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.32k stars 695 forks source link

showShimmer(true) would not start the shimmer #91

Closed fullmoon6661 closed 5 years ago

fullmoon6661 commented 5 years ago

Calling showShimmer(true) while having attribute app:shimmer_auto_start="false" would show the shimmer but doesn't start the shimmer. I'm guessing because the following function would return immediately without checking if the shimmer has started.

/**
* Sets the ShimmerDrawable to be visible.
* @param startShimmer Whether to start the shimmer again.
*/
public void showShimmer(boolean startShimmer) {
    if (mShowShimmer) { // mShowShimmer=true
        return;
    }
    mShowShimmer = true;
    if (startShimmer) {
        startShimmer();
    }
}
xiphirx commented 5 years ago

The param there is just a convenience when showing the shimmer the first time. If its already visible then you want to use startShimmer(). The ergonomics of the function suck though, so I'll remove the early return since it doesn't seem to be preventing much