mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 16:47:30 +00:00
Always slide up bottom nav bar when navigating. Fixes https://github.com/austinhuang0131/barinsta/issues/406
This commit is contained in:
parent
160d556ac5
commit
473e33841c
@ -47,6 +47,7 @@ import androidx.navigation.ui.NavigationUI;
|
|||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior;
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -109,6 +110,7 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
private boolean isActivityCheckerServiceBound = false;
|
private boolean isActivityCheckerServiceBound = false;
|
||||||
private boolean isBackStackEmpty = false;
|
private boolean isBackStackEmpty = false;
|
||||||
private boolean isLoggedIn;
|
private boolean isLoggedIn;
|
||||||
|
private HideBottomViewOnScrollBehavior<BottomNavigationView> behavior;
|
||||||
|
|
||||||
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
@ -143,6 +145,13 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
final Toolbar toolbar = binding.toolbar;
|
final Toolbar toolbar = binding.toolbar;
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
createNotificationChannels();
|
createNotificationChannels();
|
||||||
|
try {
|
||||||
|
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) binding.bottomNavView.getLayoutParams();
|
||||||
|
//noinspection unchecked
|
||||||
|
behavior = (HideBottomViewOnScrollBehavior<BottomNavigationView>) layoutParams.getBehavior();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "onCreate: ", e);
|
||||||
|
}
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
setupBottomNavigationBar(true);
|
setupBottomNavigationBar(true);
|
||||||
}
|
}
|
||||||
@ -499,7 +508,11 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
final int destinationId = destination.getId();
|
final int destinationId = destination.getId();
|
||||||
@SuppressLint("RestrictedApi") final Deque<NavBackStackEntry> backStack = navController.getBackStack();
|
@SuppressLint("RestrictedApi") final Deque<NavBackStackEntry> backStack = navController.getBackStack();
|
||||||
setupMenu(backStack.size(), destinationId);
|
setupMenu(backStack.size(), destinationId);
|
||||||
binding.bottomNavView.setVisibility(SHOW_BOTTOM_VIEW_DESTINATIONS.contains(destinationId) ? View.VISIBLE : View.GONE);
|
final boolean contains = SHOW_BOTTOM_VIEW_DESTINATIONS.contains(destinationId);
|
||||||
|
binding.bottomNavView.setVisibility(contains ? View.VISIBLE : View.GONE);
|
||||||
|
if (contains && behavior != null) {
|
||||||
|
behavior.slideUp(binding.bottomNavView);
|
||||||
|
}
|
||||||
|
|
||||||
// explicitly hide keyboard when we navigate
|
// explicitly hide keyboard when we navigate
|
||||||
final View view = getCurrentFocus();
|
final View view = getCurrentFocus();
|
||||||
|
Loading…
Reference in New Issue
Block a user