diff options
Diffstat (limited to 'core/java/android/widget/ProgressBar.java')
| -rw-r--r-- | core/java/android/widget/ProgressBar.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 3c45e8c5d78b..1b76ebf7c8c6 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -70,6 +70,7 @@ import com.android.internal.R; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.Locale; /** * <p> @@ -250,6 +251,9 @@ public class ProgressBar extends View { private ObjectAnimator mLastProgressAnimator; + private NumberFormat mPercentFormat; + private Locale mCachedLocale; + /** * Create a new progress bar with range 0...100 and initial progress of 0. * @param context the application environment @@ -819,6 +823,7 @@ public class ProgressBar extends View { * @see #setIndeterminateTintList(ColorStateList) * @see Drawable#setTintBlendMode(BlendMode) */ + @RemotableViewMethod public void setIndeterminateTintBlendMode(@Nullable BlendMode blendMode) { if (mProgressTintInfo == null) { mProgressTintInfo = new ProgressTintInfo(); @@ -1128,6 +1133,7 @@ public class ProgressBar extends View { * @see #getProgressTintMode() * @see Drawable#setTintBlendMode(BlendMode) */ + @RemotableViewMethod public void setProgressTintBlendMode(@Nullable BlendMode blendMode) { if (mProgressTintInfo == null) { mProgressTintInfo = new ProgressTintInfo(); @@ -1244,6 +1250,7 @@ public class ProgressBar extends View { * @see #setProgressBackgroundTintList(ColorStateList) * @see Drawable#setTintBlendMode(BlendMode) */ + @RemotableViewMethod public void setProgressBackgroundTintBlendMode(@Nullable BlendMode blendMode) { if (mProgressTintInfo == null) { mProgressTintInfo = new ProgressTintInfo(); @@ -1301,6 +1308,7 @@ public class ProgressBar extends View { * @see #getSecondaryProgressTintList() * @see Drawable#setTintList(ColorStateList) */ + @RemotableViewMethod public void setSecondaryProgressTintList(@Nullable ColorStateList tint) { if (mProgressTintInfo == null) { mProgressTintInfo = new ProgressTintInfo(); @@ -1356,6 +1364,7 @@ public class ProgressBar extends View { * @see #setSecondaryProgressTintList(ColorStateList) * @see Drawable#setTintBlendMode(BlendMode) */ + @RemotableViewMethod public void setSecondaryProgressTintBlendMode(@Nullable BlendMode blendMode) { if (mProgressTintInfo == null) { mProgressTintInfo = new ProgressTintInfo(); @@ -1589,8 +1598,15 @@ public class ProgressBar extends View { * @return state description based on progress */ private CharSequence formatStateDescription(int progress) { - return NumberFormat.getPercentInstance(mContext.getResources().getConfiguration().locale) - .format(getPercent(progress)); + // Cache the locale-appropriate NumberFormat. Configuration locale is guaranteed + // non-null, so the first time this is called we will always get the appropriate + // NumberFormat, then never regenerate it unless the locale changes on the fly. + final Locale curLocale = mContext.getResources().getConfiguration().getLocales().get(0); + if (!curLocale.equals(mCachedLocale)) { + mCachedLocale = curLocale; + mPercentFormat = NumberFormat.getPercentInstance(curLocale); + } + return mPercentFormat.format(getPercent(progress)); } /** @@ -1604,6 +1620,7 @@ public class ProgressBar extends View { * @param stateDescription The state description. */ @Override + @RemotableViewMethod public void setStateDescription(@Nullable CharSequence stateDescription) { mCustomStateDescription = stateDescription; if (stateDescription == null) { |
