当前位置: 首页>>代码示例>>Java>>正文


Java Preference.getKey方法代码示例

本文整理汇总了Java中android.support.v7.preference.Preference.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.getKey方法的具体用法?Java Preference.getKey怎么用?Java Preference.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.preference.Preference的用法示例。


在下文中一共展示了Preference.getKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPreferenceTreeClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
    switch (preference.getKey()) {
        case RESET_SETUP_WIZARD:
            LocalBroadcastUtils.send(activity, new Intent(ACTION_FLOAT_VIEW_SERVICE_STOP));
            intentGuideActivity(PAGE_WELCOME, MODE_NONE);
            break;
        case HISTORY:
            ActivityUtils.startActivity(activity, HistoryActivity.class);
            break;
        case ABOUT:
            ActivityUtils.startActivity(activity, AboutActivity.class);
            break;
    }
    return super.onPreferenceTreeClick(preference);
}
 
开发者ID:Omico,项目名称:CurrentActivity,代码行数:17,代码来源:SettingsFragment.java

示例2: setPreferenceSummary

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
        /* For list preferences, look up the correct display value in */
        /* the preference's 'entries' list (since they have separate labels/values). */
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:18,代码来源:SettingsFragment.java

示例3: bindPreferenceSummaryToValue

import android.support.v7.preference.Preference; //导入方法依赖的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

示例4: onPreferenceClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
    switch (preference.getKey()) {
        case PrefUtils.THEME:
            showThemeChooser();
            return true;
        case PrefUtils.LANGUAGE:
            showLanguageList();
            return true;
        case PrefUtils.LOGOUT:
            logout();
            return true;
        case PrefUtils.START_PAGE:
            showChooseStartPageDialog();
            return true;
    }
    return false;
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:19,代码来源:SettingsFragment.java

示例5: onPreferenceClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
	Intent activityIntent = new Intent(getActivity(), WebViewExtrasActivity.class);

	switch (preference.getKey()) {
		case "about":
			activityIntent.putExtra(WebViewExtrasActivity.EXTRA_ASSET_FILE, "about.html");
			break;
		case "help":
			activityIntent.putExtra(WebViewExtrasActivity.EXTRA_ASSET_FILE, "help.html");
			break;
	}

	startActivity(activityIntent);
	return true;
}
 
开发者ID:ashutoshgngwr,项目名称:10-bitClockWidget,代码行数:17,代码来源:ClockWidgetPreferenceFragment.java

示例6: bindPreferenceSummaryToValue

import android.support.v7.preference.Preference; //导入方法依赖的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

