diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java index c1d95b4f6..30b38ffbf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -202,15 +202,23 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene private void onTabSelected(@IdRes int tab){ Fragment newFragment=fragmentForTab(tab); if(tab==currentTab){ + if(tab == R.id.tab_search){ + if(newFragment instanceof ScrollableToTop scrollable) + scrollable.scrollToTop(); + searchFragment.selectSearch(); + return; + } + if(newFragment instanceof ScrollableToTop scrollable) + scrollable.scrollToTop(); + return; + } + if(tab==currentTab && tab == R.id.tab_search){ if(newFragment instanceof ScrollableToTop scrollable) scrollable.scrollToTop(); return; } getChildFragmentManager().beginTransaction().hide(fragmentForTab(currentTab)).show(newFragment).commit(); maybeTriggerLoading(newFragment); -// if(tab == currentTab && tab == R.id.tab_search){ -// searchFragment.selectSearch(); -// } currentTab=tab; ((FragmentStackActivity)getActivity()).invalidateSystemBarColors(this); } @@ -239,10 +247,11 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene return true; } if(tab==R.id.tab_search){ - searchFragment.selectSearch(); onTabSelected(R.id.tab_search); + tabBar.selectTab(R.id.tab_search); + searchFragment.selectSearch(); + return true; } - return false; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java index c13c98c6c..dd40d2367 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverFragment.java @@ -2,8 +2,6 @@ package org.joinmastodon.android.fragments.discover; import android.app.Fragment; import android.app.FragmentTransaction; -import android.content.Context; -import android.hardware.input.InputManager; import android.os.Build; import android.os.Bundle; import android.text.Editable; @@ -19,7 +17,6 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; -import android.widget.Toast; import org.joinmastodon.android.BuildConfig; import org.joinmastodon.android.GlobalUserPreferences;