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);
}
}
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();
}
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);
}
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);
}
}
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);
}
Aggregations