Skip to content

Instantly share code, notes, and snippets.

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,
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?) {
}
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) {
<?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"
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
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
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" +
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) {
@amyu
amyu / hoge.xml
Created November 24, 2015 05:32
<?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"
public class PreLoadLayoutManager extends LinearLayoutManager {
private final int mDisplayHeight;
public PreLoadLayoutManager(Context context) {
super(context);
mDisplayHeight = context.getResources().getDisplayMetrics().heightPixels;
}
@Override