use of androidx.fragment.app.DialogFragment in project OneSignal-Android-SDK by OneSignal.
the class OSSystemConditionController method isDialogFragmentShowing.
boolean isDialogFragmentShowing(Context context) throws NoClassDefFoundError {
// Detect if user has a dialog fragment showing
if (context instanceof AppCompatActivity) {
final FragmentManager manager = ((AppCompatActivity) context).getSupportFragmentManager();
manager.registerFragmentLifecycleCallbacks(new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentDetached(@NonNull FragmentManager fm, @NonNull Fragment fragmentDetached) {
super.onFragmentDetached(fm, fragmentDetached);
if (fragmentDetached instanceof DialogFragment) {
manager.unregisterFragmentLifecycleCallbacks(this);
systemConditionObserver.systemConditionChanged();
}
}
}, true);
List<Fragment> fragments = manager.getFragments();
int size = fragments.size();
if (size > 0) {
// We only care of the last fragment available
Fragment fragment = fragments.get(size - 1);
return fragment.isVisible() && fragment instanceof DialogFragment;
}
}
// We cannot detect AlertDialogs because they are added to the decor view as linear layout without an identification
return false;
}
use of androidx.fragment.app.DialogFragment in project k-9 by k9mail.
the class MessageViewFragment method showDialog.
private void showDialog(int dialogId) {
DialogFragment fragment;
if (dialogId == R.id.dialog_confirm_delete) {
String title = getString(R.string.dialog_confirm_delete_title);
String message = getString(R.string.dialog_confirm_delete_message);
String confirmText = getString(R.string.dialog_confirm_delete_confirm_button);
String cancelText = getString(R.string.dialog_confirm_delete_cancel_button);
fragment = ConfirmationDialogFragment.newInstance(dialogId, title, message, confirmText, cancelText);
} else if (dialogId == R.id.dialog_confirm_spam) {
String title = getString(R.string.dialog_confirm_spam_title);
String message = getResources().getQuantityString(R.plurals.dialog_confirm_spam_message, 1);
String confirmText = getString(R.string.dialog_confirm_spam_confirm_button);
String cancelText = getString(R.string.dialog_confirm_spam_cancel_button);
fragment = ConfirmationDialogFragment.newInstance(dialogId, title, message, confirmText, cancelText);
} else if (dialogId == R.id.dialog_attachment_progress) {
String message = getString(R.string.dialog_attachment_progress_title);
long size = currentAttachmentViewInfo.size;
fragment = AttachmentDownloadDialogFragment.newInstance(size, message);
} else {
throw new RuntimeException("Called showDialog(int) with unknown dialog id.");
}
fragment.setTargetFragment(this, dialogId);
fragment.show(getParentFragmentManager(), getDialogTag(dialogId));
}
use of androidx.fragment.app.DialogFragment in project k-9 by k9mail.
the class MessageViewFragment method removeDialog.
private void removeDialog(int dialogId) {
if (!isAdded()) {
return;
}
FragmentManager fm = getParentFragmentManager();
// Make sure the "show dialog" transaction has been processed when we call
// findFragmentByTag() below. Otherwise the fragment won't be found and the dialog will
// never be dismissed.
fm.executePendingTransactions();
DialogFragment fragment = (DialogFragment) fm.findFragmentByTag(getDialogTag(dialogId));
if (fragment != null) {
fragment.dismissAllowingStateLoss();
}
}
use of androidx.fragment.app.DialogFragment in project Signal-Android by signalapp.
the class GroupLinkShareQrDialogFragment method show.
public static void show(@NonNull FragmentManager manager, @NonNull GroupId.V2 groupId) {
DialogFragment fragment = new GroupLinkShareQrDialogFragment();
Bundle args = new Bundle();
args.putString(ARG_GROUP_ID, groupId.toString());
fragment.setArguments(args);
fragment.show(manager, BottomSheetUtil.STANDARD_BOTTOM_SHEET_FRAGMENT_TAG);
}
use of androidx.fragment.app.DialogFragment in project Signal-Android by signalapp.
the class ReactWithAnyEmojiBottomSheetDialogFragment method createForEditReactions.
public static DialogFragment createForEditReactions() {
DialogFragment fragment = new ReactWithAnyEmojiBottomSheetDialogFragment();
Bundle args = new Bundle();
args.putLong(ARG_MESSAGE_ID, -1);
args.putBoolean(ARG_IS_MMS, false);
args.putInt(ARG_START_PAGE, -1);
args.putBoolean(ARG_SHADOWS, false);
args.putString(ARG_RECENT_KEY, REACTION_STORAGE_KEY);
fragment.setArguments(args);
return fragment;
}
Aggregations