use of androidx.fragment.app.FragmentActivity in project collect by opendatakit.
the class BackgroundAudioPermissionDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
setCancelable(false);
final FragmentActivity activity = requireActivity();
return new MaterialAlertDialogBuilder(requireContext()).setMessage(R.string.background_audio_permission_explanation).setPositiveButton(R.string.ok, (dialog, which) -> {
onOKClicked(activity);
}).create();
}
use of androidx.fragment.app.FragmentActivity in project android by nextcloud.
the class GalleryFragment method onResume.
@Override
public void onResume() {
super.onResume();
setLoading(photoSearchQueryRunning);
final FragmentActivity activity = getActivity();
if (activity instanceof FileDisplayActivity) {
FileDisplayActivity fileDisplayActivity = ((FileDisplayActivity) activity);
fileDisplayActivity.updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
fileDisplayActivity.setMainFabVisible(false);
}
}
use of androidx.fragment.app.FragmentActivity in project collect by opendatakit.
the class BackgroundAudioPermissionDialogFragmentTest method clickingOk_andGrantingPermissions_whenGrantPermissionsThrowsIllegalStateException_finishesActivity.
@Test
public void clickingOk_andGrantingPermissions_whenGrantPermissionsThrowsIllegalStateException_finishesActivity() {
doThrow(IllegalStateException.class).when(backgroundAudioViewModel).grantAudioPermission();
FragmentScenario<BackgroundAudioPermissionDialogFragment> scenario = launcherRule.launchDialogFragment(BackgroundAudioPermissionDialogFragment.class);
scenario.onFragment(f -> {
// Need to grab this here as `getActivity()` will return null later
FragmentActivity activity = f.getActivity();
AlertDialog dialog = (AlertDialog) f.getDialog();
Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
fakePermissionsProvider.setPermissionGranted(true);
button.performClick();
RobolectricHelpers.runLooper();
assertThat(activity.isFinishing(), is(true));
});
}
use of androidx.fragment.app.FragmentActivity in project collect by opendatakit.
the class DialogFragmentUtilsTest method showIfNotShowing_onlyEverOpensOneDialog.
@Test
public void showIfNotShowing_onlyEverOpensOneDialog() {
FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
FragmentManager fragmentManager = activity.getSupportFragmentManager();
DialogFragmentUtils.showIfNotShowing(DialogFragment.class, fragmentManager);
assertThat(fragmentManager.getFragments().size(), equalTo(1));
Fragment dialog1 = fragmentManager.getFragments().get(0);
DialogFragmentUtils.showIfNotShowing(DialogFragment.class, fragmentManager);
assertThat(fragmentManager.getFragments().size(), equalTo(1));
assertThat(fragmentManager.getFragments().get(0), equalTo(dialog1));
}
use of androidx.fragment.app.FragmentActivity in project collect by opendatakit.
the class DialogFragmentUtilsTest method showIfNotShowing_whenActivityDestroyed_doesNotShowDialog.
@Test
public void showIfNotShowing_whenActivityDestroyed_doesNotShowDialog() {
ActivityController<FragmentActivity> activityController = Robolectric.buildActivity(FragmentActivity.class).setup();
activityController.pause().stop().destroy();
FragmentManager fragmentManager = activityController.get().getSupportFragmentManager();
DialogFragmentUtils.showIfNotShowing(DialogFragment.class, fragmentManager);
assertThat(fragmentManager.getFragments().size(), equalTo(0));
}
Aggregations