Skip to content

Commit

Permalink
update drawable immediately after copy is created
Browse files Browse the repository at this point in the history
Lars Werkman committed Apr 23, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 692d001 commit d8af425
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package com.larswerkman.skeletonloading
import android.graphics.drawable.Drawable

class SkeletonBinder internal constructor(
private val style: Drawable,
private val drawable: () -> Drawable,
private val views: MutableList<ISkeletonView>
) {

@@ -15,7 +15,7 @@ class SkeletonBinder internal constructor(

init {
views.forEach {
it.setup(style.constantState?.newDrawable() ?: style)
it.setup(drawable())
}
}

Original file line number Diff line number Diff line change
@@ -24,18 +24,15 @@ class SkeletonLoading(

private val binders = CopyOnWriteArrayList<SkeletonBinder>()

init {
animation?.progress?.update(drawable)
}

fun create(block: SkeletonBinder.Builder.() -> Unit): SkeletonBinder {
val builder = SkeletonBinder.Builder()
block(builder)

val binder = SkeletonBinder(drawable, builder.views)
binders += binder

return binder
return SkeletonBinder({
drawable.constantState?.newDrawable()?.also {
animation?.progress?.update(it)
} ?: drawable
}, builder.views).also { binders += it }
}

fun register(owner: LifecycleOwner) {

0 comments on commit d8af425

Please sign in to comment.