use of androidx.fragment.app.FragmentTransaction in project BaseProject by fly803.
the class ActivityUtils method addFragmentToActivity.
/**
* 将一个Fragment添加到Activity中
* @param fragmentManager fragment管理器
* @param fragment 需要添加的fragment
* @param frameId 布局FrameLayout的Id
*/
public static void addFragmentToActivity(FragmentManager fragmentManager, Fragment fragment, int frameId) {
if (null != fragmentManager && null != fragment) {
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(frameId, fragment);
transaction.commit();
}
}
use of androidx.fragment.app.FragmentTransaction in project BaseProject by fly803.
the class ActivityUtils method replaceFragmentFromActivity.
/**
* 替换Activity中的Fragment
* @param fragmentManager fragment管理器
* @param fragment 需要替换到Activity的Fragment
* @param frameId 布局FrameLayout的Id
*/
public static void replaceFragmentFromActivity(FragmentManager fragmentManager, Fragment fragment, int frameId) {
if (null != fragmentManager && null != fragment) {
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(frameId, fragment);
transaction.commit();
}
}
use of androidx.fragment.app.FragmentTransaction in project BaseProject by fly803.
the class FragmentUtils method add.
/**
* Add fragment.
*
* @param fm The manager of fragment.
* @param containerId The id of container.
* @param add The fragment will be add.
* @param isAddStack True to add fragment in stack, false otherwise.
* @param enterAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being added or attached.
* @param exitAnim An animation or animator resource ID used for the exit animation on the
* view of the fragment being removed or detached.
* @param popEnterAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being readded or reattached caused by
* popBackStack() or similar methods.
* @param popExitAnim An animation or animator resource ID used for the enter animation on the
* view of the fragment being removed or detached caused by
* popBackStack() or similar methods.
*/
public static void add(@NonNull final FragmentManager fm, @NonNull final Fragment add, @IdRes final int containerId, final boolean isAddStack, @AnimRes final int enterAnim, @AnimRes final int exitAnim, @AnimRes final int popEnterAnim, @AnimRes final int popExitAnim) {
FragmentTransaction ft = fm.beginTransaction();
putArgs(add, new Args(containerId, false, isAddStack));
addAnim(ft, enterAnim, exitAnim, popEnterAnim, popExitAnim);
operate(TYPE_ADD_FRAGMENT, fm, ft, null, add);
}
use of androidx.fragment.app.FragmentTransaction in project Signal-Android by signalapp.
the class MmsPreferencesActivity method onCreate.
@Override
protected void onCreate(Bundle icicle, boolean ready) {
assert getSupportActionBar() != null;
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Fragment fragment = new MmsPreferencesFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(android.R.id.content, fragment);
fragmentTransaction.commit();
}
use of androidx.fragment.app.FragmentTransaction in project Signal-Android by signalapp.
the class AvatarSelectionActivity method onNavigateToCamera.
@Override
public void onNavigateToCamera() {
if (isCameraFirst() && popToRoot()) {
return;
}
Fragment fragment = CameraFragment.newInstanceForAvatarCapture();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, IMAGE_CAPTURE);
if (isGalleryFirst()) {
transaction.addToBackStack(null);
}
transaction.commit();
}
Aggregations