Search in sources :

Example 66 with FragmentManager

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

the class AddAppNetworksActivity method showAddNetworksFragment.

@VisibleForTesting
void showAddNetworksFragment() {
    // TODO: Check the new intent status.
    mBundle.putString(KEY_CALLING_PACKAGE_NAME, getCallingPackage());
    mBundle.putParcelableArrayList(Settings.EXTRA_WIFI_NETWORK_LIST, getIntent().getParcelableArrayListExtra(Settings.EXTRA_WIFI_NETWORK_LIST));
    final FragmentManager fragmentManager = getSupportFragmentManager();
    Fragment fragment = fragmentManager.findFragmentByTag(TAG);
    if (fragment == null) {
        fragment = new AddAppNetworksFragment();
        fragment.setArguments(mBundle);
        fragmentManager.beginTransaction().add(R.id.main_content, fragment, TAG).commit();
    } else {
        ((AddAppNetworksFragment) fragment).createContent(mBundle);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Fragment(androidx.fragment.app.Fragment) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 67 with FragmentManager

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

the class MobileNetworkActivity method switchFragment.

@VisibleForTesting
void switchFragment(SubscriptionInfo subInfo) {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    final int subId = subInfo.getSubscriptionId();
    final Intent intent = getIntent();
    final Bundle bundle = new Bundle();
    bundle.putInt(Settings.EXTRA_SUB_ID, subId);
    if (intent != null && Settings.ACTION_MMS_MESSAGE_SETTING.equals(intent.getAction())) {
        // highlight "mms_message" preference.
        bundle.putString(EXTRA_FRAGMENT_ARG_KEY, "mms_message");
    }
    final String fragmentTag = buildFragmentTag(subId);
    if (fragmentManager.findFragmentByTag(fragmentTag) != null) {
        Log.d(TAG, "Construct fragment: " + fragmentTag);
    }
    final Fragment fragment = new MobileNetworkSettings();
    fragment.setArguments(bundle);
    fragmentTransaction.replace(R.id.content_frame, fragment, fragmentTag);
    fragmentTransaction.commitAllowingStateLoss();
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Bundle(android.os.Bundle) Intent(android.content.Intent) Fragment(androidx.fragment.app.Fragment) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 68 with FragmentManager

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

the class BluetoothDeviceDetailsFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    FakeFeatureFactory.setupForTest();
    mFragment = spy(BluetoothDeviceDetailsFragment.newInstance(TEST_ADDRESS));
    doReturn(mLocalManager).when(mFragment).getLocalBluetoothManager(any());
    doReturn(mCachedDevice).when(mFragment).getCachedDevice(any());
    doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
    FragmentManager fragmentManager = mock(FragmentManager.class);
    when(mFragment.getFragmentManager()).thenReturn(fragmentManager);
    mFragmentTransaction = mock(FragmentTransaction.class);
    when(fragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
    when(mCachedDevice.getAddress()).thenReturn(TEST_ADDRESS);
    Bundle args = new Bundle();
    args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS, TEST_ADDRESS);
    mFragment.setArguments(args);
    mFragment.onAttach(mContext);
    mMenu = new RoboMenu(mContext);
    mInflater = new MenuInflater(mContext);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) MenuInflater(android.view.MenuInflater) Bundle(android.os.Bundle) RoboMenu(org.robolectric.fakes.RoboMenu) Before(org.junit.Before)

Example 69 with FragmentManager

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

the class ImeiInfoDialogFragment method show.

public static void show(@NonNull Fragment host, int slotId, String dialogTitle) {
    final FragmentManager manager = host.getChildFragmentManager();
    if (manager.findFragmentByTag(TAG) == null) {
        final Bundle bundle = new Bundle();
        bundle.putInt(SLOT_ID_BUNDLE_KEY, slotId);
        bundle.putString(DIALOG_TITLE_BUNDLE_KEY, dialogTitle);
        final ImeiInfoDialogFragment dialog = new ImeiInfoDialogFragment();
        dialog.setArguments(bundle);
        dialog.show(manager, TAG);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Bundle(android.os.Bundle)

Example 70 with FragmentManager

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

the class SavedAccessPointsWifiSettings2Test method onDestroy_shouldTerminateWorkerThread.

@Test
public void onDestroy_shouldTerminateWorkerThread() {
    mSettings = new TestFragment();
    final FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
    final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(mSettings, null);
    fragmentTransaction.commit();
    final Bundle bundle = new Bundle();
    mSettings.onCreate(bundle);
    mSettings.onDestroy();
    assertThat(mSettings.mWorkerThread.getState()).isEqualTo(Thread.State.TERMINATED);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Bundle(android.os.Bundle) Test(org.junit.Test)

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