Java Code Examples for android.app.DialogFragment#setArguments()

The following examples show how to use android.app.DialogFragment#setArguments() . 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: DialogUtil.java    From Augendiagnose with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Display an error and either go back to the current activity or finish the current activity.
 *
 * @param activity the current activity
 * @param resource the error message
 * @param listener listener to react on dialog confirmation or dismissal.
 * @param args     arguments for the error message
 */
private static void displayError(@NonNull final Activity activity, final int resource, @Nullable final MessageDialogListener listener,
								 final Object... args) {
	String message = String.format(activity.getString(resource), args);
	Log.w(Application.TAG, "Dialog message: " + message);
	Bundle bundle = new Bundle();
	bundle.putCharSequence(PARAM_MESSAGE, message);
	bundle.putString(PARAM_TITLE, activity.getString(R.string.title_dialog_error));
	bundle.putInt(PARAM_ICON, R.drawable.ic_title_error);
	if (listener != null) {
		bundle.putSerializable(PARAM_LISTENER, listener);
	}

	DialogFragment fragment = new DisplayMessageDialogFragment();
	fragment.setArguments(bundle);
	try {
		fragment.show(activity.getFragmentManager(), fragment.getClass().toString());
	}
	catch (IllegalStateException e) {
		displayToast(activity, resource, args);
		if (listener != null) {
			listener.onDialogClick(fragment);
		}
	}
}
 
Example 2
Source File: DialogUtil.java    From Augendiagnose with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Display an information message and go back to the current activity.
 *
 * @param activity the current activity
 * @param listener an optional listener waiting for the dialog response. If a listener is given, then the dialog will not
 *                 be automatically recreated on orientation change!
 * @param resource the message resource
 * @param args     arguments for the error message
 */
public static void displayInfo(@NonNull final Activity activity, @Nullable final MessageDialogListener listener, final int resource,
							   final Object... args) {
	String message = String.format(activity.getString(resource), args);
	Bundle bundle = new Bundle();
	bundle.putCharSequence(PARAM_MESSAGE, message);
	bundle.putString(PARAM_TITLE, activity.getString(R.string.title_dialog_info));
	bundle.putInt(PARAM_ICON, R.drawable.ic_title_info);
	if (listener != null) {
		bundle.putSerializable(PARAM_LISTENER, listener);
	}
	DialogFragment fragment = new DisplayMessageDialogFragment();
	fragment.setArguments(bundle);
	try {
		fragment.show(activity.getFragmentManager(), fragment.getClass().toString());
	}
	catch (IllegalStateException e) {
		displayToast(activity, resource, args);
		if (listener != null) {
			listener.onDialogClick(fragment);
		}
	}
}
 
Example 3
Source File: TextPropertyEditor.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
protected void startChangeValueDialog()
{
	Bundle args = initDialogArgs();
	DialogFragment df = new TextEditDialog();
	df.setArguments(args);
	df.show(getHost().getFragmentManager(), TextEditDialog.TAG);
}
 
Example 4
Source File: MainActivity.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
@Override
public void showUiRefreshDialog(String filename, boolean isEdit, boolean returnToList) {
    Bundle bundle = new Bundle();
    bundle.putString("filename", filename);
    bundle.putBoolean("is-edit", isEdit);
    bundle.putBoolean("return-to-list", returnToList);

    DialogFragment uiRefreshFragment = new UiRefreshDialogFragment();
    uiRefreshFragment.setArguments(bundle);
    uiRefreshFragment.show(getFragmentManager(), "ui-refresh");
}
 
Example 5
Source File: MainActivity.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
@Override
public void showReloadDialog(String filename, boolean isEdit, boolean returnToList) {
    Bundle bundle = new Bundle();
    bundle.putString("filename", filename);
    bundle.putBoolean("is-edit", isEdit);
    bundle.putBoolean("return-to-list", returnToList);

    DialogFragment reloadProfileFragment = new ReloadProfileDialogFragment();
    reloadProfileFragment.setArguments(bundle);
    reloadProfileFragment.show(getFragmentManager(), "reload");
}
 
Example 6
Source File: DialogUtil.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Display an error.
 *
 * @param activity the current activity
 * @param resource the error message
 * @param args     arguments for the error message
 */
public static void displayError(@NonNull final Activity activity, final int resource, final Object... args) {
	String message = String.format(activity.getString(resource), args);
	Bundle bundle = new Bundle();
	bundle.putCharSequence(PARAM_MESSAGE, message);
	bundle.putString(PARAM_TITLE, activity.getString(R.string.title_dialog_error));

	DialogFragment fragment = new DisplayMessageDialogFragment();
	fragment.setArguments(bundle);
	fragment.show(activity.getFragmentManager(), fragment.getClass().toString());
}
 
Example 7
Source File: CustomKeysActivity.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
private void showAddDialog(int index, String word) {
    DialogFragment newFragment = new AddWordDialogFragment();
    Bundle args = new Bundle();
    args.putInt("index", index);
    args.putString("word", word);
    newFragment.setArguments(args);
    newFragment.show(getFragmentManager(), "new_word");
}
 
Example 8
Source File: CustomKeysActivity.java    From kboard with GNU General Public License v3.0 5 votes vote down vote up
private void showAddDialog(int index, String word) {
    DialogFragment newFragment = new AddWordDialogFragment();
    Bundle args = new Bundle();
    args.putInt("index", index);
    args.putString("word", word);
    newFragment.setArguments(args);
    newFragment.show(getFragmentManager(), "new_word");
}
 
