From a275e930da955a703984696469f994788277fe72 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 2 Jul 2021 08:27:41 +0200 Subject: [PATCH] End search on detach body --- .../java/eu/faircode/email/FragmentMessages.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index f1b2ff9a1f..4a6ca2c83e 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -5850,6 +5850,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. private void startSearch(TextView view) { searchView = view; + searchView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { + @Override + public void onViewAttachedToWindow(View v) { + // Do nothing + } + + @Override + public void onViewDetachedFromWindow(View v) { + v.removeOnAttachStateChangeListener(this); + endSearch(); + } + }); + etSearch.setText(null); etSearch.setVisibility(View.VISIBLE); etSearch.requestFocus();