Example usage for android.support.v4.app DialogFragment setTargetFragment

List of usage examples for android.support.v4.app DialogFragment setTargetFragment

Introduction

In this page you can find the example usage for android.support.v4.app DialogFragment setTargetFragment.

Prototype

public void setTargetFragment(Fragment fragment, int requestCode) 

Source Link

Document

Optional target for this fragment.

Usage

From source file:com.ultramegasoft.flavordex2.dialog.ConfirmationDialog.java

/**
 * Show a confirmation dialog./*from  w  ww. j  av a  2  s  . c o m*/
 *
 * @param fm          The FragmentManager to use
 * @param target      The Fragment to notify of the result
 * @param requestCode A number to identify this request
 * @param title       The dialog title
 * @param message     The dialog message
 * @param icon        Resource ID for the dialog icon
 * @param data        An Intent to store additional data
 */
public static void showDialog(@NonNull FragmentManager fm, @Nullable Fragment target, int requestCode,
        @Nullable String title, @Nullable String message, int icon, @Nullable Intent data) {
    final DialogFragment fragment = new ConfirmationDialog();
    fragment.setTargetFragment(target, requestCode);

    final Bundle args = new Bundle();
    args.putString(ARG_TITLE, title);
    args.putString(ARG_MESSAGE, message);
    args.putInt(ARG_ICON, icon);
    args.putParcelable(ARG_DATA, data);
    fragment.setArguments(args);

    fragment.show(fm, TAG);
}

From source file:com.ultramegasoft.flavordex2.dialog.CatListDialog.java

/**
 * Show the dialog.//  w ww. ja v  a  2  s.  com
 *
 * @param fm          The FragmentManager to use
 * @param target      The Fragment to notify of the result
 * @param requestCode A number to identify this request
 */
public static void showDialog(@NonNull FragmentManager fm, @Nullable Fragment target, int requestCode) {
    final DialogFragment fragment = new CatListDialog();
    fragment.setTargetFragment(target, requestCode);

    fragment.show(fm, TAG);
}

From source file:net.xpece.android.support.preference.XpColorPreferenceDialogFragment.java

public static boolean onPreferenceDisplayDialog(PreferenceFragmentCompat preferenceFragment,
        android.support.v7.preference.Preference preference) {
    if (preference instanceof ColorPreference) {
        final String key = preference.getKey();
        DialogFragment f = XpColorPreferenceDialogFragment.newInstance(key);
        f.setTargetFragment(preferenceFragment, 0);
        f.show(preferenceFragment.getFragmentManager(), key);
        return true;
    }// w w w . j a  va 2  s.  co  m
    return false;
}

From source file:com.feathercoin.wallet.feathercoin.ui.AmountCalculatorFragment.java

public static void calculate(final FragmentManager fm, final Listener listener) {
    final DialogFragment newFragment = new AmountCalculatorFragment();
    newFragment.setTargetFragment((Fragment) listener, 0);
    newFragment.show(fm, FRAGMENT_TAG);/*from  www.j  a va2s. c o  m*/
}

From source file:net.maiatday.hellorealm.ui.TriggerSelectDialogFragment.java

/**
 * Static method to show this MultiSelect dialog fragment
 *
 * @param fm             fragment manager
 * @param targetFragment Target fragment if required
 * @param moodUuid       associated alert id
 *///from  w  w w  .  j a v  a  2s . c o  m
public static void show(FragmentManager fm, @Nullable Fragment targetFragment, String moodUuid) {
    DialogFragment newFragment = TriggerSelectDialogFragment.newInstance(moodUuid);
    if (targetFragment != null) {
        newFragment.setTargetFragment(targetFragment, 0);
    }
    newFragment.show(fm, TAG);
}

From source file:com.ultramegasoft.flavordex2.dialog.CatDeleteDialog.java

/**
 * Show the confirmation dialog to delete a category.
 *
 * @param fm          The FragmentManager to use
 * @param target      The Fragment to send the result to
 * @param requestCode The code to identify the request
 * @param catId       The database ID for the category
 *///from w  ww .  j  a  v a2 s  . c om
