use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class KeyboardLayoutPickerControllerTest method testOnDeviceRemove_getDifferentDevice_shouldNotFinish.
@Test
@Config(shadows = ShadowInputDevice.class)
public void testOnDeviceRemove_getDifferentDevice_shouldNotFinish() {
final int TARGET_DEVICE_ID = 1;
final int ANOTHER_DEVICE_ID = 2;
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
final String[] enableKeyboardLayouts = { "layout1" };
final InputDevice device = ShadowInputDevice.makeInputDevicebyId(TARGET_DEVICE_ID);
when(mFragment.getActivity()).thenReturn(activity);
when(mInputManager.getInputDeviceByDescriptor(anyString())).thenReturn(device);
when(mInputManager.getEnabledKeyboardLayoutsForInputDevice(any(InputDeviceIdentifier.class))).thenReturn(enableKeyboardLayouts);
mController.onStart();
mController.onInputDeviceRemoved(ANOTHER_DEVICE_ID);
assertThat(activity.isFinishing()).isFalse();
}
use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class KeyboardLayoutPickerControllerTest method testOnDeviceRemove_getSameDevice_shouldFinish.
@Test
@Config(shadows = ShadowInputDevice.class)
public void testOnDeviceRemove_getSameDevice_shouldFinish() {
final int TARGET_DEVICE_ID = 1;
final FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
final String[] enableKeyboardLayouts = { "layout1" };
final InputDevice device = ShadowInputDevice.makeInputDevicebyId(TARGET_DEVICE_ID);
when(mFragment.getActivity()).thenReturn(activity);
when(mInputManager.getInputDeviceByDescriptor(anyString())).thenReturn(device);
when(mInputManager.getEnabledKeyboardLayoutsForInputDevice(any(InputDeviceIdentifier.class))).thenReturn(enableKeyboardLayouts);
mController.onStart();
mController.onInputDeviceRemoved(TARGET_DEVICE_ID);
assertThat(activity.isFinishing()).isTrue();
}
use of androidx.fragment.app.FragmentActivity in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SurveyMixinTest method onPause_removesReceiverIfPreviouslySet.
@Test
public void onPause_removesReceiverIfPreviouslySet() {
// Pretend there is a survey in memory
when(mProvider.getSurveyExpirationDate(any(), any())).thenReturn(-1L);
// Pretend we are an activity that starts and stops
FragmentActivity temp = Robolectric.setupActivity(FragmentActivity.class);
when(mFragment.getActivity()).thenReturn(temp);
when(mProvider.createAndRegisterReceiver(any())).thenReturn(mReceiver);
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(temp);
SurveyMixin mixin = new SurveyMixin(mFragment, FAKE_KEY);
mixin.onResume();
manager.registerReceiver(mReceiver, new IntentFilter());
mixin.onPause();
// Verify we remove the receiver
HashMap<BroadcastReceiver, ArrayList<IntentFilter>> map = ReflectionHelpers.getField(manager, "mReceivers");
assertThat(map.containsKey(mReceiver)).isFalse();
}
use of androidx.fragment.app.FragmentActivity in project Presentation by StanKocken.
the class FormPresenter method onClickGoFormDialogFragment.
@Override
public void onClickGoFormDialogFragment() {
Activity activity = getActivity();
if (activity instanceof FragmentActivity) {
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
new FormDialogFragment().show(fragmentManager, "");
}
}
use of androidx.fragment.app.FragmentActivity in project android-oss by kickstarter.
the class BaseBottomSheetDialogFragment method onResume.
@CallSuper
@Override
public void onResume() {
super.onResume();
Timber.d("onResume %s", this.toString());
this.lifecycle.onNext(FragmentEvent.RESUME);
assignViewModel(null);
if (this.viewModel != null) {
this.viewModel.onResume(this);
final FragmentActivity activity = getActivity();
if (activity != null) {
activity.registerReceiver(this.optimizelyReadyReceiver, new IntentFilter(ExperimentsClientTypeKt.EXPERIMENTS_CLIENT_READY));
}
}
}
Aggregations