android.support.v7.preference.Preference.getContext()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中android.support.v7.preference.Preference.getContext()方法的一些代码示例,展示了Preference.getContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Preference.getContext()方法的具体详情如下:
包路径:android.support.v7.preference.Preference
类名称:Preference
方法名:getContext

Preference.getContext介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipe

@Override
public boolean onPreferenceTreeClick(Preference preference) {
  if (preference.getKey().equals(thumbnailLoadToggleKey)) {
    final ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.stop();
    imageLoader.clearDiskCache();
    imageLoader.clearMemoryCache();
    imageLoader.resume();
    Toast.makeText(preference.getContext(), R.string.thumbnail_cache_wipe_complete_notice,
        Toast.LENGTH_SHORT).show();
  }
  return super.onPreferenceTreeClick(preference);
}

代码示例来源:origin: TeamNewPipe/NewPipe

if (preference.getKey().equals(cacheWipeKey)) {
  InfoCache.getInstance().clearCache();
  Toast.makeText(preference.getContext(), R.string.metadata_cache_wipe_complete_notice,
      Toast.LENGTH_SHORT).show();

代码示例来源:origin: consp1racy/android-support-preference

@Override
  public boolean onLongClick(@NonNull Preference preference, @NonNull View view) {
    final Toast toast = Toast.makeText(preference.getContext(), "This showcases long click listeners on preferences.", Toast.LENGTH_SHORT);
    toast.show();
    return true;
  }
}

代码示例来源:origin: consp1racy/android-support-preference

@NonNull
public Context getContext() {
  return getPreference().getContext();
}

代码示例来源:origin: Ashish-Bansal/OneTapVideoDownload

public static Boolean getBooleanPreferenceValue(Preference preference) {
  return android.support.v7.preference.PreferenceManager
      .getDefaultSharedPreferences(preference.getContext())
      .getBoolean(preference.getKey(), true);
}

代码示例来源:origin: Ashish-Bansal/OneTapVideoDownload

public static String getStringPreferenceValue(Preference preference) {
  return android.support.v7.preference.PreferenceManager
      .getDefaultSharedPreferences(preference.getContext())
      .getString(preference.getKey(), "");
}

代码示例来源:origin: Ashish-Bansal/OneTapVideoDownload

public static Integer getIntegerPreferenceValue(Preference preference) {
  return android.support.v7.preference.PreferenceManager
      .getDefaultSharedPreferences(preference.getContext())
      .getInt(preference.getKey(), -1);
}

代码示例来源:origin: Calsign/APDE

private static void bindPreferenceSummaryToValue(Preference preference) {
  //Don't bind the preference if it doesn't appear in this fragment
  if(preference != null) {
    // Set the listener to watch for value changes.
    preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
    
    // Trigger the listener immediately with the preference's
    // current value.
    sBindPreferenceSummaryToValueListener.onPreferenceChange(
        preference,
        PreferenceManager.getDefaultSharedPreferences(
            preference.getContext()).getString(preference.getKey(), ""));
  }
}

代码示例来源:origin: consp1racy/android-support-preference

static void onCreatePreference(final @NonNull Preference preference, @Nullable final AttributeSet attrs) {
  final int defStyleAttr = getDefStyleAttr(preference);
  if (!(preference instanceof CustomIconPreference)) {
    final PreferenceIconHelper iconHelper = new PreferenceIconHelper(preference);
    iconHelper.loadFromAttributes(attrs, defStyleAttr, 0);
    PREFERENCE_ICON_HELPERS.put(preference, iconHelper);
  }
  if (preference instanceof DialogPreference && !(preference instanceof CustomDialogIconPreference)) {
    DialogPreference dialogPreference = (DialogPreference) preference;
    final DialogPreferenceIconHelper iconHelper = new DialogPreferenceIconHelper(dialogPreference);
    iconHelper.loadFromAttributes(attrs, defStyleAttr, 0);
    PREFERENCE_DIALOG_ICON_HELPERS.put(dialogPreference, iconHelper);
  }
  if (!(preference instanceof ColorableTextPreference)) {
    final PreferenceTextHelper textHelper = new PreferenceTextHelper();
    textHelper.init(preference.getContext(), attrs, defStyleAttr, 0);
    PREFERENCE_TEXT_HELPERS.put(preference, textHelper);
  }
}

代码示例来源:origin: Ashish-Bansal/OneTapVideoDownload

public static void updatePreferenceSummary(Preference preference) {
  if (preference.getKey().equals("pref_download_location")) {
    bindPreferenceSummaryToValueListener.onPreferenceChange(preference,
        CheckPreferences.getDownloadLocation(preference.getContext()));
  } else if (preference instanceof SwitchPreference) {
    bindPreferenceSummaryToValueListener.onPreferenceChange(preference,
        CheckPreferences.getBooleanPreferenceValue(preference));
  } else {
    bindPreferenceSummaryToValueListener.onPreferenceChange(preference,
        CheckPreferences.getStringPreferenceValue(preference));
  }
}

代码示例来源:origin: consp1racy/android-support-preference

final Context context = preference.getContext();
final Uri selectedUri = Uri.parse(stringValue);
final SafeRingtone ringtone = SafeRingtone.obtain(context, selectedUri);
Toast.makeText(preference.getContext(), R.string.try_again, Toast.LENGTH_SHORT).show();

代码示例来源:origin: consp1racy/android-support-preference

if (preference instanceof MultiSelectListPreference) {
  Set<String> summary = XpSharedPreferences.getStringSet(
      PreferenceManager.getDefaultSharedPreferences(preference.getContext()),
      key,
      new HashSet<String>());
} else {
  String value = PreferenceManager
      .getDefaultSharedPreferences(preference.getContext())
      .getString(key, "");
  sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, value);

相关文章