@@ -75,18 +75,18 @@ public class BaseProgressIndicator extends ProgressBar {
7575 public static final int HIDE_OUTWARD = 1 ;
7676 public static final int HIDE_INWARD = 2 ;
7777
78- protected static final int DEF_STYLE_RES = R .style .Widget_MaterialComponents_ProgressIndicator ;
78+ static final int DEF_STYLE_RES = R .style .Widget_MaterialComponents_ProgressIndicator ;
7979
80- protected static final float DEFAULT_OPACITY = 0.2f ;
81- protected static final int MAX_ALPHA = 255 ;
80+ static final float DEFAULT_OPACITY = 0.2f ;
81+ static final int MAX_ALPHA = 255 ;
8282 /**
8383 * The maximum time, in milliseconds, that the requested hide action is allowed to wait once
8484 * {@link #show()} is called.
8585 */
8686 private static final int MAX_HIDE_DELAY = 1000 ;
8787
8888 /** A place to hold all the attributes. */
89- protected final BaseProgressIndicatorSpec baseSpec ;
89+ final BaseProgressIndicatorSpec baseSpec ;
9090
9191 /** A temp place to hold new progress while switching from indeterminate to determinate mode. */
9292 private int storedProgress ;
@@ -251,8 +251,8 @@ public void hide() {
251251 * @see #hide()
252252 */
253253 private void internalHide () {
254- getCurrentDrawable ()
255- .setVisible (/*visible=*/ false , /*restart=*/ false , /*animationDesired =*/ true );
254+ (( DrawableWithAnimatedVisibilityChange ) getCurrentDrawable () )
255+ .setVisible (/*visible=*/ false , /*restart=*/ false , /*animate =*/ true );
256256
257257 if (isNoLongerNeedToBeVisible ()) {
258258 setVisibility (INVISIBLE );
@@ -262,27 +262,28 @@ private void internalHide() {
262262 @ Override
263263 protected void onVisibilityChanged (@ NonNull View changedView , int visibility ) {
264264 super .onVisibilityChanged (changedView , visibility );
265- applyNewVisibility (/*animationDesired =*/ visibility == VISIBLE );
265+ applyNewVisibility (/*animate =*/ visibility == VISIBLE );
266266 }
267267
268268 @ Override
269269 protected void onWindowVisibilityChanged (int visibility ) {
270270 super .onWindowVisibilityChanged (visibility );
271- applyNewVisibility (/*animationDesired =*/ false );
271+ applyNewVisibility (/*animate =*/ false );
272272 }
273273
274274 /**
275275 * If it changes to visible, the start animation will be started if {@code showAnimationBehavior}
276276 * indicates any. If it changes to invisible, hides the drawable immediately.
277277 *
278- * @param animationDesired Whether to change the visibility with animation.
278+ * @param animate Whether to change the visibility with animation.
279279 */
280- protected void applyNewVisibility (boolean animationDesired ) {
280+ protected void applyNewVisibility (boolean animate ) {
281281 if (!isParentDoneInitializing ) {
282282 return ;
283283 }
284284
285- getCurrentDrawable ().setVisible (visibleToUser (), /*restart=*/ false , animationDesired );
285+ ((DrawableWithAnimatedVisibilityChange ) getCurrentDrawable ())
286+ .setVisible (visibleToUser (), /*restart=*/ false , animate );
286287 }
287288
288289 @ Override
@@ -300,7 +301,7 @@ protected void onDetachedFromWindow() {
300301 // Removes the delayedHide and delayedShow runnables from the queue if it has been scheduled.
301302 removeCallbacks (delayedHide );
302303 removeCallbacks (delayedShow );
303- getCurrentDrawable ().hideNow ();
304+ (( DrawableWithAnimatedVisibilityChange ) getCurrentDrawable () ).hideNow ();
304305 unregisterAnimationCallbacks ();
305306 super .onDetachedFromWindow ();
306307 }
@@ -329,6 +330,9 @@ protected synchronized void onDraw(@NonNull Canvas canvas) {
329330 protected synchronized void onMeasure (int widthMeasureSpec , int heightMeasureSpec ) {
330331 super .onMeasure (widthMeasureSpec , heightMeasureSpec );
331332 DrawingDelegate drawingDelegate = getCurrentDrawingDelegate ();
333+ if (drawingDelegate == null ) {
334+ return ;
335+ }
332336 int drawableMeasuredWidth = drawingDelegate .getPreferredWidth ();
333337 int drawableMeasuredHeight = drawingDelegate .getPreferredHeight ();
334338 setMeasuredDimension (
@@ -353,13 +357,13 @@ public void invalidate() {
353357 /** Returns the corresponding drawable based on current indeterminate state. */
354358 @ Override
355359 @ Nullable
356- public DrawableWithAnimatedVisibilityChange getCurrentDrawable () {
360+ public Drawable getCurrentDrawable () {
357361 return isIndeterminate () ? getIndeterminateDrawable () : getProgressDrawable ();
358362 }
359363
360364 /** Returns the drawing delegate associated with the current drawable. */
361365 @ Nullable
362- public DrawingDelegate getCurrentDrawingDelegate () {
366+ private DrawingDelegate getCurrentDrawingDelegate () {
363367 if (isIndeterminate ()) {
364368 return getIndeterminateDrawable () == null
365369 ? null
@@ -431,7 +435,7 @@ public IndeterminateDrawable getIndeterminateDrawable() {
431435 * Returns whether or not this view is currently displayed in window, based on whether it is
432436 * attached to a window and whether it and its ancestors are visible.
433437 */
434- protected boolean visibleToUser () {
438+ boolean visibleToUser () {
435439 return ViewCompat .isAttachedToWindow (this )
436440 && getWindowVisibility () == View .VISIBLE
437441 && isEffectivelyVisible ();
@@ -460,7 +464,7 @@ && getWindowVisibility() == View.VISIBLE
460464 * conclusively prove otherwise (but may result in some false positives, if this view ends up
461465 * being attached to a non-visible hierarchy after being detached in a visible state).
462466 */
463- protected boolean isEffectivelyVisible () {
467+ boolean isEffectivelyVisible () {
464468 View current = this ;
465469 do {
466470 if (current .getVisibility () != VISIBLE ) {
@@ -508,14 +512,16 @@ public synchronized void setIndeterminate(boolean indeterminate) {
508512
509513 // Needs to explicitly set visibility of two drawables. ProgressBar.setIndeterminate doesn't
510514 // handle it properly for pre-lollipop.
511- DrawableWithAnimatedVisibilityChange oldDrawable = getCurrentDrawable ();
515+ DrawableWithAnimatedVisibilityChange oldDrawable =
516+ (DrawableWithAnimatedVisibilityChange ) getCurrentDrawable ();
512517 if (oldDrawable != null ) {
513518 oldDrawable .hideNow ();
514519 }
515520 super .setIndeterminate (indeterminate );
516- DrawableWithAnimatedVisibilityChange newDrawable = getCurrentDrawable ();
521+ DrawableWithAnimatedVisibilityChange newDrawable =
522+ (DrawableWithAnimatedVisibilityChange ) getCurrentDrawable ();
517523 if (newDrawable != null ) {
518- newDrawable .setVisible (visibleToUser (), /*restart=*/ false , /*animationDesired =*/ false );
524+ newDrawable .setVisible (visibleToUser (), /*restart=*/ false , /*animate =*/ false );
519525 }
520526
521527 // Indeterminate mode change finished.
@@ -691,7 +697,7 @@ public void setHideAnimationBehavior(@HideAnimationBehavior int hideAnimationBeh
691697 *
692698 * @param progress The new progress value.
693699 * @see ProgressBar#setProgress(int)
694- * @see #setProgress (int, boolean)
700+ * @see #setProgressCompat (int, boolean)
695701 */
696702 @ Override
697703 public synchronized void setProgress (int progress ) {
0 commit comments