當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiSelectListPreference類代碼示例

本文整理匯總了Java中net.xpece.android.support.preference.MultiSelectListPreference的典型用法代碼示例。如果您正苦於以下問題:Java MultiSelectListPreference類的具體用法?Java MultiSelectListPreference怎麽用?Java MultiSelectListPreference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MultiSelectListPreference類屬於net.xpece.android.support.preference包,在下文中一共展示了MultiSelectListPreference類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bindPreferenceSummaryToValue

import net.xpece.android.support.preference.MultiSelectListPreference; //導入依賴的package包/類
/**
 * Binds a preference's summary to its value. More specifically, when the
 * preference's value is changed, its summary (line of text below the
 * preference title) is updated to reflect the value. The summary is also
 * immediately updated upon calling this method. The exact display format is
 * dependent on the type of preference.
 *
 * @see #sBindPreferenceSummaryToValueListener
 */
private static void bindPreferenceSummaryToValue(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);

    // Trigger the listener immediately with the preference's
    // current value.
    final String key = preference.getKey();
    if (preference instanceof MultiSelectListPreference) {
        Set<String> summary = SharedPreferencesCompat.getStringSet(
                PreferenceManager.getDefaultSharedPreferences(preference.getContext()),
                key,
                new HashSet<>());
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, summary);
    } else if (preference instanceof ColorPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, ((ColorPreference) preference).getColor());
    } else if (preference instanceof SeekBarPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, ((SeekBarPreference) preference).getValue());
    } else {
        String value = PreferenceManager
                .getDefaultSharedPreferences(preference.getContext())
                .getString(key, "");
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value);
    }
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:34,代碼來源:SettingsFragment.java

示例2: updateLinesPreferenceSummary

import net.xpece.android.support.preference.MultiSelectListPreference; //導入依賴的package包/類
private void updateLinesPreferenceSummary(MultiSelectListPreference preference, Set<String> values) {
    List<String> sortedValues = new ArrayList<String>(values);
    Collections.sort(sortedValues);

    if (!values.isEmpty()) {
        CharSequence summary = getSelectedEntries(sortedValues, preference).toString();
        summary = summary.subSequence(1, summary.length() - 1);
        preference.setSummary(String.format(getString(R.string.frag_notif_summary_lines), summary));
    } else {
        preference.setSummary(getString(R.string.frag_notif_summary_no_lines));
    }

    Preference notifsDistServiceResumed = findPreference("pref_notifs_service_resumed");
    Preference notifsDistRingtone = findPreference("pref_notifs_ringtone");
    Preference notifsDistVibrate = findPreference("pref_notifs_vibrate");
    notifsDistServiceResumed.setEnabled(values.size() != 0);
    notifsDistRingtone.setEnabled(values.size() != 0);
    notifsDistVibrate.setEnabled(values.size() != 0);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:20,代碼來源:NotifPreferenceFragment.java

示例3: updateSourcesPreferenceSummary

import net.xpece.android.support.preference.MultiSelectListPreference; //導入依賴的package包/類
private void updateSourcesPreferenceSummary(MultiSelectListPreference preference, Set<String> values) {
    List<String> sortedValues = new ArrayList<String>(values);
    Collections.sort(sortedValues);

    if (!values.isEmpty()) {
        CharSequence summary = getSelectedEntries(sortedValues, preference).toString();
        summary = summary.subSequence(1, summary.length() - 1);
        preference.setSummary(String.format(getString(R.string.frag_notif_summary_sources), summary));
    } else {
        preference.setSummary(getString(R.string.frag_notif_summary_no_sources));
    }

    Preference notifsAnnRingtone = findPreference("pref_notifs_announcement_ringtone");
    Preference notifsAnnVibrate = findPreference("pref_notifs_announcement_vibrate");
    notifsAnnRingtone.setEnabled(values.size() != 0);
    notifsAnnVibrate.setEnabled(values.size() != 0);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:18,代碼來源:NotifPreferenceFragment.java

示例4: bindPreferenceSummaryToValue

import net.xpece.android.support.preference.MultiSelectListPreference; //導入依賴的package包/類
private static void bindPreferenceSummaryToValue(Preference preference) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);

    // Trigger the listener immediately with the preference's
    // current value.
    final String key = preference.getKey();
    if (preference instanceof MultiSelectListPreference) {
        Set<String> summary = SharedPreferencesCompat.getStringSet(
                PreferenceManager.getDefaultSharedPreferences(preference.getContext()),
                key, new HashSet<String>());
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, summary);
    } else if (preference instanceof SeekBarPreference) {
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, ((SeekBarPreference) preference).getValue());
    } else {
        String value = PreferenceManager
                .getDefaultSharedPreferences(preference.getContext())
                .getString(key, "");
        sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value);
    }
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:22,代碼來源:NotifPreferenceFragment.java

示例5: getSelectedEntries

import net.xpece.android.support.preference.MultiSelectListPreference; //導入依賴的package包/類
private List<CharSequence> getSelectedEntries(List<String> values, MultiSelectListPreference multilistPreference) {
    List<CharSequence> labels = new ArrayList<>();
    for (String value : values) {
        int index = multilistPreference.findIndexOfValue(value);
        if (index >= 0) {
            labels.add(multilistPreference.getEntries()[index]);
        }
    }
    return labels;
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:11,代碼來源:NotifPreferenceFragment.java

示例6: onPreferenceChange

import net.xpece.android.support.preference.MultiSelectListPreference; //導入依賴的package包/類
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof SeekBarPreference) {
        SeekBarPreference pref = (SeekBarPreference) preference;
        int progress = (int) value;
        pref.setInfo(progress + "%");
    } else if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else if (preference instanceof MultiSelectListPreference) {
        String summary = stringValue.trim().substring(1, stringValue.length() - 1); // strip []
        preference.setSummary(summary);
    } else if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value using RingtoneManager.
        if (TextUtils.isEmpty(stringValue)) {
            // Empty values correspond to 'silent' (no ringtone).
            preference.setSummary(R.string.frag_notif_summary_silent);
        } else {
            final Uri selectedUri = Uri.parse(stringValue);
            try {
                final Ringtone ringtone = RingtoneManager.getRingtone(
                        preference.getContext(), selectedUri);
                if (ringtone == null) {
                    // Clear the summary if there was a lookup error, i.e. does not exist.
                    preference.setSummary(null);
                } else {
                    // Set the summary to reflect the new ringtone display name.
                    final String name = ringtone.getTitle(preference.getContext());
                    preference.setSummary(name);
                }
            } catch (SecurityException ex) {
                // The user has selected a ringtone from external storage
                // and then revoked READ_EXTERNAL_STORAGE permission.
                // We have no way of guessing the ringtone title.
                // We'd have to store the title of selected ringtone in prefs as well.
                preference.setSummary("???");
            }
        }

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:57,代碼來源:NotifPreferenceFragment.java


注:本文中的net.xpece.android.support.preference.MultiSelectListPreference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。