Correctly display "no messages"

This commit is contained in:
M66B 2019-01-29 08:35:42 +00:00
parent a7c3dac2fd
commit ec96c352ee
3 changed files with 23 additions and 11 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);
}
};