androidx.preference.PreferenceFragment Java Examples

The following examples show how to use androidx.preference.PreferenceFragment. 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: OnDisplayPreferenceDialogDelegater.java    From libcommon with Apache License 2.0 6 votes vote down vote up
/**
 * PreferenceFragment#onDisplayPreferenceDialogのヘルパーメソッド
 * @param fragment
 * @param preference
 * @return true: 処理済み, false: 未処理
 */
public static boolean onDisplayPreferenceDialog(
	@NonNull final PreferenceFragment fragment,
	final Preference preference) {

	if (DEBUG) Log.v(TAG, "onDisplayPreferenceDialog:" + preference);
	final android.app.FragmentManager fm = fragment.getFragmentManager();
	if (preference instanceof NumberPickerPreferenceV7) {
		// check if dialog is already showing
		if (fm.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) {
			return true;	// handled
		}

		final android.app.DialogFragment f
			= NumberPickerPreferenceFragment.newInstance(preference.getKey());
		f.setTargetFragment(fragment, 0);
		f.show(fm, DIALOG_FRAGMENT_TAG);
		return true;	// handled
	}
	return false;
}
 
Example #2
Source File: SettingsExampleFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceStartScreen(PreferenceFragment preferenceFragment,
                                       PreferenceScreen preferenceScreen) {
    PreferenceFragment frag = buildPreferenceFragment(R.xml.prefs, preferenceScreen.getKey());
    startPreferenceFragment(frag);
    return true;
}
 
Example #3
Source File: SettingsExampleFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private PreferenceFragment buildPreferenceFragment(int preferenceResId, String root) {
    PreferenceFragment fragment = new PrefFragment();
    Bundle args = new Bundle();
    args.putInt("preferenceResource", preferenceResId);
    args.putString("root", root);
    fragment.setArguments(args);
    return fragment;
}
 
Example #4
Source File: SettingsFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceStartScreen(PreferenceFragment preferenceFragment,
    PreferenceScreen preferenceScreen) {
    PreferenceFragment frag = buildPreferenceFragment(R.xml.settings,
        preferenceScreen.getKey());
    startPreferenceFragment(frag);
    return true;
}
 
Example #5
Source File: SettingsFragment.java    From tv-samples with Apache License 2.0 5 votes vote down vote up
private PreferenceFragment buildPreferenceFragment(int preferenceResId, String root) {
    PreferenceFragment fragment = new PrefFragment();
    Bundle args = new Bundle();
    args.putInt(PREFERENCE_RESOURCE_ID, preferenceResId);
    args.putString(PREFERENCE_ROOT, root);
    fragment.setArguments(args);
    return fragment;
}
 
Example #6
Source File: Util.java    From android-testdpc with Apache License 2.0 5 votes vote down vote up
public static void showFileViewer(PreferenceFragment fragment, int requestCode) {
    Intent certIntent = new Intent(Intent.ACTION_GET_CONTENT);
    certIntent.setTypeAndNormalize("*/*");
    try {
        fragment.startActivityForResult(certIntent, requestCode);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "showFileViewer: ", e);
    }
}
 
Example #7
Source File: SettingsFragment.java    From androidtv-Leanback with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPreferenceStartScreen(PreferenceFragment preferenceFragment,
    PreferenceScreen preferenceScreen) {
    PreferenceFragment frag = buildPreferenceFragment(R.xml.settings,
        preferenceScreen.getKey());
    startPreferenceFragment(frag);
    return true;
}
 
Example #8
Source File: SettingsFragment.java    From androidtv-Leanback with Apache License 2.0 5 votes vote down vote up
private PreferenceFragment buildPreferenceFragment(int preferenceResId, String root) {
    PreferenceFragment fragment = new PrefFragment();
    Bundle args = new Bundle();
    args.putInt(PREFERENCE_RESOURCE_ID, preferenceResId);
    args.putString(PREFERENCE_ROOT, root);
    fragment.setArguments(args);
    return fragment;
}
 
Example #9
Source File: SettingsExampleFragment.java    From tv-samples with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPreferenceStartFragment(PreferenceFragment preferenceFragment,
                                         Preference preference) {
    return false;
}
 
Example #10
Source File: SettingsFragment.java    From tv-samples with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPreferenceStartFragment(PreferenceFragment preferenceFragment,
    Preference preference) {
    return false;
}
 
Example #11
Source File: SettingsFragment.java    From androidtv-Leanback with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPreferenceStartFragment(PreferenceFragment preferenceFragment,
    Preference preference) {
    return false;
}