Search in sources :

Example 1 with PreferenceFragment

use of android.support.v4.preference.PreferenceFragment in project platform_frameworks_base by android.

the class TunerActivity method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getFragmentManager().findFragmentByTag(TAG_TUNER) == null) {
        final String action = getIntent().getAction();
        boolean showDemoMode = action != null && action.equals("com.android.settings.action.DEMO_MODE");
        final PreferenceFragment fragment = showDemoMode ? new DemoModeFragment() : new TunerFragment();
        getFragmentManager().beginTransaction().replace(R.id.content_frame, fragment, TAG_TUNER).commit();
    }
}
Also used : PreferenceFragment(android.support.v14.preference.PreferenceFragment)

Example 2 with PreferenceFragment

use of android.support.v4.preference.PreferenceFragment in project android_frameworks_base by AOSPA.

the class TunerActivity method onPreferenceStartFragment.

@Override
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
    try {
        Class<?> cls = Class.forName(pref.getFragment());
        Fragment fragment = (Fragment) cls.newInstance();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        setTitle(pref.getTitle());
        transaction.replace(R.id.content_frame, fragment);
        transaction.addToBackStack("PreferenceFragment");
        transaction.commit();
        return true;
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        Log.d("TunerActivity", "Problem launching fragment", e);
        return false;
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) PreferenceFragment(android.support.v14.preference.PreferenceFragment)

Example 3 with PreferenceFragment

use of android.support.v4.preference.PreferenceFragment in project platform_frameworks_base by android.

the class TunerActivity method onPreferenceStartFragment.

@Override
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
    try {
        Class<?> cls = Class.forName(pref.getFragment());
        Fragment fragment = (Fragment) cls.newInstance();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        setTitle(pref.getTitle());
        transaction.replace(R.id.content_frame, fragment);
        transaction.addToBackStack("PreferenceFragment");
        transaction.commit();
        return true;
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        Log.d("TunerActivity", "Problem launching fragment", e);
        return false;
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) PreferenceFragment(android.support.v14.preference.PreferenceFragment)

Example 4 with PreferenceFragment

use of android.support.v4.preference.PreferenceFragment in project Douya by DreaminginCodeZH.

the class LicensesDialogPreference method onDisplayPreferenceDialog.

/**
     * Users should override {@link PreferenceFragmentCompat#onDisplayPreferenceDialog(Preference)}
     * and check the return value of this method, only call through to super implementation if
     * {@code false} is returned.
     *
     * @param preferenceFragment The preference fragment
     * @param preference The preference, as in
     * {@link PreferenceFragmentCompat#onDisplayPreferenceDialog(Preference)}
     * @return Whether the call has been handled by this method.
     */
public static boolean onDisplayPreferenceDialog(PreferenceFragmentCompat preferenceFragment, Preference preference) {
    if (preference instanceof LicensesDialogPreference) {
        // getChildFragmentManager() will lead to looking for target fragment in the child
        // fragment manager.
        FragmentManager fragmentManager = preferenceFragment.getFragmentManager();
        if (fragmentManager.findFragmentByTag(DIALOG_FRAGMENT_TAG) == null) {
            LicensesDialogFragment dialogFragment = new LicensesDialogFragment.Builder(preferenceFragment.getActivity()).setNotices(R.raw.licenses).setUseAppCompat(true).build();
            dialogFragment.setTargetFragment(preferenceFragment, 0);
            dialogFragment.show(fragmentManager, DIALOG_FRAGMENT_TAG);
        }
        return true;
    }
    return false;
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) LicensesDialogFragment(de.psdev.licensesdialog.LicensesDialogFragment)

Example 5 with PreferenceFragment

use of android.support.v4.preference.PreferenceFragment in project android_frameworks_base by DirtyUnicorns.

the class PNCActivity method onPreferenceStartFragment.

@Override
public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
    try {
        Class<?> cls = Class.forName(pref.getFragment());
        Fragment fragment = (Fragment) cls.newInstance();
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        setTitle(pref.getTitle());
        transaction.replace(R.id.content_frame, fragment);
        transaction.addToBackStack("PreferenceFragment");
        transaction.commit();
        return true;
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        Log.d("TunerActivity", "Problem launching fragment", e);
        return false;
    }
}
Also used : FragmentTransaction(android.app.FragmentTransaction) Fragment(android.app.Fragment) PreferenceFragment(android.support.v14.preference.PreferenceFragment)

Aggregations

PreferenceFragment (android.support.v14.preference.PreferenceFragment)10 Fragment (android.app.Fragment)8 FragmentTransaction (android.app.FragmentTransaction)6 Bundle (android.os.Bundle)1 LeanbackSettingsFragment (android.support.v17.preference.LeanbackSettingsFragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 LicensesDialogFragment (de.psdev.licensesdialog.LicensesDialogFragment)1