Improved reset search

pull/199/head
M66B 4 years ago
parent 155a8f32aa
commit ff9f58f467

@ -307,7 +307,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private long primary; private long primary;
private boolean connected; private boolean connected;
private boolean reset = false;
private boolean initialized = false; private boolean initialized = false;
private boolean loading = false; private boolean loading = false;
private boolean swiping = false; private boolean swiping = false;
@ -377,7 +376,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
"time", "unread", "starred", "priority" "time", "unread", "starred", "priority"
)); ));
private static ExecutorService executor = Helper.getBackgroundExecutor(1, "decrypt"); private static final ExecutorService executor =
Helper.getBackgroundExecutor(1, "messages");
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -3781,7 +3781,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
outState.putBoolean("fair:reset", reset);
outState.putBoolean("fair:autoExpanded", autoExpanded); outState.putBoolean("fair:autoExpanded", autoExpanded);
outState.putInt("fair:autoCloseCount", autoCloseCount); outState.putInt("fair:autoCloseCount", autoCloseCount);
@ -3807,7 +3806,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null) {
reset = savedInstanceState.getBoolean("fair:reset");
autoExpanded = savedInstanceState.getBoolean("fair:autoExpanded"); autoExpanded = savedInstanceState.getBoolean("fair:autoExpanded");
autoCloseCount = savedInstanceState.getInt("fair:autoCloseCount"); autoCloseCount = savedInstanceState.getInt("fair:autoCloseCount");
@ -4822,25 +4820,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
} }
}); });
} else if (viewType == AdapterMessage.ViewType.SEARCH && !reset) {
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
DB.getInstance(context).message().resetSearch();
return null;
}
@Override
protected void onExecuted(Bundle args, Void data) {
reset = true;
loadMessagesNext(top);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, new Bundle(), "search:reset");
} else } else
loadMessagesNext(top); loadMessagesNext(top);
} }
@ -8086,21 +8065,42 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return; return;
} }
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) executor.submit(new Runnable() {
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE); @Override
public void run() {
try {
DB db = DB.getInstance(context);
db.message().resetSearch();
Bundle args = new Bundle(); ApplicationEx.getMainHandler().post(new Runnable() {
args.putLong("account", account); @Override
args.putLong("folder", folder); public void run() {
args.putBoolean("server", server); try {
args.putSerializable("criteria", criteria); if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentMessages fragment = new FragmentMessages(); Bundle args = new Bundle();
fragment.setArguments(args); args.putLong("account", account);
args.putLong("folder", folder);
args.putBoolean("server", server);
args.putSerializable("criteria", criteria);
FragmentTransaction fragmentTransaction = manager.beginTransaction(); FragmentMessages fragment = new FragmentMessages();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search"); fragment.setArguments(args);
fragmentTransaction.commit();
FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search");
fragmentTransaction.commit();
} catch (Throwable ex) {
Log.e(ex);
}
}
});
} catch (Throwable ex) {
Log.e(ex);
}
}
});
} }
private static class ActionData { private static class ActionData {

Loading…
Cancel
Save