mirror of https://github.com/M66B/FairEmail.git
Correctly display "no messages"
This commit is contained in:
parent
a7c3dac2fd
commit
ec96c352ee
|
@ -32,6 +32,7 @@ import androidx.paging.PagedList;
|
|||
public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMessageEx> {
|
||||
private ViewModelBrowse model;
|
||||
private Handler handler;
|
||||
private boolean loading = false;
|
||||
private IBoundaryCallbackMessages intf;
|
||||
|
||||
private ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory);
|
||||
|
@ -86,6 +87,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
return;
|
||||
|
||||
try {
|
||||
loading = true;
|
||||
fetched = 0;
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
|
@ -103,6 +105,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
}
|
||||
});
|
||||
} finally {
|
||||
loading = false;
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -113,4 +116,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean isLoading() {
|
||||
return loading;
|
||||
}
|
||||
}
|
|
@ -37,6 +37,10 @@ public class ContentLoadingProgressBar extends ProgressBar {
|
|||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
if (false && BuildConfig.DEBUG) {
|
||||
super.setVisibility(visibility);
|
||||
return;
|
||||
}
|
||||
removeCallbacks(delayedShow);
|
||||
if (visibility == VISIBLE) {
|
||||
super.setVisibility(INVISIBLE);
|
||||
|
|
|
@ -1748,18 +1748,18 @@ public class FragmentMessages extends FragmentBase {
|
|||
new BoundaryCallbackMessages.IBoundaryCallbackMessages() {
|
||||
@Override
|
||||
public void onLoading() {
|
||||
pbWait.setTag(true);
|
||||
tvNoEmail.setVisibility(View.GONE);
|
||||
pbWait.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaded(int fetched) {
|
||||
RecyclerView.Adapter adapter = rvMessage.getAdapter();
|
||||
int items = (adapter == null ? 0 : adapter.getItemCount());
|
||||
tvNoEmail.setVisibility(items + fetched == 0 ? View.VISIBLE : View.GONE);
|
||||
pbWait.setVisibility(View.GONE);
|
||||
pbWait.setTag(null);
|
||||
|
||||
Integer submitted = (Integer) rvMessage.getTag();
|
||||
if (submitted == null)
|
||||
submitted = 0;
|
||||
if (submitted + fetched == 0)
|
||||
tvNoEmail.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2018,13 +2018,14 @@ public class FragmentMessages extends FragmentBase {
|
|||
|
||||
Log.i("Submit messages=" + messages.size());
|
||||
adapter.submitList(messages);
|
||||
rvMessage.setTag(messages.size());
|
||||
|
||||
if (pbWait.getTag() == null) {
|
||||
if (boundaryCallback == null || !boundaryCallback.isLoading())
|
||||
pbWait.setVisibility(View.GONE);
|
||||
if (!(viewType == AdapterMessage.ViewType.FOLDER || viewType == AdapterMessage.ViewType.SEARCH))
|
||||
tvNoEmail.setVisibility(messages.size() == 0 ? View.VISIBLE : View.GONE);
|
||||
grpReady.setVisibility(messages.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (boundaryCallback == null && messages.size() == 0)
|
||||
tvNoEmail.setVisibility(View.VISIBLE);
|
||||
if (messages.size() > 0)
|
||||
grpReady.setVisibility(View.VISIBLE);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue