当前位置: 首页>>代码示例>>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;未经允许,请勿转载。