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

The following examples show how to use androidx.fragment.app.DialogFragment#setTargetFragment() . 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: SettingsFragment.java    From SmsCode with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    boolean handled = false;
    if (preference instanceof ResetEditPreference) {
        DialogFragment dialogFragment =
                ResetEditPreferenceDialogFragCompat.newInstance(preference.getKey());

        FragmentManager fm = this.getFragmentManager();
        if (fm != null) {
            dialogFragment.setTargetFragment(this, 0);
            dialogFragment.show(fm, "android.support.v14.preference.PreferenceFragment.DIALOG");
            handled = true;
        }
    }
    if (!handled) {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example 2
Source File: ArticleTabFragment.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
private void createGotoDialog() {

        Bundle args = new Bundle();
        args.putInt("page", mPagerAdapter.getCount());
        args.putInt("floor", mReplyCount);

        DialogFragment df = new GotoDialogFragment();
        df.setArguments(args);
        df.setTargetFragment(this, ActivityUtils.REQUEST_CODE_JUMP_PAGE);

        FragmentManager fm = getActivity().getSupportFragmentManager();

        Fragment prev = fm.findFragmentByTag(GOTO_TAG);
        if (prev != null) {
            fm.beginTransaction().remove(prev).commit();
        }
        df.show(fm, GOTO_TAG);

    }
 
Example 3
Source File: SettingsFragment.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("RestrictedApi")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    if (preference instanceof NumberPickerPreference) {
        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;
        }

        if (getFragmentManager().findFragmentByTag("numberpicker") != null) {
            return;
        }

        DialogFragment f = NumberPickerPreference.NumberPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), "numberpicker");
    } else
        super.onDisplayPreferenceDialog(preference);
}
 
Example 4
Source File: AccessLogActivity.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
/**
 * ダイアログを表示します.
 * <p>
 * targetFragment に指定した Fragment の {@link Fragment#onActivityResult(int, int, Intent)}
 * にレスポンスを返却します。
 * </p>
 * @param fragmentManager 表示するFragmentManager
 * @param targetFragment ターゲットとなるFragment
 */
void show(FragmentManager fragmentManager, Fragment targetFragment) {
    Bundle bundle = new Bundle();
    if (mTitle != null) {
        bundle.putString("title", mTitle);
    }
    if (mMessage != null) {
        bundle.putString("message", mMessage);
    }
    if (mPositive != null) {
        bundle.putString("positive", mPositive);
    }
    if (mNegative != null) {
        bundle.putString("negative", mNegative);
    }
    DialogFragment dialog = new DeleteDialogFragment();
    dialog.setArguments(bundle);
    dialog.setTargetFragment(targetFragment, mRequestCode);
    dialog.show(fragmentManager, "test");
}
 
Example 5
Source File: SettingsFragment.java    From prayer-times-android with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("RestrictedApi")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    if (preference instanceof NumberPickerPreference) {
        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;
        }

        if (getFragmentManager().findFragmentByTag("numberpicker") != null) {
            return;
        }

        DialogFragment f = NumberPickerPreference.NumberPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), "numberpicker");
    } else
        super.onDisplayPreferenceDialog(preference);
}
 
