Search in sources :

Example 31 with FragmentTransaction

use of androidx.fragment.app.FragmentTransaction in project LshUtils by SenhLinsh.

the class FragmentUtilsEx method replaceFragment.

/**
 * 创建切换 replace
 *
 * @param fragment        Fragment
 * @param containerViewId 容器 id
 * @param activity        Activity
 */
public static void replaceFragment(Fragment fragment, int containerViewId, AppCompatActivity activity) {
    if (fragment != null) {
        FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
        transaction.replace(containerViewId, fragment);
        transaction.commit();
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Example 32 with FragmentTransaction

use of androidx.fragment.app.FragmentTransaction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BackgroundCheckSummary method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // initialize the inflater
    mInflater = inflater;
    View rootView = mInflater.inflate(R.layout.background_check_summary, container, false);
    // only when the view is added.
    if (container instanceof PreferenceFrameLayout) {
        ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
    }
    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    ft.add(R.id.appops_content, new AppOpsCategory(AppOpsState.RUN_IN_BACKGROUND_TEMPLATE), "appops");
    ft.commitAllowingStateLoss();
    return rootView;
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) PreferenceFrameLayout(android.preference.PreferenceFrameLayout) View(android.view.View)

Example 33 with FragmentTransaction

use of androidx.fragment.app.FragmentTransaction in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsHomepageActivity method showFragment.

private void showFragment(Fragment fragment, int id) {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    final Fragment showFragment = fragmentManager.findFragmentById(id);
    if (showFragment == null) {
        fragmentTransaction.add(id, fragment);
    } else {
        fragmentTransaction.show(showFragment);
    }
    fragmentTransaction.commit();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Fragment(androidx.fragment.app.Fragment) ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment)

Example 34 with FragmentTransaction

use of androidx.fragment.app.FragmentTransaction in project SeriesGuide by UweTrottmann.

the class StatsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stats);
    setupActionBar();
    setupBottomNavigation(R.id.navigation_item_stats);
    if (savedInstanceState == null) {
        StatsFragment f = new StatsFragment();
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(R.id.content_frame, f);
        ft.commit();
    }
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Example 35 with FragmentTransaction

use of androidx.fragment.app.FragmentTransaction in project AndroidUtilCode by Blankj.

the class FragmentUtils method add.

/**
 * Add fragment.
 *
 * @param fm             The manager of fragment.
 * @param add            The fragment will be add.
 * @param containerId    The id of container.
 * @param isAddStack     True to add fragment in stack, false otherwise.
 * @param sharedElements A View in a disappearing Fragment to match with a View in an
 *                       appearing Fragment.
 */
public static void add(@NonNull final FragmentManager fm, @NonNull final Fragment add, @IdRes final int containerId, final String tag, final boolean isAddStack, @NonNull final View... sharedElements) {
    FragmentTransaction ft = fm.beginTransaction();
    putArgs(add, new Args(containerId, tag, false, isAddStack));
    addSharedElement(ft, sharedElements);
    operate(TYPE_ADD_FRAGMENT, fm, ft, null, add);
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction)

Aggregations

FragmentTransaction (androidx.fragment.app.FragmentTransaction)176 Fragment (androidx.fragment.app.Fragment)57 FragmentManager (androidx.fragment.app.FragmentManager)53 Bundle (android.os.Bundle)25 Test (org.junit.Test)14 DialogFragment (androidx.fragment.app.DialogFragment)10 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)6 View (android.view.View)5 Intent (android.content.Intent)4 ActionBar (androidx.appcompat.app.ActionBar)4 Toolbar (androidx.appcompat.widget.Toolbar)4 SwipeRefreshListFragment (eu.siacs.conversations.ui.widget.SwipeRefreshListFragment)4 MediaGalleryFragment (org.thoughtcrime.securesms.mediasend.v2.gallery.MediaGalleryFragment)4 SuppressLint (android.annotation.SuppressLint)3 Activity (android.app.Activity)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 SslUntrustedCertDialog (com.owncloud.android.ui.dialog.SslUntrustedCertDialog)3 TargetApi (android.annotation.TargetApi)2 PreferenceFrameLayout (android.preference.PreferenceFrameLayout)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2