Skip to content

Commit 8be6ad7

Browse files
committed
animate history items appearing
1 parent 160f096 commit 8be6ad7

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

app/src/main/java/replete/HistoryAdapter.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.text.SpannableString
66
import android.view.LayoutInflater
77
import android.view.View
88
import android.view.ViewGroup
9+
import android.view.animation.AnimationUtils
910
import android.widget.ArrayAdapter
1011
import android.widget.ListView
1112
import android.widget.TextView
@@ -28,6 +29,8 @@ fun inflateItem(viewHolder: HistoryAdapter.ViewHolder, item: Item) {
2829
class HistoryAdapter(context: Context, id: Int, val parent: ListView) :
2930
ArrayAdapter<Item>(context, id) {
3031

32+
val animation = AnimationUtils.loadAnimation(parent.context, R.anim.entry_appears)
33+
3134
fun update(item: Item) {
3235
this.add(item)
3336
parent.post {
@@ -51,6 +54,8 @@ class HistoryAdapter(context: Context, id: Int, val parent: ListView) :
5154
inflateItem(viewHolder, item)
5255
}
5356

57+
_itemView.startAnimation(animation)
58+
5459
return _itemView
5560
} else {
5661
if (item != null) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:duration="@android:integer/config_mediumAnimTime">
4+
5+
<translate
6+
android:fromXDelta="-100%"
7+
android:toXDelta="0"
8+
android:interpolator="@android:anim/decelerate_interpolator"
9+
/>
10+
11+
<alpha
12+
android:fromAlpha="0"
13+
android:toAlpha="1"
14+
android:interpolator="@android:anim/decelerate_interpolator"
15+
/>
16+
17+
</set>

0 commit comments

Comments
 (0)