Closed funyin closed 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.
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