From 0f4221ba65233a89045ac3d6d37d39d1cfd84b2d Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 15 May 2019 13:47:01 +0200 Subject: [PATCH] Reset search once only --- .../main/java/eu/faircode/email/FragmentMessages.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 3693af8d5f..38ec9c6945 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -161,7 +161,9 @@ public class FragmentMessages extends FragmentBase { private long primary; private boolean outbox = false; private boolean connected; + private boolean reset = false; private String searching = null; + private boolean loading = false; private boolean manual = false; private Integer lastUnseen = null; @@ -1867,6 +1869,7 @@ public class FragmentMessages extends FragmentBase { @Override public void onSaveInstanceState(Bundle outState) { + outState.putBoolean("fair:reset", reset); outState.putString("fair:searching", searching); outState.putBoolean("fair:autoExpanded", autoExpanded); @@ -1902,6 +1905,7 @@ public class FragmentMessages extends FragmentBase { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { + reset = savedInstanceState.getBoolean("fair:reset"); searching = savedInstanceState.getString("fair:searching"); autoExpanded = savedInstanceState.getBoolean("fair:autoExpanded"); @@ -2587,7 +2591,7 @@ public class FragmentMessages extends FragmentBase { // Do nothing } }); - } else if (viewType == AdapterMessage.ViewType.SEARCH) { + } else if (viewType == AdapterMessage.ViewType.SEARCH && !reset) { new SimpleTask() { @Override protected Void onExecute(Context context, Bundle args) { @@ -2597,6 +2601,7 @@ public class FragmentMessages extends FragmentBase { @Override protected void onExecuted(Bundle args, Void data) { + reset = true; loadMessagesNext(top); } @@ -2609,8 +2614,6 @@ public class FragmentMessages extends FragmentBase { loadMessagesNext(top); } - private boolean loading = false; - private void loadMessagesNext(final boolean top) { if (top) adapter.gotoTop();