108 lines
3.5 KiB
Java
108 lines
3.5 KiB
Java
package androidx.core.widget;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.widget.ProgressBar;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
public class ContentLoadingProgressBar extends ProgressBar {
|
|
private static final int MIN_DELAY = 500;
|
|
private static final int MIN_SHOW_TIME = 500;
|
|
private final Runnable mDelayedHide;
|
|
private final Runnable mDelayedShow;
|
|
public boolean mDismissed;
|
|
public boolean mPostedHide;
|
|
public boolean mPostedShow;
|
|
public long mStartTime;
|
|
|
|
/* renamed from: androidx.core.widget.ContentLoadingProgressBar$1 reason: invalid class name */
|
|
public class AnonymousClass1 implements Runnable {
|
|
public AnonymousClass1() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ContentLoadingProgressBar contentLoadingProgressBar = ContentLoadingProgressBar.this;
|
|
contentLoadingProgressBar.mPostedHide = false;
|
|
contentLoadingProgressBar.mStartTime = -1;
|
|
contentLoadingProgressBar.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.core.widget.ContentLoadingProgressBar$2 reason: invalid class name */
|
|
public class AnonymousClass2 implements Runnable {
|
|
public AnonymousClass2() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ContentLoadingProgressBar contentLoadingProgressBar = ContentLoadingProgressBar.this;
|
|
contentLoadingProgressBar.mPostedShow = false;
|
|
if (!contentLoadingProgressBar.mDismissed) {
|
|
contentLoadingProgressBar.mStartTime = System.currentTimeMillis();
|
|
ContentLoadingProgressBar.this.setVisibility(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public ContentLoadingProgressBar(@NonNull Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public ContentLoadingProgressBar(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
|
super(context, attributeSet, 0);
|
|
this.mStartTime = -1;
|
|
this.mPostedHide = false;
|
|
this.mPostedShow = false;
|
|
this.mDismissed = false;
|
|
this.mDelayedHide = new AnonymousClass1();
|
|
this.mDelayedShow = new AnonymousClass2();
|
|
}
|
|
|
|
private void removeCallbacks() {
|
|
removeCallbacks(this.mDelayedHide);
|
|
removeCallbacks(this.mDelayedShow);
|
|
}
|
|
|
|
public synchronized void hide() {
|
|
this.mDismissed = true;
|
|
removeCallbacks(this.mDelayedShow);
|
|
this.mPostedShow = false;
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long j = this.mStartTime;
|
|
long j2 = currentTimeMillis - j;
|
|
if (j2 < 500) {
|
|
if (j != -1) {
|
|
if (!this.mPostedHide) {
|
|
postDelayed(this.mDelayedHide, 500 - j2);
|
|
this.mPostedHide = true;
|
|
}
|
|
}
|
|
}
|
|
setVisibility(8);
|
|
}
|
|
|
|
@Override // android.widget.ProgressBar, android.view.View
|
|
public void onAttachedToWindow() {
|
|
super.onAttachedToWindow();
|
|
removeCallbacks();
|
|
}
|
|
|
|
@Override // android.widget.ProgressBar, android.view.View
|
|
public void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
removeCallbacks();
|
|
}
|
|
|
|
public synchronized void show() {
|
|
this.mStartTime = -1;
|
|
this.mDismissed = false;
|
|
removeCallbacks(this.mDelayedHide);
|
|
this.mPostedHide = false;
|
|
if (!this.mPostedShow) {
|
|
postDelayed(this.mDelayedShow, 500);
|
|
this.mPostedShow = true;
|
|
}
|
|
}
|
|
}
|