Skip to content

Instantly share code, notes, and snippets.

View tmaxxdd's full-sized avatar
💻
In my mind, 🍺 in my heart

Tomasz Kądziołka tmaxxdd

💻
In my mind, 🍺 in my heart
View GitHub Profile
Room
.databaseBuilder(this, Database.class, "database")
.addMigrations(Migrations.MIGRATION_1_2)
.build();
V/MotionLayout: CHECK: start is hided
V/MotionLayout: CHECK: end is shown
W/MotionLayout: CHECK: hided NO View matches id itemBackground
W/MotionLayout: CHECK: hided(itemBackground) no LAYOUT_HEIGHT
W/MotionLayout: CHECK: hided NO View matches id dragLabel
W/MotionLayout: CHECK: hided NO View matches id itemForeground
W/MotionLayout: CHECK: hided(itemForeground) no LAYOUT_HEIGHT
W/MotionLayout: CHECK: hided NO View matches id deleteAction
V/MotionLayout: CHECK: CURRENT
V/MotionLayout: CHECK: transition = hided -> shown
<!-- This is applied for default -->
<Transition
app:constraintSetEnd="@id/panelExpanded"
app:constraintSetStart="@id/panelCollapsed"
app:duration="500">
<OnSwipe app:dragDirection="dragRight" />
</Transition>
<!-- This must be set explicitly from code or xml -->
<Transition
<MotionScene>
<!-- You must implement all the attributes -->
<ConstraintSet android:id="@+id/viewsInvisible">
<Constraint android:id="@+id/loading">
<Layout
android:layout_width="64dp"
android:layout_height="64dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
class MotionProgressListener(private val progressListener: (Float) -> Unit) :
MotionLayout.TransitionListener {
override fun onTransitionTrigger(layout: MotionLayout?, triggerId: Int, positive: Boolean, progress: Float) {}
override fun onTransitionStarted(layout: MotionLayout?, startId: Int, endId: Int) {}
override fun onTransitionChange(layout: MotionLayout?, startId: Int, endId: Int, progress: Float) {
progressListener.invoke(progress)
}
override fun onTransitionCompleted(layout: MotionLayout?, currentId: Int) {}
}
val target = card,
val propertyName = "radius",
val startRadius = 4f
val endRadius = 500f
ObjectAnimator.ofFloat(target, propertyName, startRadius, endRadius).apply {
startDelay = 2000
duration = 5000
start()
}
bottomSheetSwitch.setOnCheckedChangeListener { _, bottomSheetSmall ->
if (bottomSheetSmall)
motionLayout.loadLayoutDescription(R.xml.expandable_bottom_sheet_small)
else
motionLayout.loadLayoutDescription(R.xml.expandable_bottom_sheet_big)
}
<ConstraintSet
android:id="@+id/end"
motion:deriveConstraintsFrom="@id/start">
<Constraint
android:id="@+id/card"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
motionLayout.setTransitionListener(MotionProgressListener { progress: Float ->
lottie.progress = progress
arrow.isVisible = (progress <= 0.5f)
editText.isVisible = (progress >= 0.5f)
})
<com.google.android.material.card.MaterialCardView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
app:cardCornerRadius="0dp"
app:cardElevation="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">