Search in sources :

Example 1 with LicensesDialogFragment

use of de.psdev.licensesdialog.LicensesDialogFragment 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)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)1 LicensesDialogFragment (de.psdev.licensesdialog.LicensesDialogFragment)1