Skip to content

Commit 9c06bf8

Browse files
author
Lars Werkman
committed
keep main drawable in sync with animation
1 parent b414fa5 commit 9c06bf8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

skeletonloading/src/main/java/com/larswerkman/skeletonloading/SkeletonAnimation.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class SkeletonAnimation(
1515
) {
1616

1717
private var animator: ValueAnimator? = null
18-
private val progress = Progress(start)
18+
val progress = Progress(start)
1919

2020
private fun create() {
2121
animator = ValueAnimator.ofFloat(start, end)

skeletonloading/src/main/java/com/larswerkman/skeletonloading/SkeletonLoading.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class SkeletonLoading(
2323

2424
private val binders = CopyOnWriteArrayList<SkeletonBinder>()
2525

26+
init {
27+
animation?.progress?.update(drawable)
28+
}
29+
2630
fun create(block: SkeletonBinder.Builder.() -> Unit): SkeletonBinder {
2731
val builder = SkeletonBinder.Builder()
2832
block(builder)
@@ -36,6 +40,8 @@ class SkeletonLoading(
3640
@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
3741
fun onCreate() {
3842
animation?.start { progress ->
43+
progress.update(drawable)
44+
3945
binders.forEach { binder ->
4046
if (binder.isUnbound) {
4147
binders.remove(binder)

0 commit comments

Comments
 (0)