1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-22 21:16:57 +00:00

Hide search if default tab is not profile

This commit is contained in:
Ammar Githam 2020-09-09 00:55:28 +09:00
parent 31f6f735f2
commit 149410d552

View File

@ -24,6 +24,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.lifecycle.LiveData;
import androidx.navigation.NavBackStackEntry;
import androidx.navigation.NavController;
import androidx.navigation.NavDestination;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.appbar.AppBarLayout;
@ -126,6 +127,14 @@ public class MainActivity extends BaseLanguageActivity {
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
searchMenuItem = menu.findItem(R.id.search);
if (showSearch && currentNavControllerLiveData != null && currentNavControllerLiveData.getValue() != null) {
final NavController navController = currentNavControllerLiveData.getValue();
final NavDestination currentDestination = navController.getCurrentDestination();
if (currentDestination != null) {
final int destinationId = currentDestination.getId();
showSearch = destinationId == R.id.profileFragment;
}
}
if (!showSearch) {
searchMenuItem.setVisible(false);
return true;
@ -291,15 +300,6 @@ public class MainActivity extends BaseLanguageActivity {
@Override
public boolean onQueryTextSubmit(final String query) {
return onQueryTextChange(query);
// menu.findItem(R.id.action_about).setVisible(true);
// menu.findItem(R.id.action_settings).setVisible(true);
// closeAnyOpenDrawer();
// addToStack();
// userQuery = (query.contains("@") || query.contains("#")) ? query : ("@" + query);
// searchAction.collapseActionView();
// searchView.setIconified(true);
// searchView.setIconified(true);
// mainHelper.onRefresh();
}
@Override