This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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?) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PreLoadLayoutManager extends LinearLayoutManager { | |
private final int mDisplayHeight; | |
public PreLoadLayoutManager(Context context) { | |
super(context); | |
mDisplayHeight = context.getResources().getDisplayMetrics().heightPixels; | |
} | |
@Override |
NewerOlder