Skip to content

Commit 593aeee

Browse files
committed
multiple animation example added
1 parent 40d56d3 commit 593aeee

File tree

12 files changed

+518
-15
lines changed

12 files changed

+518
-15
lines changed

.idea/assetWizardSettings.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/app/layout/motion/motionlayoutexample/ComplexAnimationActivity.kt

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,57 @@
11
package app.layout.motion.motionlayoutexample
22

3+
import android.animation.ObjectAnimator
34
import android.os.Build
45
import android.os.Bundle
56
import android.view.View
7+
import android.view.animation.BounceInterpolator
8+
import android.widget.ImageView
69
import androidx.appcompat.app.AppCompatActivity
710
import androidx.constraintlayout.motion.widget.MotionLayout
8-
import android.animation.ObjectAnimator
9-
import android.content.Context
10-
import android.view.HapticFeedbackConstants
11-
import android.view.animation.BounceInterpolator
12-
import kotlinx.android.synthetic.main.complex_animation_example.*
13-
import android.os.Vibrator
1411

1512

13+
class ComplexAnimationActivity: AppCompatActivity(), MotionLayout.TransitionListener {
14+
private val motionLayout by lazy {
15+
findViewById<MotionLayout>(R.id.motionLayout)
16+
}
17+
private val favImage by lazy {
18+
findViewById<ImageView>(R.id.favImage)
19+
}
20+
21+
private val seenImage by lazy {
22+
findViewById<ImageView>(R.id.seenImage)
23+
}
24+
private val shareImage by lazy {
25+
findViewById<ImageView>(R.id.shareImage)
26+
}
27+
28+
private val mainImage2 by lazy {
29+
findViewById<ImageView>(R.id.mainImage2)
30+
}
1631

32+
var layoutId = 0
1733

18-
class ComplexAnimationActivity: AppCompatActivity(), MotionLayout.TransitionListener {
1934
override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {
2035
}
2136

2237
override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) {
2338
if(p0 == null)
2439
return
25-
if(p0.currentState != -1)
40+
if(layoutId == R.layout.complex_animation_example && p0.currentState != -1)
2641
doBounceAnimation(mainImage2)
42+
43+
if(layoutId == R.layout.multiple_animation_example && p0.currentState != -1){
44+
doBounceAnimation(favImage)
45+
doBounceAnimation(shareImage)
46+
doBounceAnimation(seenImage)
47+
}
48+
2749
}
2850

2951
override fun onCreate(savedInstanceState: Bundle?) {
30-
3152
super.onCreate(savedInstanceState)
32-
setContentView(intent.getIntExtra("layoutId", R.layout.complex_animation_example))
53+
layoutId = intent.getIntExtra("layoutId", R.layout.complex_animation_example)
54+
setContentView(layoutId)
3355
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
3456
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
3557
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@@ -39,7 +61,6 @@ class ComplexAnimationActivity: AppCompatActivity(), MotionLayout.TransitionList
3961
or View.SYSTEM_UI_FLAG_IMMERSIVE)
4062
}
4163
motionLayout.setTransitionListener(this)
42-
4364
}
4465

