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

stopShimmer leaves ShimmerDrawable visible #85

Closed ScottCooper92 closed 5 years ago

ScottCooper92 commented 5 years ago

I might be using this library differently from how it was intended but I think this issue could be any easy fix.

I have my RecyclerView inside the ShimmerFrameLayout, when the view is first created RecyclerViewAdapter is given a list of null and the adapter represents each of the nulls by creating placeholder ViewHolders, I then tell the ShimmerFrameLayout to start shimmering.

Once content has arrived the nulls are replaced with actual data and the ViewHolders are populated, the shimmering is then stopped using stopShimmer(). The issue is that the mShimmerDrawable in ShimmerFrameLayout is still displayed meaning the content is masked.

I can work around this by setting the shimmer to null when stopping it and then adding it again when starting like so:

shimmerLayout.stopShimmer()
shimmerLayout.setShimmer(null)
shimmerLayout.setShimmer(Shimmer.AlphaHighlightBuilder().build())
shimmerLayout.startShimmer()

Can this be handled internally by either hiding the drawable when stopping or through some other means?

Subroid commented 5 years ago

I think the separate layout has to be provided for shimmer layout. Check this article https://medium.com/mindorks/android-design-shimmer-effect-fa7f74c68a93

xiphirx commented 5 years ago

stopShimmer stops the shimmering animation, if you want it completely gone, then you do need to setShimmer(null). Adding hideShimmer, showShimmer methods seems fine, though.

xiphirx commented 5 years ago

PR for that is certainly welcome if you're up for it :)

ScottCooper92 commented 5 years ago

Closed as part of #86