public static void showDialog(@NonNull FragmentManager fm, @Nullable Fragment target, int requestCode,
        long catId) {
    if (catId > 0) {
        final DialogFragment fragment = new CatDeleteDialog();
        fragment.setTargetFragment(target, requestCode);

        final Bundle args = new Bundle();
        args.putLong(ARG_CAT_ID, catId);
        fragment.setArguments(args);

        fragment.show(fm, TAG);
    }
}

From source file:org.andstatus.app.util.DialogFactory.java

public static void showYesCancelDialog(Fragment fragment, int titleId, int messageId,
        final ActivityRequestCode requestCode) {
    DialogFragment dialog = new YesCancelDialog();
    Bundle args = new Bundle();
    args.putCharSequence(DIALOG_TITLE_KEY, fragment.getText(titleId));
    args.putCharSequence(DIALOG_MESSAGE_KEY, fragment.getText(messageId));
    dialog.setArguments(args);/* w  ww  .  j  a v  a  2s .co  m*/
    dialog.setTargetFragment(fragment, requestCode.id);
    dialog.show(fragment.getFragmentManager(), YES_CANCEL_DIALOG_TAG);
}

From source file:org.andstatus.app.util.DialogFactory.java

/** See http://stackoverflow.com/questions/10285047/showdialog-deprecated-whats-the-alternative */
public static void showOkDialog(Fragment fragment, int titleId, int messageId, final int requestCode) {
    DialogFragment dialog = new OkDialogFragment();
    Bundle args = new Bundle();
    args.putCharSequence(DIALOG_TITLE_KEY, fragment.getText(titleId));
    args.putCharSequence(DIALOG_MESSAGE_KEY, fragment.getText(messageId));
    dialog.setArguments(args);/*from www  . j  a  va 2 s  . c om*/
    dialog.setTargetFragment(fragment, requestCode);
    dialog.show(fragment.getFragmentManager(), OK_DIALOG_TAG);
}

From source file:com.vuze.android.remote.dialog.DialogFragmentFilterBy.java

public static void openFilterByDialog(Fragment fragment, SessionInfo sessionInfo, String id) {
    DialogFragment dlg = null;
    if (sessionInfo.getSupportsTags()) {
        List<Map<?, ?>> allTags = sessionInfo.getTags();

        if (allTags != null && allTags.size() > 0) {
            dlg = new DialogFragmentFilterByTags();
        }/*from   w ww  .  jav  a2 s.c o  m*/
    }

    if (dlg == null) {
        dlg = new DialogFragmentFilterBy();
    }
    dlg.setTargetFragment(fragment, 0);
    Bundle bundle = new Bundle();
    bundle.putString(SessionInfoManager.BUNDLE_KEY, id);
    dlg.setArguments(bundle);
    AndroidUtils.showDialog(dlg, fragment.getFragmentManager(), "OpenFilterDialog");
}

From source file:com.ultramegasoft.flavordex2.dialog.FileSelectorDialog.java

/**
 * @param fm               The FragmentManager to use
 * @param target           The Fragment to send results to
 * @param requestCode      The request code
 * @param rootPath         The initial starting path
 * @param allowDirectories Whether to allow directories to be selected
 * @param nameFilter       Filter out files that do not contain any of these string
 * @param path             The current path
 *//*  w w  w  .  jav  a2s.  c o  m*/
private static void showDialog(@NonNull FragmentManager fm, @Nullable Fragment target, int requestCode,
        @Nullable String rootPath, boolean allowDirectories, @Nullable String[] nameFilter,
        @Nullable String path) {
    final DialogFragment fragment = new FileSelectorDialog();
    fragment.setTargetFragment(target, requestCode);

    final Bundle args = new Bundle();
    args.putString(ARG_ROOT_PATH, rootPath);
    args.putString(ARG_PATH, path);
    args.putBoolean(ARG_ALLOW_DIRECTORIES, allowDirectories);
    args.putStringArray(ARG_NAME_FILTER, nameFilter);
    fragment.setArguments(args);

    fragment.show(fm, TAG);
}