use of android.support.v4.app.FragmentTransaction in project native-navigation by airbnb.
the class ScreenCoordinator method pushScreen.
public void pushScreen(Fragment fragment, @Nullable Bundle options) {
FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction().setAllowOptimization(true);
Fragment currentFragment = getCurrentFragment();
if (currentFragment == null) {
throw new IllegalStateException("There is no current fragment. You must present one first.");
}
if (ViewUtils.isAtLeastLollipop() && options != null && options.containsKey(TRANSITION_GROUP)) {
setupFragmentForSharedElement(currentFragment, fragment, ft, options);
} else {
PresentAnimation anim = PresentAnimation.Push;
ft.setCustomAnimations(anim.enter, anim.exit, anim.popEnter, anim.popExit);
}
BackStack bsi = getCurrentBackStack();
ft.detach(currentFragment).add(container.getId(), fragment).addToBackStack(null).commit();
bsi.pushFragment(fragment);
Log.d(TAG, toString());
}
use of android.support.v4.app.FragmentTransaction in project Fragmentation by YoKeyword.
the class FragmentationDelegate method replaceTransaction.
/**
* replace事务, 主要用于子Fragment之间的replace
*/
void replaceTransaction(FragmentManager fragmentManager, int containerId, SupportFragment to, boolean addToBack) {
fragmentManager = checkFragmentManager(fragmentManager, null);
if (fragmentManager == null)
return;
checkNotNull(to, "toFragment == null");
bindContainerId(containerId, to);
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.replace(containerId, to, to.getClass().getName());
if (addToBack) {
ft.addToBackStack(to.getClass().getName());
}
Bundle bundle = to.getArguments();
bundle.putBoolean(FRAGMENTATION_ARG_IS_ROOT, true);
supportCommit(fragmentManager, ft);
}
use of android.support.v4.app.FragmentTransaction in project Fragmentation by YoKeyword.
the class FragmentationDelegate method loadMultipleRootTransaction.
/**
* 加载多个根Fragment
*/
void loadMultipleRootTransaction(FragmentManager fragmentManager, int containerId, int showPosition, SupportFragment... tos) {
fragmentManager = checkFragmentManager(fragmentManager, null);
if (fragmentManager == null)
return;
FragmentTransaction ft = fragmentManager.beginTransaction();
for (int i = 0; i < tos.length; i++) {
SupportFragment to = tos[i];
bindContainerId(containerId, tos[i]);
String toName = to.getClass().getName();
ft.add(containerId, to, toName);
if (i != showPosition) {
ft.hide(to);
}
}
supportCommit(fragmentManager, ft);
}
use of android.support.v4.app.FragmentTransaction in project Fragmentation by YoKeyword.
the class SupportFragment method processRestoreInstanceState.
private void processRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState != null) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
if (isSupportHidden()) {
ft.hide(this);
} else {
ft.show(this);
}
ft.commit();
}
}
use of android.support.v4.app.FragmentTransaction in project Fragmentation by YoKeyword.
the class FragmentationDelegate method showHideFragment.
/**
* show一个Fragment,hide另一个/多个Fragment ; 主要用于类似微信主页那种 切换tab的情况
*
* @param showFragment 需要show的Fragment
* @param hideFragment 需要hide的Fragment
*/
void showHideFragment(FragmentManager fragmentManager, SupportFragment showFragment, SupportFragment hideFragment) {
fragmentManager = checkFragmentManager(fragmentManager, null);
if (fragmentManager == null)
return;
if (showFragment == hideFragment)
return;
FragmentTransaction ft = fragmentManager.beginTransaction().show(showFragment);
if (hideFragment == null) {
List<Fragment> fragmentList = fragmentManager.getFragments();
if (fragmentList != null) {
for (Fragment fragment : fragmentList) {
if (fragment != null && fragment != showFragment) {
ft.hide(fragment);
}
}
}
} else {
ft.hide(hideFragment);
}
supportCommit(fragmentManager, ft);
}
Aggregations