示例7: onPreferenceTreeClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
  switch (preference.getKey()) {
    case KEY_CLEAR_DISK_CACHE:
      onClearDiskCachePreferenceClicked();
      return true;
    case KEY_URI_OVERRIDE:
      onUriOverrideClicked();
      return true;
    default:
      return super.onPreferenceTreeClick(preference);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:SettingsFragment.java

示例8: onPreferenceChange

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
    switch (preference.getKey()) {
        case "dark_theme": {
            Colorful.config(getContext())
                    .dark(((boolean) o))
                    .apply();
            getActivity().recreate();
            break;
        }
        case "animations": {
            Media.setUseAnimations((boolean) o);
            break;
        }
        case "staggered": {
            Media.setStaggered((boolean) o);
        }
        case "primary" : {
            getActivity().recreate();
            break;
        }
        case "accent" : {
            getActivity().recreate();
            break;
        }

    }
    return true;
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:30,代码来源:SettingsActivity.java

示例9: onPreferenceChange

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
    boolean checked = (boolean) o;
    String key = preference.getKey();
    switch (key) {
        case KEY_FORCE_ENGLISH:
            if (!checked) {
                Utils.setLocale(Resources.getSystem().getConfiguration().locale.getLanguage(), getActivity());
            }
        case KEY_DARK_THEME:
            getActivity().finish();
            Intent intent = new Intent(getActivity(), MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            return true;
        case KEY_MATERIAL_ICON:
            Utils.setStartActivity(checked, getActivity());
            return true;
        case KEY_HIDE_BANNER:
            if (!Utils.DONATED) {
                ViewUtils.dialogDonate(getActivity()).show();
                return false;
            }
            return true;
        default:
            if (key.equals(KEY_SECTIONS_ICON) || key.endsWith("_enabled")) {
                if (key.equals(KEY_SECTIONS_ICON) && !Utils.DONATED) {
                    ViewUtils.dialogDonate(getActivity()).show();
                    return false;
                }
                Prefs.saveBoolean(key, checked, getActivity());
                ((NavigationActivity) getActivity()).appendFragments();
                return true;
            }
            break;
    }
    return false;
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:39,代码来源:SettingsFragment.java

示例10: onPreferenceDisplayDialog

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceDisplayDialog(PreferenceFragmentCompat preferenceFragmentCompat, Preference preference) {
    final String key = preference.getKey();
    DialogFragment f;
    if (preference instanceof ColorPreference) {
        f = XpColorPreferenceDialogFragment.newInstance(key);
    } else {
        return false;
    }

    f.setTargetFragment(preferenceFragmentCompat, 0);
    f.show(this.getSupportFragmentManager(), key);
    return true;
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:15,代码来源:SettingsActivity.java

示例11: onPreferenceChange

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    switch (preference.getKey()) {
        case ENABLE_FLOAT_WINDOW:
            if (Settings.getString(Settings.Mode.SELECTION, Settings.Mode.NONE).equals(Settings.Mode.NONE)) {
                ActivityCollector.getActivityCollector().removeAllActivity();
                intentGuideActivity(PAGE_WELCOME, MODE_NONE);
            } else if ((boolean) newValue) {
                activity.startService(new Intent(activity, FloatViewService.class).setAction(ACTION_FLOAT_VIEW_SERVICE_START));
            } else {
                LocalBroadcastUtils.send(activity, new Intent(ACTION_FLOAT_VIEW_SERVICE_STOP));
            }
            break;
        case BOOT_COMPLETED:
            Settings.putBoolean(BOOT_COMPLETED, (boolean) newValue);
            break;
        case OPEN_MAIN_ACTIVITY_WHEN_QUICK_START_OR_QUICK_STOP:
            Settings.putBoolean(OPEN_MAIN_ACTIVITY_WHEN_QUICK_START_OR_QUICK_STOP, (boolean) newValue);
            break;
        case GESTURE_CLICK:
            Settings.putString(GESTURE_CLICK, (String) newValue);
            break;
        case GESTURE_LONG_PRESS:
            Settings.putString(GESTURE_LONG_PRESS, (String) newValue);
            break;
        case WORKING_MODE:
            switch ((String) newValue) {
                case Settings.Mode.ROOT:
                    intentGuideActivity(PAGE_GETTING_MODE_PERMISSION, MODE_ROOT);
                    break;
                case Settings.Mode.ACCESSIBILITY_SERVICE:
                    intentGuideActivity(PAGE_GETTING_MODE_PERMISSION, MODE_ACCESSIBILITY_SERVICE);
                    break;
                case Settings.Mode.NONE:
                    intentGuideActivity(PAGE_WELCOME, MODE_NONE);
                    break;
            }
            break;
    }
    return true;
}
 
开发者ID:Omico,项目名称:CurrentActivity,代码行数:42,代码来源:SettingsFragment.java

示例12: onPreferenceTreeClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
    SettingsHelper settingsHelper = new SettingsHelper(getContext());
    String key = preference.getKey();
    if (key.equals(getString(R.string.about_dialog))) {
        DialogHelper dialogHelper = new DialogHelper(getContext());
        dialogHelper.buildAboutDialog();
    }

    if (key.equals((getString(R.string.pref_recycler_left_color)))) {
        settingsHelper.setColorForViews(SettingsHelper.KEY_LEFT_LIST);
        settingsHelper.setPref(SettingsHelper.PREF_LEFT_LIST);
    }
    if (key.equals(getString(R.string.pref_recycler_right_color))) {
        settingsHelper.setColorForViews(SettingsHelper.KEY_RIGHT_LIST);
        settingsHelper.setPref(SettingsHelper.PREF_RIGHT_LIST);
    }
    if (key.equals((getString(R.string.pref_search_bar_color)))) {
        settingsHelper.setColorForViews(SettingsHelper.KEY_SEARCHBAR);
        settingsHelper.setPref(SettingsHelper.PREF_SEARCHBAR);
    }
    if (key.equals((getString(R.string.pref_search_list_color)))) {
        settingsHelper.setColorForViews(SettingsHelper.KEY_SEARCHLIST);
        settingsHelper.setPref(SettingsHelper.PREF_SEARCHLIST);
    }

    if (key.equals((getString(R.string.pref_menu_fragment_color)))) {
        settingsHelper.setColorForViews(SettingsHelper.KEY_MENU);
        settingsHelper.setPref(SettingsHelper.PREF_MENU);
    }

    if (key.equals((getString(R.string.seekbar_size_main_elems)))) {
        settingsHelper.setSeekbarEndpointValue(SettingsHelper.KEY_SEEKBAR_SIZE_MAIN,
                getString(R.string.seekbar_main_title), 400);
        settingsHelper.setPref(SettingsHelper.PREF_SEEKBAR_SIZE_MAIN);
    }

    if (key.equals((getString(R.string.seekbar_alpha_main_elems)))) {
        settingsHelper.setSeekbarEndpointValue(SettingsHelper.KEY_SEEKBAR_ALPHA_MAIN,
                getString(R.string.seekbar_main_title), 10);
        settingsHelper.setPref(SettingsHelper.PREF_SEEKBAR_ALPHA_MAIN);
    }

    if (key.equals((getString(R.string.seekbar_alpha_search_button)))) {
        settingsHelper.setSeekbarEndpointValue(SettingsHelper.KEY_SEEKBAR_ALPHA_SEARCH_BUTTON,
                getString(R.string.seekbar_main_title), 10);
        settingsHelper.setPref(SettingsHelper.PREF_SEEKBAR_ALPHA_SEARCH_BUTTON);
    }

    return super.onPreferenceTreeClick(preference);

}
 
开发者ID:Existentio,项目名称:OddLauncher,代码行数:53,代码来源:SettingsFragment.java

示例13: onPreferenceChange

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
    boolean checked = (boolean) o;
    String key = preference.getKey();
    switch (key) {
        case KEY_UPDATE_NOTIFICATION:
            Prefs.saveBoolean("show_update_notif", checked, getActivity());
            return true;
        case KEY_FORCE_ENGLISH:
            if (!checked) {
                Utils.setLocale(Resources.getSystem().getConfiguration().locale.getLanguage(), getActivity());
            }
        case KEY_DARK_THEME:
            getActivity().finish();
            Intent intent = new Intent(getActivity(), MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            return true;
        /*
        case KEY_MATERIAL_ICON:
            Utils.setStartActivity(checked, getActivity());
            return true;
        */
        case KEY_HIDE_BANNER:
            if (!Utils.DONATED) {
                ViewUtils.dialogDonate(getActivity()).show();
                return false;
            }
            return true;
        default:
            if (key.equals(KEY_SECTIONS_ICON) || key.endsWith("_enabled")) {
                if (key.equals(KEY_SECTIONS_ICON) && !Utils.DONATED) {
                    ViewUtils.dialogDonate(getActivity()).show();
                    return false;
                }
                Prefs.saveBoolean(key, checked, getActivity());
                ((NavigationActivity) getActivity()).appendFragments();
                return true;
            }
            break;
    }
    return false;
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:44,代码来源:SettingsFragment.java

示例14: onPreferenceClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
    public boolean onPreferenceClick(Preference preference) {
        switch (preference.getKey()) {
//            case PREFERENCE_ICONS_NOTE:
//                break;
            case PREFERENCE_ICONS_AUTHOR:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_icons_summary_author));
                break;
            case PREFERENCE_ICONS_CONTACT:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_icons_summary_contact));
                break;
            case PREFERENCE_ICONS_TODO_1:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_icons_summary_todo_1));
                break;
            case PREFERENCE_ICONS_COPYRIGHT:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_icons_summary_copyright));
                break;
            case PREFERENCE_SUPPORT_DONATE:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_support_summary_donate));
                break;
            case PREFERENCE_SUPPORT_TODO_1:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_support_summary_todo_1));
                break;
            case PREFERENCE_SUPPORT_SPONSORS:
                showDonate();
                break;
