Example usage for android.app DialogFragment setTargetFragment

List of usage examples for android.app DialogFragment setTargetFragment

Introduction

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

Prototype

public void setTargetFragment(Fragment fragment, int requestCode) 

Source Link

Document

Optional target for this fragment.

Usage

From source file:com.android.settings.aicp.AicpSettings.java

private void showDialogInner(int id) {
    DialogFragment newFragment = MyAlertDialogFragment.newInstance(id);
    newFragment.setTargetFragment(this, 0);
    newFragment.show(getFragmentManager(), "dialog " + id);
}

From source file:com.coinblesk.client.wallet.WalletAddressList.java

private void showCollectRefundOptionsDialog(Coin amount) {
    // there are two options for the user:
    // (1) user pays to current receive address of this wallet, i.e. in order to lock the funds again.
    // (2) user pays to custom address (external wallet)
    DialogFragment optionsDialog = CollectRefundOptionsDialog.newInstance(amount);
    optionsDialog.setTargetFragment(this, 0);
    optionsDialog.show(getFragmentManager(), "collect_refund_options_dialog");
}

From source file:android.support.v14.preference.PreferenceFragment.java

/**
 * Called when a preference in the tree requests to display a dialog. Subclasses should
 * override this method to display custom dialogs or to handle dialogs for custom preference
 * classes./*  ww  w .j a  va2  s .  co m*/
 *
 * @param preference The Preference object requesting the dialog.
 */
@Override
public void onDisplayPreferenceDialog(Preference preference) {

    boolean handled = false;
    if (getCallbackFragment() instanceof OnPreferenceDisplayDialogCallback) {
        handled = ((OnPreferenceDisplayDialogCallback) getCallbackFragment()).onPreferenceDisplayDialog(this,
                preference);
    }
    if (!handled && getActivity() instanceof OnPreferenceDisplayDialogCallback) {
        handled = ((OnPreferenceDisplayDialogCallback) getActivity()).onPreferenceDisplayDialog(this,
                preference);
    }

    if (handled) {
        return;
    }

    // check if dialog is already showing
    if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
        return;
    }

    final DialogFragment f;
    if (preference instanceof EditTextPreference) {
        f = EditTextPreferenceDialogFragment.newInstance(preference.getKey());
    } else if (preference instanceof ListPreference) {
        f = ListPreferenceDialogFragment.newInstance(preference.getKey());
    } else if (preference instanceof MultiSelectListPreference) {
        f = MultiSelectListPreferenceDialogFragment.newInstance(preference.getKey());
    } else {
        throw new IllegalArgumentException("Tried to display dialog for unknown "
                + "preference type. Did you forget to override onDisplayPreferenceDialog()?");
    }
    f.setTargetFragment(this, 0);
    f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
}

From source file:amhamogus.com.daysoff.fragments.AddEventFragment.java

@Override
public void onClick(View view) {
    Bundle args;// w  w  w  .j a v  a2s . c o  m
    DialogFragment timePicker;

    switch (view.getId()) {
    case R.id.event_checkbox_food:
        if (((CheckBox) view).isChecked()) {
            checkedActivities[0] = "Eat a meal";
        } else {
            checkedActivities[0] = "";
        }
        break;
    case R.id.event_checkbox_movie:
        if (((CheckBox) view).isChecked()) {
            checkedActivities[1] = "Watch a movie";
        } else {
            checkedActivities[1] = "";
        }
        break;
    case R.id.event_checkbox_outdoors:
        if (((CheckBox) view).isChecked()) {
            checkedActivities[2] = "Go for a walk";
        } else {
            checkedActivities[2] = "";
        }
        break;
    case R.id.start_time_btn:
        args = new Bundle();
        args.putInt("HOUR", hour);
        args.putInt("MINUTE", minute);

        timeLabel = (TextView) view;
        timePicker = new TimePickerFragment();
        timePicker.setArguments(args);
        timePicker.setTargetFragment(this, 0);
        timePicker.show(getFragmentManager(), "timePicker");
        break;
    case R.id.end_time_btn:
        args = new Bundle();
        args.putInt("HOUR", futureHour);
        args.putInt("MINUTE", futureMinute);

        timeLabel = (TextView) view;
        timePicker = new TimePickerFragment();

        timePicker.setArguments(args);
        timePicker.setTargetFragment(this, 0);
        timePicker.show(getFragmentManager(), "timePicker");
        break;
    }
}