Show number of messages found, when possible

pull/172/head
M66B 5 years ago
parent 8441b5567e
commit ab8898b422

@ -88,6 +88,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
void onLoaded(int fetched); void onLoaded(int fetched);
void onFound(String query, int count);
void onException(@NonNull Throwable ex); void onException(@NonNull Throwable ex);
} }
@ -188,10 +190,19 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean fts = prefs.getBoolean("fts", false); boolean fts = prefs.getBoolean("fts", false);
boolean pro = ActivityBilling.isPro(context); boolean pro = ActivityBilling.isPro(context);
if (fts && pro && seen == null && flagged == null && snoozed == null && encrypted == null) { if (fts && pro &&
query != null &&
seen == null && flagged == null && snoozed == null && encrypted == null) {
if (state.ids == null) { if (state.ids == null) {
SQLiteDatabase sdb = FtsDbHelper.getInstance(context); SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
state.ids = FtsDbHelper.match(sdb, folder, query); state.ids = FtsDbHelper.match(sdb, folder, query);
handler.post(new Runnable() {
@Override
public void run() {
intf.onFound(query, state.ids.size());
}
});
} }
try { try {
@ -450,7 +461,15 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
state.imessages = (Message[]) result; state.imessages = (Message[]) result;
} }
Log.i("Boundary server found messages=" + state.imessages.length); Log.i("Boundary server found messages=" + state.imessages.length);
if (query != null)
handler.post(new Runnable() {
@Override
public void run() {
intf.onFound(query, count);
}
});
state.index = state.imessages.length - 1; state.index = state.imessages.length - 1;
} catch (Throwable ex) { } catch (Throwable ex) {

@ -3375,6 +3375,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
pbWait.setVisibility(View.GONE); pbWait.setVisibility(View.GONE);
} }
@Override
public void onFound(String query, int count) {
setSubtitle(getString(R.string.title_name_count, query, count));
}
@Override @Override
public void onException(@NonNull Throwable ex) { public void onException(@NonNull Throwable ex) {
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))

Loading…
Cancel
Save