Report number of found message for list state

This commit is contained in:
M66B 2020-11-27 08:27:57 +01:00
parent d791788985
commit 5a15249ed4
2 changed files with 11 additions and 8 deletions

View File

@ -96,7 +96,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
interface IBoundaryCallbackMessages { interface IBoundaryCallbackMessages {
void onLoading(); void onLoading();
void onLoaded(); void onLoaded(int found);
void onException(@NonNull Throwable ex); void onException(@NonNull Throwable ex);
} }
@ -141,6 +141,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
executor.submit(new Runnable() { executor.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
int found = 0;
try { try {
if (state.destroyed || state.error) if (state.destroyed || state.error)
return; return;
@ -154,7 +155,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
}); });
if (server) if (server)
try { try {
load_server(state); found = load_server(state);
} catch (Throwable ex) { } catch (Throwable ex) {
if (state.error || ex instanceof IllegalArgumentException) if (state.error || ex instanceof IllegalArgumentException)
throw ex; throw ex;
@ -163,10 +164,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
close(state, true); close(state, true);
// Retry // Retry
load_server(state); found = load_server(state);
} }
else else
load_device(state); found = load_device(state);
} catch (final Throwable ex) { } catch (final Throwable ex) {
state.error = true; state.error = true;
Log.e("Boundary", ex); Log.e("Boundary", ex);
@ -178,13 +179,15 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} }
}); });
} finally { } finally {
if (intf != null) if (intf != null) {
final int f = found;
ApplicationEx.getMainHandler().post(new Runnable() { ApplicationEx.getMainHandler().post(new Runnable() {
@Override @Override
public void run() { public void run() {
intf.onLoaded(); intf.onLoaded(f);
} }
}); });
}
} }
} }
}); });

View File

@ -4537,9 +4537,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
@Override @Override
public void onLoaded() { public void onLoaded(int found) {
loading = false; loading = false;
updateListState("Loaded", SimpleTask.getCount(), adapter.getItemCount()); updateListState("Loaded found=" + found, SimpleTask.getCount(), adapter.getItemCount() + found);
} }
@Override @Override