Java Code Examples for androidx.fragment.app.DialogFragment#getArguments()

The following examples show how to use androidx.fragment.app.DialogFragment#getArguments() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogHelper.java    From dialog-helper with Apache License 2.0 5 votes vote down vote up
/**
 * Obtain the ID of the given dialog. This method assumes that the dialog was shown using
 * DialogHelper.
 * @return the ID of the given dialog; null if the dialog has no ID
 */
public @Nullable String getDialogId(@NonNull DialogFragment dialog) {
    //noinspection ConstantConditions
    if (dialog == null) {
        throw new IllegalArgumentException("DialogFragment mustn't be null");
    }

    if (dialog.getArguments() == null ||
            !dialog.getArguments().containsKey(ARGUMENT_DIALOG_ID)) {
        return null;
    } else {
        return dialog.getArguments().getString(ARGUMENT_DIALOG_ID);
    }
}
 
Example 2
Source File: DefaultDialogFragmentConverter.java    From Alligator with MIT License 5 votes vote down vote up
@Override
@NonNull
@SuppressWarnings("unchecked")
public ScreenT getScreen(@NonNull DialogFragment dialogFragment) {
	if (dialogFragment.getArguments() == null) {
		throw new IllegalArgumentException("Fragment has no arguments.");
	} else if (Serializable.class.isAssignableFrom(mScreenClass)) {
		return checkNotNull((ScreenT) dialogFragment.getArguments().getSerializable(KEY_SCREEN));
	} else if (Parcelable.class.isAssignableFrom(mScreenClass)) {
		return checkNotNull((ScreenT) dialogFragment.getArguments().getParcelable(KEY_SCREEN));
	} else {
		throw new IllegalArgumentException("Screen " + mScreenClass.getSimpleName() + " should be Serializable or Parcelable.");
	}
}
 
Example 3
Source File: DialogHelper.java    From dialog-helper with Apache License 2.0 4 votes vote down vote up
private void setId(@NonNull DialogFragment dialog, @Nullable String id) {
    Bundle args = dialog.getArguments() != null ? dialog.getArguments() : new Bundle(1);
    args.putString(ARGUMENT_DIALOG_ID, id);
    dialog.setArguments(args);
}