4566
private fun doBounceAnimation(targetView: View) {

app/src/main/java/app/layout/motion/motionlayoutexample/MainActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class MainActivity : AppCompatActivity() {
1717
MainAdapter.Demo("Collapsing Toolbar w/ Text Interpolation", ExampleTypes.DEFAULT, R.layout.collapsing_toolbar_2),
1818
MainAdapter.Demo("Collapsing Toolbar w/ Cover Example", ExampleTypes.FULLSCREEN, R.layout.collapsing_toolbar_with_cover),
1919
MainAdapter.Demo("Complex Animation Example", ExampleTypes.WITHOUT_RECYCLER_VIEW, R.layout.complex_animation_example, ComplexAnimationActivity::class.java),
20+
MainAdapter.Demo("Multiple Animation Example", ExampleTypes.FULLSCREEN, R.layout.multiple_animation_example, ComplexAnimationActivity::class.java),
2021
MainAdapter.Demo("Basic Keyframe Example", ExampleTypes.WITHOUT_RECYCLER_VIEW, R.layout.basic_key_frame_example),
2122
MainAdapter.Demo("Basic Keyframe Example 2", ExampleTypes.WITHOUT_RECYCLER_VIEW, R.layout.basic_key_frame_example_2),
2223
MainAdapter.Demo("Notification Center Example", ExampleTypes.DEFAULT, R.layout.notification_center_example),
@@ -44,7 +45,7 @@ class MainActivity : AppCompatActivity() {
4445
}
4546

4647
fun start(activity: Class<*>, layoutFileId: Int, types: ExampleTypes?, position: Int) {
47-
if (position > 3) {
48+
if (position > 4) {
4849
Toast.makeText(this, "Coming soon...", Toast.LENGTH_LONG).show()
4950
} else {
5051
val intent = Intent(this, activity).apply {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"/>
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:fillColor="#FF000000"
8+
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
9+
</vector>
229 KB
Loading
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:background="#90caf9">
7+
8+
<ImageView
9+
android:id="@+id/seenImage"
10+
android:layout_width="30dp"
11+
android:layout_height="30dp"
12+
android:layout_marginTop="12dp"
13+
android:tint="#ffffff"
14+
app:layout_constraintEnd_toStartOf="@id/favImage"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="parent"
17+
app:srcCompat="@drawable/ic_done" />
18+
19+
<ImageView
20+
android:id="@+id/favImage"
21+
android:layout_width="30dp"
22+
android:layout_height="30dp"
23+
android:layout_marginTop="12dp"
24+
android:padding="1dp"
25+
android:tint="#ffffff"
26+
app:layout_constraintEnd_toStartOf="@id/shareImage"
27+
app:layout_constraintStart_toEndOf="@id/seenImage"
28+
app:layout_constraintTop_toTopOf="parent"
29+
app:srcCompat="@drawable/ic_fav" />
30+
31+
<ImageView
32+
android:id="@+id/shareImage"
33+
android:layout_width="30dp"
34+
android:layout_height="30dp"
35+
android:layout_marginTop="12dp"
36+
android:tint="#ffffff"
37+
android:padding="1dp"
38+
app:layout_constraintEnd_toEndOf="parent"
39+
app:layout_constraintStart_toEndOf="@id/favImage"
40+
app:layout_constraintTop_toTopOf="parent"
41+
app:srcCompat="@drawable/ic_share" />
42+
43+
<TextView
44+
android:id="@+id/seenText"
45+
android:layout_width="wrap_content"
46+
android:layout_height="wrap_content"
47+
android:layout_marginTop="2dp"
48+
android:layout_marginBottom="12dp"
49+
android:text="SEEN"
50+
android:textColor="#ffffff"
51+
android:textSize="15sp"
52+
android:textStyle="bold"
53+
android:fontFamily="serif-monospace"
54+
app:layout_constraintBottom_toBottomOf="parent"
55+
app:layout_constraintEnd_toEndOf="@id/seenImage"
56+
app:layout_constraintStart_toStartOf="@id/seenImage"
57+
app:layout_constraintTop_toBottomOf="@id/seenImage" />
58+
59+
60+
<TextView
61+
android:id="@+id/favText"
62+
android:layout_width="wrap_content"
63+
android:layout_height="wrap_content"
64+
android:layout_marginTop="4dp"
65+
android:layout_marginBottom="12dp"
66+
android:text="999"
67+
android:textColor="#ffffff"
68+
android:textSize="15sp"
69+
android:textStyle="bold"
70+
android:fontFamily="serif-monospace"
71+
app:layout_constraintBottom_toBottomOf="parent"
72+
app:layout_constraintEnd_toEndOf="@id/favImage"
73+
app:layout_constraintStart_toStartOf="@id/favImage"
74+
app:layout_constraintTop_toBottomOf="@id/favImage" />
75+
76+
77+
<TextView
78+
android:id="@+id/shareText"
79+
android:layout_width="wrap_content"
80+
android:layout_height="wrap_content"
81+
android:layout_marginTop="4dp"
82+
android:layout_marginBottom="12dp"
83+
android:textSize="15sp"
84+
android:textStyle="bold"
85+
android:fontFamily="serif-monospace"
86+
android:text="SHARE"
87+
android:textColor="#ffffff"
88+
app:layout_constraintBottom_toBottomOf="parent"
89+
app:layout_constraintEnd_toEndOf="@id/shareImage"
90+
app:layout_constraintStart_toStartOf="@id/shareImage"
91+
app:layout_constraintTop_toBottomOf="@id/shareImage" />
92+
93+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)