Example 9
Source File: GenericAlertDialogFragment.java    From United4 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Factory for an alert dialog
 * @param s the title and message of the new dialog
 * @param manager the fragment manager used to show the dialog
 */
public static void newInstance(String s, FragmentManager manager) {
    DialogFragment f = new GenericAlertDialogFragment();
    Bundle args = new Bundle();
    args.putString("text", s);
    f.setArguments(args);
    f.show(manager, "dialog");
}
 
Example 10
Source File: GenericProgressDialogFragment.java    From United4 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generic factory method for a progress dialog
 * @param s the title and message of the dialog
 * @param manager the manager to use to add the dialog
 */
public static void newInstance(String s, FragmentManager manager) {
    DialogFragment f = new GenericProgressDialogFragment();
    Bundle args = new Bundle();
    args.putString("text", s);
    f.setArguments(args);
    f.show(manager, "progress_dialog");
}
 
Example 11
Source File: RenameFileDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, String currentPath, String fileName)
{
	DialogFragment newFragment = new RenameFileDialog();
	Bundle b = new Bundle();
	b.putString(ARG_CURRENT_PATH, currentPath);
	b.putString(ARG_FILENAME, fileName);
	newFragment.setArguments(b);
    newFragment.show(fm, TAG);
}
 
Example 12
Source File: SavePIMPropertyEditor.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
protected void startChangeValueDialog()
{
    Bundle args = initDialogArgs();
    DialogFragment df = new TextEditDialog();
    df.setArguments(args);
    df.show(getHost().getFragmentManager(), TextEditDialog.TAG);
}
 
Example 13
Source File: ChoiceDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, int propertyId, String title, List<String> variants, String hostFragmentTag)
{
       Bundle args = new Bundle();
       args.putStringArrayList(ARG_VARIANTS, new ArrayList<>(variants));
       args.putString(ARG_TITLE, title);
       args.putInt(PropertyEditor.ARG_PROPERTY_ID, propertyId);
       if(hostFragmentTag!=null)
           args.putString(PropertyEditor.ARG_HOST_FRAGMENT_TAG, hostFragmentTag);
	DialogFragment newFragment = new ChoiceDialog();
       newFragment.setArguments(args);
    newFragment.show(fm, TAG);
}
 
Example 14
Source File: AskExtStorageWritePermissionDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, String openerTag)
{
	Bundle args = new Bundle();
	args.putString(LocationOpenerBaseFragment.PARAM_RECEIVER_FRAGMENT_TAG, openerTag);
	DialogFragment newFragment = new AskExtStorageWritePermissionDialog();
	newFragment.setArguments(args);
    newFragment.show(fm, "AskExtStorageWritePermissionDialog");
}
 
Example 15
Source File: RemoveLocationConfirmationDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, Location loc)
{
    DialogFragment f = new RemoveLocationConfirmationDialog();
    Bundle b = new Bundle();
    LocationsManager.storePathsInBundle(b,loc, null);
    f.setArguments(b);
    f.show(fm, TAG);
}
 
Example 16
Source File: OverwriteContainerDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, int requestResId)
{		
	DialogFragment newFragment = new OverwriteContainerDialog();
	if(requestResId > 0)
	{
		Bundle args = new Bundle();
		args.putInt(ARG_REQUEST_RES_ID, requestResId);
		newFragment.setArguments(args);
	}
    newFragment.show(fm, "com.sovworks.eds.android.locations.dialogs.OverwriteContainerDialog");
}
 
Example 17
Source File: ForceCloseDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, String closerTag, String locTitle, String closerClassName, Bundle closerArgs)
{
    DialogFragment f = new ForceCloseDialog();
    Bundle b = new Bundle();
    b.putString(ARG_LOCATION_TITLE, locTitle);
    b.putString(ARG_CLOSER_CLASS_NAME, closerClassName);
    if(closerArgs!=null)
        b.putBundle(ARG_CLOSER_ARGS, closerArgs);
    b.putString(LocationCloserBaseFragment.PARAM_RECEIVER_FRAGMENT_TAG, closerTag);
    f.setArguments(b);
    f.show(fm, TAG);
}
 
Example 18
Source File: SortDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm,int sortMode,int sortLabelsResId, String receiverFragmentTag)
{
	DialogFragment newFragment = new SortDialog();		
	Bundle b = new Bundle();		
	b.putInt(ARG_SORT_MODE, sortMode);
	b.putInt(ARG_SORT_LABELS_RES_ID, sortLabelsResId);
       if(receiverFragmentTag!=null)
           b.putString(ARG_RECEIVER_FRAGMENT_TAG, receiverFragmentTag);
	newFragment.setArguments(b);
    newFragment.show(fm, "SortDialog");
}
 
Example 19
Source File: NewFileDialog.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
public static void showDialog(FragmentManager fm, int type, String receiverTag)
{
	DialogFragment newFragment = new NewFileDialog();
	Bundle b = new Bundle();
	b.putInt(ARG_TYPE, type);
	b.putString(ARG_RECEIVER_TAG, receiverTag);
	newFragment.setArguments(b);
    newFragment.show(fm, "NewFileDialog");
}
 
Example 20
Source File: DeleteConfirmationDialog.java    From edslite with GNU General Public License v2.0 4 votes vote down vote up
public static void showDialog(FragmentManager fm,Bundle args)
{		
	DialogFragment newFragment = new DeleteConfirmationDialog();
	newFragment.setArguments(args);
    newFragment.show(fm, TAG);
}