facebookarchive / shimmer-android

An easy, flexible way to add a shimmering effect to any view in an Android app.
http://facebook.github.io/shimmer-android/
Other
5.31k stars 698 forks source link

isShimmerVisible and isShimmerStarted values are not consistent #111

Closed funyin closed 3 years ago

funyin commented 3 years ago

I wrote a toggle function for the shimmer and it didn't work because of the way their values were initialized in the widget class(ShimmerFrameLayout) private fun toggleShimmer(view: ShimmerFrameLayout) { if (!view.isShimmerVisible) { view.showShimmer(true) } else view.hideShimmer() }

In the widget class, mShimmerVisible i.e isShimmerVisible is set to true initially when the view is created and this is not true because the shimmer is not visible by default

xiphirx commented 3 years ago

The default state of the class is to show the shimmer, which is why its set to true. isShimmerVisible does not detail whether the View itself is visible, merely whether the View will decide to draw the shimmer because its entirely possible to have a visible View with a hidden shimmer.

Your toggle function looks fine, it just seems like its being called incorrectly.