discord-jadx/app/src/main/java/androidx/core/widget/ContentLoadingProgressBar.java

98 lines
2.8 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;
import androidx.annotation.UiThread;
import y.b.b.a;
import y.b.b.b;
import y.b.b.c;
import y.b.b.d;
public class ContentLoadingProgressBar extends ProgressBar {
private static final int MIN_DELAY_MS = 500;
private static final int MIN_SHOW_TIME_MS = 500;
private final Runnable mDelayedHide;
private final Runnable mDelayedShow;
public boolean mDismissed;
public boolean mPostedHide;
public boolean mPostedShow;
public long mStartTime;
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 a(this);
this.mDelayedShow = new c(this);
}
public static /* synthetic */ void a(ContentLoadingProgressBar contentLoadingProgressBar) {
contentLoadingProgressBar.hideOnUiThread();
}
public static /* synthetic */ void b(ContentLoadingProgressBar contentLoadingProgressBar) {
contentLoadingProgressBar.showOnUiThread();
}
@UiThread
private void hideOnUiThread() {
this.mDismissed = true;
removeCallbacks(this.mDelayedShow);
this.mPostedShow = false;
long currentTimeMillis = System.currentTimeMillis();
long j = this.mStartTime;
long j2 = currentTimeMillis - j;
if (j2 >= 500 || j == -1) {
setVisibility(8);
} else if (!this.mPostedHide) {
postDelayed(this.mDelayedHide, 500 - j2);
this.mPostedHide = true;
}
}
private void removeCallbacks() {
removeCallbacks(this.mDelayedHide);
removeCallbacks(this.mDelayedShow);
}
@UiThread
private void showOnUiThread() {
this.mStartTime = -1;
this.mDismissed = false;
removeCallbacks(this.mDelayedHide);
this.mPostedHide = false;
if (!this.mPostedShow) {
postDelayed(this.mDelayedShow, 500);
this.mPostedShow = true;
}
}
public void hide() {
post(new b(this));
}
@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 void show() {
post(new d(this));
}
}