Last active
October 12, 2016 13:17
-
-
Save jsonfry/374c3eb5b8eb88d2a674100d6bfecd92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package co.blah.ui.widget; | |
import android.annotation.TargetApi; | |
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.os.Build; | |
import android.provider.Settings; | |
import android.util.AttributeSet; | |
import android.widget.ProgressBar; | |
public class TestableIndeterminateProgressBar extends ProgressBar { | |
public TestableIndeterminateProgressBar(Context context) { | |
super(context); | |
} | |
public TestableIndeterminateProgressBar(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public TestableIndeterminateProgressBar(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
} | |
@TargetApi(21) | |
public TestableIndeterminateProgressBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { | |
super(context, attrs, defStyleAttr, defStyleRes); | |
} | |
@Override | |
public void setIndeterminateDrawable(Drawable drawable) { | |
super.setIndeterminateDrawable(hideIndeterminateDrawable() ? null : drawable); | |
} | |
private boolean hideIndeterminateDrawable() { | |
return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && | |
Settings.Global.getFloat(getContext().getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 1) == 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment