use of com.odysee.app.ui.BaseFragment in project odysee-android by OdyseeTeam.
the class MainActivity method openFragment.
public void openFragment(Class fragmentClass, boolean allowNavigateBack, @Nullable Map<String, Object> params) {
try {
Fragment fragment = (Fragment) fragmentClass.newInstance();
if (fragment instanceof BaseFragment) {
((BaseFragment) fragment).setParams(params);
}
Fragment currentFragment = getCurrentFragment();
if (currentFragment != null && currentFragment.equals(fragment)) {
return;
}
if (currentFragment != null && ((BaseFragment) currentFragment).getParams() != null && ((BaseFragment) currentFragment).getParams().containsKey("source") && ((BaseFragment) currentFragment).getParams().get("source").equals("notification")) {
Map<String, Object> currentParams = new HashMap<>(1);
if (((BaseFragment) currentFragment).getParams().containsKey("url"))
currentParams.put("url", ((BaseFragment) currentFragment).getParams().get("url"));
((BaseFragment) currentFragment).setParams(currentParams);
}
// fragment.setRetainInstance(true);
FragmentManager manager = getSupportFragmentManager();
if (fragment instanceof FileViewFragment || fragment instanceof ChannelFragment)
findViewById(R.id.fragment_container_search).setVisibility(View.GONE);
FragmentTransaction transaction;
if (fragment instanceof FileViewFragment) {
transaction = manager.beginTransaction().replace(R.id.main_activity_other_fragment, fragment, FILE_VIEW_TAG);
} else {
transaction = manager.beginTransaction().replace(R.id.main_activity_other_fragment, fragment);
}
if (allowNavigateBack) {
transaction.addToBackStack(null);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(!(fragment instanceof FileViewFragment) && allowNavigateBack);
transaction.commit();
currentDisplayFragment = fragment;
findViewById(R.id.main_activity_other_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.fragment_container_main_activity).setVisibility(View.GONE);
findViewById(R.id.bottom_navigation).setVisibility(View.GONE);
findViewById(R.id.toolbar_balance_and_tools_layout).setVisibility(View.GONE);
} catch (Exception ex) {
// pass
}
}
Aggregations