當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。