//            case PREFERENCE_APP_APP:
//                executeCode(preference.getTitle().toString(), preference.getSummary().toString());
//                break;
            case PREFERENCE_APP_TODO_1:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_app_summary_todo_1));
                break;
            case PREFERENCE_APP_DASHBOARD:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_app_summary_dashboard));
                break;
            case PREFERENCE_DEV_STATS:
                enterStats();
                break;
            case PREFERENCE_DEV_QUERY:
                executeCode(preference.getTitle().toString(),
                        getString(R.string.preference_dev_summary_query));
                break;
        }
        return true;
    }
 
开发者ID:homeii,项目名称:GxIconDIY,代码行数:54,代码来源:AboutFragment.java

示例15: onPreferenceTreeClick

import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
    View preferenceView = getListView().findViewHolderForAdapterPosition(preference.getOrder()).itemView;

    switch (preference.getKey()) {
        case Common.PREF_LOCATION_UPDATE_INTERVAL:
            ListPopupWindow listPopupWindow = new ListPopupWindow(getActivity());
            listPopupWindow.setAnchorView(preferenceView);
            listPopupWindow.setAdapter(new ArrayAdapter<>(getActivity(), android.support.design.R.layout.support_simple_spinner_dropdown_item, getResources().getStringArray(R.array.location_update_interval_summaries)));
            listPopupWindow.setContentWidth(getResources().getDimensionPixelSize(R.dimen.popup_window_width));
            listPopupWindow.setHorizontalOffset(getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin));
            listPopupWindow.setOnItemClickListener((parent, view, position, id) -> {
                Log.d("Selected", String.valueOf(position));
                prefs.edit().putInt(Common.PREF_LOCATION_UPDATE_INTERVAL,
                        getResources().getIntArray(R.array.location_update_interval_values)[position]).apply();
                listPopupWindow.dismiss();
                updatePreferenceSummaries();
                updateLocationTracker();
            });
            listPopupWindow.show();
            return true;
        case Common.PREF_RESET_HOST_MISMATCHES:
            prefs.edit().remove(Common.PREF_ALLOWED_HOST_MISMATCHES_KEY).apply();
            Toast.makeText(getActivity(), R.string.toast_ignored_ssl_mismatches_cleared, Toast.LENGTH_SHORT).show();
            updatePreferenceSummaries();
            return true;
        case Common.HELP_TRANSLATE:
            CustomTabsSession session = ((SettingsActivity) getActivity()).getCustomTabsSession();
            if (session != null) {
                @SuppressWarnings("deprecation") CustomTabsIntent intent = new CustomTabsIntent.Builder(session)
                        .setShowTitle(true)
                        .enableUrlBarHiding()
                        .setToolbarColor(getResources().getColor(R.color.primary))
                        .build();
                intent.launchUrl(getActivity(), Uri.parse(Common.CROWDIN_URL));
            }
            return true;
        default:
            return super.onPreferenceTreeClick(preference);
    }
}
 
开发者ID:Maxr1998,项目名称:home-assistant-Android,代码行数:42,代码来源:SettingsActivity.java


注:本文中的android.support.v7.preference.Preference.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。