Example 6
Source File: AppNotificationSettingsActivity.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    String TAG = "NumberPickerPreference";
    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentByTag(TAG) != null) {
        return;
    }

    if (preference instanceof NumberPickerPreference) {
        final DialogFragment f = NumberPickerPreferenceDialog.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(fm, TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example 7
Source File: NotificationSettingsActivity.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    String TAG = "NumberPickerPreference";
    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentByTag(TAG) != null) {
        return;
    }

    if (preference instanceof NumberPickerPreference) {
        final DialogFragment f = NumberPickerPreferenceDialog.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(fm, TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example 8
Source File: AppNotificationSettingsActivity.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    String TAG = "NumberPickerPreference";
    FragmentManager fm = getFragmentManager();
    if (fm.findFragmentByTag(TAG) != null) {
        return;
    }

    if (preference instanceof NumberPickerPreference) {
        final DialogFragment f = NumberPickerPreferenceDialog.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(fm, TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example 9
Source File: SettingsFragment.java    From XposedSmsCode with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    boolean handled = false;
    if (preference instanceof ResetEditPreference) {
        DialogFragment dialogFragment =
                ResetEditPreferenceDialogFragCompat.newInstance(preference.getKey());

        FragmentManager fm = getFragmentManager();
        if (fm != null) {
            dialogFragment.setTargetFragment(this, 0);
            dialogFragment.show(fm, "android.support.v7.preference.PreferenceFragment.DIALOG");
            handled = true;
        }
    }
    if (!handled) {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example 10
Source File: SettingsFragment.java    From Intra with Apache License 2.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
  if (preference instanceof ServerChooser) {
    DialogFragment dialogFragment = ServerChooserFragment.newInstance(preference.getKey());
    dialogFragment.setTargetFragment(this, 0);
    dialogFragment.show(getFragmentManager(), null);
  } else {
    // This is the app exclusion dialog.
    final ArrayList<AppInfo> appList = getAppList();
    if (appList != null) {
      String[] labels = new String[appList.size()];
      String[] packageNames = new String[appList.size()];
      for (int i = 0; i < appList.size(); ++i) {
        AppInfo entry = appList.get(i);
        labels[i] = entry.label;
        packageNames[i] = entry.packageName;
      }

      appPref.setEntries(labels);
      appPref.setEntryValues(packageNames);
    }

    super.onDisplayPreferenceDialog(preference);
  }
}
 
Example 11
Source File: CorrectedPreferenceFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
  DialogFragment dialogFragment = null;

  if (preference instanceof ColorPickerPreference) {
    dialogFragment = ColorPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey());
  } else if (preference instanceof CustomDefaultPreference) {
    dialogFragment = CustomDefaultPreference.CustomDefaultPreferenceDialogFragmentCompat.newInstance(preference.getKey());
  }

  if (dialogFragment != null) {
    dialogFragment.setTargetFragment(this, 0);
    dialogFragment.show(getFragmentManager(), "android.support.v7.preference.PreferenceFragment.DIALOG");
  } else {
    super.onDisplayPreferenceDialog(preference);
  }
}
 
Example 12
Source File: CommCarePreferenceFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
    // check if dialog is already showing
    if (getFragmentManager().findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
        return;
    }

    if (preference instanceof FilePreference) {
        DialogFragment f = FilePreferenceDialogFragmentCompat.newInstance(preference.getKey());
        f.setTargetFragment(this, 0);
        f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
    } else {
        super.onDisplayPreferenceDialog(preference);
    }
}
 
Example 13
Source File: SettingsActivity.java    From AppOpsX with MIT License 5 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
  if (preference instanceof NumberPickerPreference) {
    DialogFragment fragment = NumberPickerPreference.
        NumberPickerPreferenceDialogFragmentCompat.newInstance(preference.getKey());
    fragment.setTargetFragment(this, 0);
    fragment.show(getFragmentManager(),
        "NumberPickerPreferenceDialogFragment");
  } else {
    super.onDisplayPreferenceDialog(preference);
  }
}
 
Example 14
Source File: SettingsFragment.java    From zapp with MIT License 5 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
	if (preference instanceof DeleteSearchQueriesPreference) {
		DialogFragment dialogFragment = DeleteSearchQueriesPreferenceDialog.newInstance(preference.getKey());
		dialogFragment.setTargetFragment(this, 0);
		dialogFragment.show(Objects.requireNonNull(getParentFragmentManager()), null);
		return;
	}

	super.onDisplayPreferenceDialog(preference);
}
 
Example 15
Source File: PreferenceFragment.java    From MaterialPreference with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 *
 * @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;
    }

    DialogFragment f = null;
    if (preference instanceof DialogPreference) {
        f = ((DialogPreference) preference).onCreateDialogFragment(preference.getKey());
    }
    f.setTargetFragment(this, 0);
    f.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
}
 
Example 16
Source File: StockPreferenceFragment.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onDisplayPreferenceDialog(Preference preference) {
	if (preference instanceof CustomListPreference) {
		DialogFragment fragment = CustomListPreferenceDialogFragmentCompat.newInstance((CustomListPreference) preference);
		fragment.setTargetFragment(this, 0);
		fragment.show(getFragmentManager(), "android.support.v7.preference.PreferenceFragment.DIALOG");
	} else {
		super.onDisplayPreferenceDialog(preference);
	}
}
 
Example 17
Source File: BaseNoteFragment.java    From nextcloud-notes with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Opens a dialog in order to chose a category
 */
public void showEditTitleDialog() {
    saveNote(null);
    final String fragmentId = "fragment_edit_title";
    FragmentManager manager = requireActivity().getSupportFragmentManager();
    Fragment frag = manager.findFragmentByTag(fragmentId);
    if (frag != null) {
        manager.beginTransaction().remove(frag).commit();
    }
    DialogFragment editTitleFragment = EditTitleDialogFragment.newInstance(note.getTitle());
    editTitleFragment.setTargetFragment(this, 0);
    editTitleFragment.show(manager, fragmentId);
}
 
Example 18
Source File: CreatePoiFragment.java    From AndroidApp with Mozilla Public License 2.0 4 votes vote down vote up
public void showTimePickerDialog() {
    DialogFragment dialogFragment = new TimePickerFragment();
    dialogFragment.setTargetFragment(this, 0);
    dialogFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
}
 
Example 19
Source File: CreatePoiFragment.java    From AndroidApp with Mozilla Public License 2.0 4 votes vote down vote up
public void featureSelectorDialog() {
    DialogFragment dialogFragment = PoiFeatureDialogFragment.newInstance();
    dialogFragment.setTargetFragment(this, 1);
    dialogFragment.show(getActivity().getSupportFragmentManager(), "PoiFeatureDialogFragment");
}
 
Example 20
Source File: EditPoiFragment.java    From AndroidApp with Mozilla Public License 2.0 4 votes vote down vote up
public void showTimePickerDialog() {
    DialogFragment dialogFragment = new TimePickerFragment();
    dialogFragment.setTargetFragment(this, 0);
    dialogFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
}