mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 19:34:15 +01:00
Added loading show delay attribute
This commit is contained in:
@@ -20,6 +20,7 @@ package eu.faircode.email;
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
@@ -29,6 +30,7 @@ import androidx.annotation.Nullable;
|
||||
public class ContentLoadingProgressBar extends ProgressBar {
|
||||
private int visibility = VISIBLE;
|
||||
private boolean init = false;
|
||||
private int delay = VISIBILITY_DELAY;
|
||||
private boolean delaying = false;
|
||||
|
||||
private static final int VISIBILITY_DELAY = 1500; // milliseconds
|
||||
@@ -39,14 +41,22 @@ public class ContentLoadingProgressBar extends ProgressBar {
|
||||
|
||||
public ContentLoadingProgressBar(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs, 0);
|
||||
getAttr(context, attrs);
|
||||
}
|
||||
|
||||
public ContentLoadingProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
getAttr(context, attrs);
|
||||
}
|
||||
|
||||
public ContentLoadingProgressBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
getAttr(context, attrs);
|
||||
}
|
||||
|
||||
private void getAttr(Context context, AttributeSet attrs) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ContentLoadingProgressBar, 0, 0);
|
||||
this.delay = a.getInt(R.styleable.ContentLoadingProgressBar_show_delay, VISIBILITY_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +69,7 @@ public class ContentLoadingProgressBar extends ProgressBar {
|
||||
init = true;
|
||||
delaying = true;
|
||||
super.setVisibility(INVISIBLE);
|
||||
ApplicationEx.getMainHandler().postDelayed(delayedShow, VISIBILITY_DELAY);
|
||||
ApplicationEx.getMainHandler().postDelayed(delayedShow, delay);
|
||||
} else {
|
||||
ApplicationEx.getMainHandler().removeCallbacks(delayedShow);
|
||||
delaying = false;
|
||||
|
||||
Reference in New Issue
Block a user