Search in sources :

Example 76 with FragmentManager

use of androidx.fragment.app.FragmentManager in project android_packages_apps_Settings by omnirom.

the class BluetoothA2dpHwOffloadRebootDialog method show.

public static void show(DevelopmentSettingsDashboardFragment host, BluetoothA2dpHwOffloadPreferenceController controller) {
    final FragmentManager manager = host.getActivity().getSupportFragmentManager();
    if (manager.findFragmentByTag(TAG) == null) {
        final BluetoothA2dpHwOffloadRebootDialog dialog = new BluetoothA2dpHwOffloadRebootDialog();
        dialog.setTargetFragment(host, 0);
        dialog.show(manager, TAG);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager)

Example 77 with FragmentManager

use of androidx.fragment.app.FragmentManager in project android_packages_apps_Settings by omnirom.

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) ContextualCardsFragment(com.android.settings.homepage.contextualcards.ContextualCardsFragment) Fragment(androidx.fragment.app.Fragment)

Example 78 with FragmentManager

use of androidx.fragment.app.FragmentManager in project android_packages_apps_Settings by omnirom.

the class MDNHandlerFragment method switchToMainFragment.

private void switchToMainFragment(boolean turnoffSwitch) {
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, new SmartForwardingFragment(turnoffSwitch)).commit();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager)

Example 79 with FragmentManager

use of androidx.fragment.app.FragmentManager in project apps-android-commons by commons-app.

the class SearchActivity method onMediaClicked.

/**
 * Open media detail pager fragment on click of image in search results
 * @param index item index that should be opened
 */
@Override
public void onMediaClicked(int index) {
    ViewUtil.hideKeyboard(this.findViewById(R.id.searchBox));
    tabLayout.setVisibility(View.GONE);
    viewPager.setVisibility(View.GONE);
    mediaContainer.setVisibility(View.VISIBLE);
    // to remove searchview when mediaDetails fragment open
    searchView.setVisibility(View.GONE);
    if (mediaDetails == null || !mediaDetails.isVisible()) {
        // set isFeaturedImage true for featured images, to include author field on media detail
        mediaDetails = new MediaDetailPagerFragment(false, true);
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        supportFragmentManager.beginTransaction().hide(supportFragmentManager.getFragments().get(supportFragmentManager.getBackStackEntryCount())).add(R.id.mediaContainer, mediaDetails).addToBackStack(null).commit();
        // Reason for using hide, add instead of replace is to maintain scroll position after
        // coming back to the search activity. See https://github.com/commons-app/apps-android-commons/issues/1631
        // https://stackoverflow.com/questions/11353075/how-can-i-maintain-fragment-state-when-added-to-the-back-stack/19022550#19022550
        supportFragmentManager.executePendingTransactions();
    }
    mediaDetails.showImage(index);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Example 80 with FragmentManager

use of androidx.fragment.app.FragmentManager in project apps-android-commons by commons-app.

the class WikidataItemDetailsActivity method onMediaClicked.

/**
 * Shows media detail fragment when user clicks on any image in the list
 */
@Override
public void onMediaClicked(int position) {
    tabLayout.setVisibility(View.GONE);
    viewPager.setVisibility(View.GONE);
    mediaContainer.setVisibility(View.VISIBLE);
    if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
        // set isFeaturedImage true for featured images, to include author field on media detail
        mediaDetailPagerFragment = new MediaDetailPagerFragment(false, true);
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        supportFragmentManager.beginTransaction().replace(R.id.mediaContainer, mediaDetailPagerFragment).addToBackStack(null).commit();
        supportFragmentManager.executePendingTransactions();
    }
    mediaDetailPagerFragment.showImage(position);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MediaDetailPagerFragment(fr.free.nrw.commons.media.MediaDetailPagerFragment)

Aggregations

FragmentManager (androidx.fragment.app.FragmentManager)163 FragmentTransaction (androidx.fragment.app.FragmentTransaction)55 Fragment (androidx.fragment.app.Fragment)42 Bundle (android.os.Bundle)28 Test (org.junit.Test)15 Intent (android.content.Intent)13 FragmentActivity (androidx.fragment.app.FragmentActivity)10 Activity (android.app.Activity)6 View (android.view.View)6 DialogFragment (androidx.fragment.app.DialogFragment)6 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)5 Context (android.content.Context)4 DialogInterface (android.content.DialogInterface)3 LayoutInflater (android.view.LayoutInflater)3 MenuInflater (android.view.MenuInflater)3 Window (android.view.Window)3 TextView (android.widget.TextView)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)3 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3