Improved reset search

pull/199/head
M66B 3 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,6 +8065,17 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return; return;
} }
executor.submit(new Runnable() {
@Override
public void run() {
try {
DB db = DB.getInstance(context);
db.message().resetSearch();
ApplicationEx.getMainHandler().post(new Runnable() {
@Override
public void run() {
try {
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE);
@ -8101,6 +8091,16 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
FragmentTransaction fragmentTransaction = manager.beginTransaction(); FragmentTransaction fragmentTransaction = manager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search"); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search");
fragmentTransaction.commit(); 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