mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 17:57:16 +00:00
Visibility delaying
This commit is contained in:
parent
0221816e21
commit
33c00d0c9b
2 changed files with 14 additions and 8 deletions
|
@ -27,7 +27,8 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ContentLoadingProgressBar extends ProgressBar {
|
||||
private int visibility;
|
||||
private int visibility = VISIBLE;
|
||||
private boolean delaying = false;
|
||||
|
||||
private static final int VISIBILITY_DELAY = 500; // milliseconds
|
||||
|
||||
|
@ -51,12 +52,16 @@ public class ContentLoadingProgressBar extends ProgressBar {
|
|||
public void setVisibility(int visibility) {
|
||||
this.visibility = visibility;
|
||||
|
||||
ApplicationEx.getMainHandler().removeCallbacks(delayedShow);
|
||||
if (visibility == VISIBLE) {
|
||||
if (delaying)
|
||||
return;
|
||||
delaying = true;
|
||||
super.setVisibility(INVISIBLE);
|
||||
ApplicationEx.getMainHandler().postDelayed(delayedShow, VISIBILITY_DELAY);
|
||||
} else
|
||||
} else {
|
||||
ApplicationEx.getMainHandler().removeCallbacks(delayedShow);
|
||||
super.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,6 +72,7 @@ public class ContentLoadingProgressBar extends ProgressBar {
|
|||
private final Runnable delayedShow = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
delaying = false;
|
||||
if (visibility == VISIBLE)
|
||||
ContentLoadingProgressBar.super.setVisibility(VISIBLE);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
public class ViewTextDelayed extends AppCompatTextView {
|
||||
private int visibility;
|
||||
private int visibility = VISIBLE;
|
||||
|
||||
private static final int VISIBILITY_DELAY = 500; // milliseconds
|
||||
|
||||
|
@ -47,13 +47,13 @@ public class ViewTextDelayed extends AppCompatTextView {
|
|||
public void setVisibility(int visibility) {
|
||||
this.visibility = visibility;
|
||||
|
||||
removeCallbacks(delayedShow);
|
||||
removeCallbacks(delayedHide);
|
||||
ApplicationEx.getMainHandler().removeCallbacks(delayedShow);
|
||||
ApplicationEx.getMainHandler().removeCallbacks(delayedHide);
|
||||
|
||||
if (visibility == VISIBLE)
|
||||
postDelayed(delayedShow, VISIBILITY_DELAY);
|
||||
ApplicationEx.getMainHandler().postDelayed(delayedShow, VISIBILITY_DELAY);
|
||||
else if (visibility == GONE)
|
||||
postDelayed(delayedHide, VISIBILITY_DELAY);
|
||||
ApplicationEx.getMainHandler().postDelayed(delayedHide, VISIBILITY_DELAY);
|
||||
else
|
||||
super.setVisibility(visibility);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue