use of im.tny.segvault.disturbances.ui.fragment.TopFragment in project underlx by underlx.
the class MainActivity method replaceFragment.
private void replaceFragment(Fragment newFragment, boolean addToBackStack) {
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.main_fragment_container);
if (currentFragment == null || !currentFragment.isAdded()) {
currentFragment = getSupportFragmentManager().findFragmentById(R.id.alt_fragment_container);
}
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (currentFragment != null) {
transaction.remove(currentFragment);
}
int destContainer = R.id.main_fragment_container;
if (newFragment instanceof TopFragment) {
TopFragment newFrag = (TopFragment) newFragment;
if (!newFrag.isScrollable()) {
destContainer = R.id.alt_fragment_container;
}
}
transaction.replace(destContainer, newFragment);
if (addToBackStack) {
transaction.addToBackStack(null);
}
transaction.commit();
}
Aggregations