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

Add show + hide functionality #86

Closed ScottCooper92 closed 5 years ago

ScottCooper92 commented 5 years ago

PR for #85

It doesn't seem like the best implementation since I'm just nulling the Shimmer but it does the job.

I've tested this in the sample app by depending on the library project rather than the snapshot and added another button for toggling it on and off but haven't included any of that in this PR. If you would like me to I'll update it.

ScottCooper92 commented 5 years ago

I knew there would be an easier way to do it, I don't have a great deal of experience with custom drawables though.

Show + hide now stop and start the ShimmerDrawable respectively and boolean gate the call to mShimmerDrawable.draw(canvas); as suggested. Interestingly if the shimmer is stopped, then we end up with the same problem of it still being visible, which is why the invalidate() call is necessary, again if there's a better way of doing this let me know.

facebook-github-bot commented 5 years ago

@xiphirx merged this pull request in facebook/shimmer-android@97ca4d1d7cd1ec4e3435ee46a1748da00aa0511e.