From 17f727fd9f058fbf4be20836f80f27d256451d04 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 18 Jul 2022 15:28:23 +0200 Subject: [PATCH] Fix #258 - Wrong selection after a second search. --- .../fedilab/android/activities/SearchResultTabActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/SearchResultTabActivity.java b/app/src/main/java/app/fedilab/android/activities/SearchResultTabActivity.java index 7fee806a8..1cb92672d 100644 --- a/app/src/main/java/app/fedilab/android/activities/SearchResultTabActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/SearchResultTabActivity.java @@ -53,6 +53,7 @@ public class SearchResultTabActivity extends BaseActivity { private String search; private ActivitySearchResultTabsBinding binding; + private TabLayout.Tab initial; @Override protected void onCreate(Bundle savedInstanceState) { @@ -77,7 +78,8 @@ public class SearchResultTabActivity extends BaseActivity { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(this, R.color.cyanea_primary))); } setTitle(search); - binding.searchTabLayout.addTab(binding.searchTabLayout.newTab().setText(getString(R.string.tags))); + initial = binding.searchTabLayout.newTab(); + binding.searchTabLayout.addTab(initial.setText(getString(R.string.tags))); binding.searchTabLayout.addTab(binding.searchTabLayout.newTab().setText(getString(R.string.accounts))); binding.searchTabLayout.addTab(binding.searchTabLayout.newTab().setText(getString(R.string.toots))); binding.searchTabLayout.addTab(binding.searchTabLayout.newTab().setText(getString(R.string.action_cache))); @@ -125,7 +127,6 @@ public class SearchResultTabActivity extends BaseActivity { @Override public boolean onQueryTextSubmit(String query) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); - assert imm != null; imm.hideSoftInputFromWindow(binding.searchTabLayout.getWindowToken(), 0); query = query.replaceAll("^#+", ""); search = query.trim(); @@ -134,6 +135,7 @@ public class SearchResultTabActivity extends BaseActivity { searchView.clearFocus(); setTitle(search); searchView.setIconified(true); + binding.searchTabLayout.selectTab(initial); return false; }