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
private fun takeScreenshot() { | |
val fullScreen = requireActivity().window.decorView.rootView | |
bitmapBackground = Bitmap.createBitmap(fullScreen.width, fullScreen.height, Bitmap.Config.ARGB_8888) | |
canvasFullscreen = Canvas(bitmapBackground) | |
fullScreen.draw(canvasFullscreen) | |
bitmapBackgroundDrawable = BitmapDrawable(resources, bitmapBackground) | |
requireActivity().window.setBackgroundDrawable(bitmapBackgroundDrawable) | |
} |
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
binding.motionLayoutRoot.setTransitionListener(object : MotionLayout.TransitionListener { | |
override fun onTransitionTrigger(p0: MotionLayout?, startId: Int, endId: Boolean, p3: Float) {} | |
override fun allowsTransition(p0: MotionScene.Transition?): Boolean {} | |
override fun onTransitionStarted(p0: MotionLayout?, startId: Int, endId: Int) {} | |
override fun onTransitionChange(p0: MotionLayout?, startId: Int, endId: Int, progress: Float) {} | |
override fun onTransitionCompleted(p0: MotionLayout?, endId: Int) {} |
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
<Transition | |
motion:constraintSetEnd="@id/endSwipeScene" | |
motion:constraintSetStart="@id/endScene" | |
motion:duration="600"> | |
<OnClick | |
motion:clickAction="toggle" | |
motion:targetId="@+id/sendButton" /> | |
</Transition> |
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
<ConstraintSet android:id="@+id/endSwipeScene"> | |
<Constraint | |
android:id="@+id/rootCL" | |
motion:visibilityMode="ignore" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:rotation="45" | |
android:scaleX="0.95" | |
android:scaleY="0.95" | |
android:translationX="600dp" /> |
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"?> | |
<androidx.constraintlayout.motion.widget.MotionLayout | |
android:layout_width="match_parent" | |
android:layout_height="300dp" | |
app:layoutDescription="@xml/ml_scene"> | |
<androidx.cardview.widget.CardView | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> |
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"?> | |
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<ConstraintSet android:id="@+id/rest"> | |
<Constraint | |
android:id="@+id/cardView" | |
android:layout_width="0dp" | |
android:layout_height="0dp" | |
android:layout_marginStart="10dp" |
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
<ConstraintSet | |
android:id="@+id/like" | |
app:deriveConstraintsFrom="@id/rest"> | |
<Constraint | |
android:id="@+id/cardViewScene" | |
android:layout_marginStart="300dp" | |
android:rotation="45" | |
app:layout_constraintHeight_percent="0.9" | |
app:layout_constraintStart_toStartOf="parent" | |
app:layout_constraintTop_toTopOf="parent" |
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
<Transition | |
app:constraintSetEnd="@id/like" | |
app:constraintSetStart="@id/rest" | |
app:duration="100"> | |
<OnSwipe | |
app:dragDirection="dragRight" | |
app:onTouchUp="autoCompleteToStart" | |
app:touchAnchorId="@id/cardView" | |
app:touchAnchorSide="right" /> |
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
enum class AnimationState { | |
STARTED, COMPLETED, IN_PROGRESS | |
} |
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 ViewHolder(private val mView: View) : | |
RecyclerView.ViewHolder(mView) { | |
fun bind( | |
item: MyItem | |
animationListener: (state: AnimationState) -> Unit | |
) { | |
(mView as MotionLayout).apply { | |
setTransitionListener(object : MotionLayout.TransitionListener { | |
override fun onTransitionTrigger( |