From 067870c679c07ca00e4227391a6596935e863fc7 Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Tue, 19 May 2020 14:48:55 -0500 Subject: [PATCH] Reproduce onTransitionCompleted bug --- ConstraintLayoutExamples/build.gradle | 2 +- .../motionlayoutexample/DemoActivity.kt | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ConstraintLayoutExamples/build.gradle b/ConstraintLayoutExamples/build.gradle index 6b6ff83f..aa642f19 100644 --- a/ConstraintLayoutExamples/build.gradle +++ b/ConstraintLayoutExamples/build.gradle @@ -27,7 +27,7 @@ buildscript { targetSdkVersion = 28 appCompatVersion = '1.1.0-alpha03' - constraintLayoutVersion = '2.0.0-beta3' + constraintLayoutVersion = '2.0.0-beta6' glideVersion = '4.8.0' kotlinVersion = '1.3.71' lifeCycleVersion = '2.0.0' diff --git a/ConstraintLayoutExamples/motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/DemoActivity.kt b/ConstraintLayoutExamples/motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/DemoActivity.kt index 862f6b73..75eb70f9 100644 --- a/ConstraintLayoutExamples/motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/DemoActivity.kt +++ b/ConstraintLayoutExamples/motionlayout/src/main/java/com/google/androidstudio/motionlayoutexample/DemoActivity.kt @@ -18,6 +18,7 @@ package com.google.androidstudio.motionlayoutexample import android.os.Build import android.os.Bundle +import android.util.Log import android.view.View import android.widget.ImageView import androidx.annotation.RequiresApi @@ -45,7 +46,37 @@ class DemoActivity : AppCompatActivity() { } else { MotionLayout.DEBUG_SHOW_NONE } - (container as? MotionLayout)?.setDebugMode(debugMode) + (container as? MotionLayout)?.apply { + setDebugMode(debugMode) + setTransitionListener(object : MotionLayout.TransitionListener { + override fun onTransitionTrigger( + motionLayout: MotionLayout, + triggerId: Int, + positive: Boolean, + progress: Float + ) = Unit + + override fun onTransitionStarted( + motionLayout: MotionLayout, + startId: Int, + endId: Int + ) = Unit + + override fun onTransitionChange( + motionLayout: MotionLayout, + startId: Int, + endId: Int, + progress: Float + ) = Unit + + override fun onTransitionCompleted(motionLayout: MotionLayout, currentId: Int) { + Log.d( + "DemoActivity", + "$currentId: currentId is start: ${currentId == R.id.start}, currentId is end: ${currentId == R.id.end}" + ) + } + }) + } } fun changeState(v: View?) {