Skip to content

Instantly share code, notes, and snippets.

Yuki Mima amyu

Block or report user

Report or block amyu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View StackCardLayoutManager.kt
class StackCardLayoutManager : RecyclerView.LayoutManager() {
private val children: List<View>
get() = (0 until childCount).map { getChildAt(it) ?: throw NullPointerException() }
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams =
RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.MATCH_PARENT)
//初回のViewレイアウト
override fun onLayoutChildren(
recycler: RecyclerView.Recycler,
View MovableConstraintLayout.kt
class MovableConstraintLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), GestureDetector.OnGestureListener {
private val detector: GestureDetectorCompat = GestureDetectorCompat(context, this)
override fun onShowPress(e: MotionEvent?) {
}
View NonSwipeViewPager.kt
class NonSwipeViewPager @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ViewPager(context, attrs) {
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean = false
override fun onTouchEvent(ev: MotionEvent?): Boolean = false
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean =
when (event?.action) {
View flexbox.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:flexWrap="wrap">
<TextView
android:layout_width="wrap_content"
View TransparentActivity.kt
class TransparentActivity : AppCompatActivity() {
companion object {
fun createIntent(context: Context): Intent = Intent(context, TransparentActivity::class.java)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_transparent)
val rootView = window.decorView.findViewById<View>(android.R.id.content).rootView
View DiffUtilCallback.kt
import android.support.v7.util.DiffUtil
class DiffUtilCallback<T>(private val oldList: List<T>, private val newList: List<T>) : DiffUtil.Callback() {
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean = oldList[oldItemPosition] == newList[newItemPosition]
override fun getOldListSize(): Int = oldList.size
override fun getNewListSize(): Int = newList.size
View TestDate.java
class TestData {
@Language("XML")
static String USE_NUMBER_PICKER_WHEN_USE_DATABINDING = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<layout>\n" +
"\n" +
" <data>\n" +
"\n" +
" <variable\n" +
" name=\"hgoe\"\n" +
View DatabindingableNumberPicker.kt
class DatabindingableNumberPicker : NumberPicker {
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr)
private var isCallSetMaxValueBeforeSetValue = false
private var tempValue = 0
override fun setValue(value: Int) {
if (!isCallSetMaxValueBeforeSetValue) {
View hoge.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:id="@+id/card_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
View PreLoadLayoutManager.java
public class PreLoadLayoutManager extends LinearLayoutManager {
private final int mDisplayHeight;
public PreLoadLayoutManager(Context context) {
super(context);
mDisplayHeight = context.getResources().getDisplayMetrics().heightPixels;
}
@Override
You can’t perform that action at this time.