use of com.google.android.material.navigation.NavigationBarView in project luckyzyxtools by luckyzyx.
the class MainActivity method initBottomNavigationView.
// 初始化BottomNavigationView底部导航栏
@SuppressLint("NonConstantResourceId")
private void initBottomNavigationView() {
NavigationBarView navigationBarView = findViewById(R.id.nav_item);
// 设置监听方法_NavigationItem被选择事件
navigationBarView.setOnItemSelectedListener(item -> {
switch(item.getItemId()) {
case R.id.nav_item_home:
switchFragment(homeFragment);
break;
case R.id.nav_item_other:
switchFragment(otherFragment);
break;
case R.id.nav_item_user:
switchFragment(userFragment);
break;
}
return true;
});
// 设置默认选中item
switchFragment(homeFragment);
// 设置默认选中item
navigationBarView.setSelectedItemId(R.id.nav_item_home);
// 设置选中显示label
navigationBarView.setLabelVisibilityMode(NavigationBarView.LABEL_VISIBILITY_SELECTED);
}
use of com.google.android.material.navigation.NavigationBarView in project LSPosed by naicfeng.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
if (savedInstanceState == null) {
savedInstanceState = getIntent().getBundleExtra(EXTRA_SAVED_INSTANCE_STATE);
}
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
repoLoader.addListener(this);
moduleUtil.addListener(this);
onModulesReloaded();
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
if (navHostFragment == null) {
return;
}
NavController navController = navHostFragment.getNavController();
var nav = (NavigationBarView) binding.nav;
NavigationUI.setupWithNavController(nav, navController);
handleIntent(getIntent());
}
use of com.google.android.material.navigation.NavigationBarView in project vTunnel by net-byte.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
setContentView(R.layout.activity_main);
NavigationBarView navigationView = findViewById(R.id.navigation_menu);
navigationView.setOnItemSelectedListener(selectedListener);
HomeFragment fragment = new HomeFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content, fragment, "");
fragmentTransaction.commit();
}
use of com.google.android.material.navigation.NavigationBarView in project LSPosed by LSPosed.
the class MainActivity method handleIntent.
private void handleIntent(Intent intent) {
if (intent == null) {
return;
}
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
if (navHostFragment == null) {
return;
}
NavController navController = navHostFragment.getNavController();
var nav = (NavigationBarView) binding.nav;
if (intent.getAction() != null && intent.getAction().equals("android.intent.action.APPLICATION_PREFERENCES")) {
nav.setSelectedItemId(R.id.settings_fragment);
} else if (ConfigManager.isBinderAlive()) {
if (!TextUtils.isEmpty(intent.getDataString())) {
switch(intent.getDataString()) {
case "modules":
nav.setSelectedItemId(R.id.modules_nav);
break;
case "logs":
nav.setSelectedItemId(R.id.logs_fragment);
break;
case "repo":
if (ConfigManager.isMagiskInstalled()) {
nav.setSelectedItemId(R.id.repo_nav);
}
break;
case "settings":
nav.setSelectedItemId(R.id.settings_fragment);
break;
default:
var data = intent.getData();
if (data != null && data.getScheme().equals("module")) {
navController.navigate(new Uri.Builder().scheme("lsposed").authority("module").appendQueryParameter("modulePackageName", data.getHost()).appendQueryParameter("moduleUserId", String.valueOf(data.getPort())).build(), new NavOptions.Builder().setEnterAnim(R.anim.fragment_enter).setExitAnim(R.anim.fragment_exit).setPopEnterAnim(R.anim.fragment_enter_pop).setPopExitAnim(R.anim.fragment_exit_pop).setLaunchSingleTop(true).setPopUpTo(navController.getGraph().getStartDestinationId(), false, true).build());
}
}
}
}
}
use of com.google.android.material.navigation.NavigationBarView in project LSPosed by LSPosed.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
if (savedInstanceState == null) {
savedInstanceState = getIntent().getBundleExtra(EXTRA_SAVED_INSTANCE_STATE);
}
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
repoLoader.addListener(this);
moduleUtil.addListener(this);
onModulesReloaded();
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
if (navHostFragment == null) {
return;
}
NavController navController = navHostFragment.getNavController();
var nav = (NavigationBarView) binding.nav;
NavigationUI.setupWithNavController(nav, navController);
handleIntent(getIntent());
}
Aggregations