android.database.CursorIndexOutOfBoundsException#android.support.v7.preference.Preference源码实例Demo

下面列出了android.database.CursorIndexOutOfBoundsException#android.support.v7.preference.Preference 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Focus   文件: BasePreferenceFragmentCompat.java
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
                }
            }
        }
    };
}
 
源代码2 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
private void tintPrefIconsRecursive(PreferenceGroup prefGroup, @ColorInt int iconColor) {
    if (prefGroup != null && isAdded()) {
        int prefCount = prefGroup.getPreferenceCount();
        for (int i = 0; i < prefCount; i++) {
            Preference pref = prefGroup.getPreference(i);
            if (pref != null) {
                if (isAllowedToTint(pref)) {
                    pref.setIcon(_cu.tintDrawable(pref.getIcon(), iconColor));
                }
                if (pref instanceof PreferenceGroup) {
                    tintPrefIconsRecursive((PreferenceGroup) pref, iconColor);
                }
            }
        }
    }
}
 
源代码4 项目: octoandroid   文件: SettingsFragment.java
@Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        mWasPrefChanged = true;
//        String stringValue = newValue.toString();
//
//        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);
//        }
        return true;
    }
 
源代码5 项目: sleep-cycle-alarm   文件: SettingsFragment.java
@Override
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
    return new PreferenceGroupAdapter(preferenceScreen) {
        @SuppressLint("RestrictedApi")
        @Override
        public void onBindViewHolder(PreferenceViewHolder holder, int position) {
            super.onBindViewHolder(holder, position);
            Preference preference = getItem(position);
            if (preference instanceof PreferenceCategory)
                setZeroPaddingToLayoutChildren(holder.itemView);
            else {
                View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
                if (iconFrame != null) {
                    iconFrame.setVisibility(preference.getIcon() == null
                            ? View.GONE
                            : View.VISIBLE);
                }
            }
        }
    };
}
 
private void updateContent() {
    GcmPrefs prefs = GcmPrefs.get(getContext());
    for (String pref : HEARTBEAT_PREFS) {
        Preference preference = findPreference(pref);
        int state = prefs.getNetworkValue(pref);
        if (state == 0) {
            int heartbeat = prefs.getHeartbeatMsFor(preference.getKey(), true);
            if (heartbeat == 0) {
                preference.setSummary("ON / Automatic");
            } else {
                preference.setSummary("ON / Automatic: " + getHeartbeatString(heartbeat));
            }
        } else if (state == -1) {
            preference.setSummary("OFF");
        } else {
            preference.setSummary("ON / Manual: " + getHeartbeatString(state * 60000));
        }
    }
}
 
源代码7 项目: FastAccess   文件: SettingsFragmentView.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    setDivider(ActivityCompat.getDrawable(getActivity(), R.drawable.list_divider));
    setDividerHeight(1);
    PreferenceGroupAdapter adapter = (PreferenceGroupAdapter) getListView().getAdapter();
    for (int i = 0; i < getListView().getAdapter().getItemCount(); i++) {//lazy global setOnPreferenceClickListener
        Preference preference = adapter.getItem(i);
        if (preference != null && !InputHelper.isEmpty(preference.getKey())) {
            if (preference.getKey().equalsIgnoreCase("version")) {
                preference.setSummary(BuildConfig.VERSION_NAME);
            } else if (!(preference instanceof SwitchPreference) && !(preference instanceof ListPreference)) {
                preference.setOnPreferenceClickListener(this);
            }
        }
    }
}
 
源代码8 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onCreatePreferences(Bundle bundle, String s) {

    // Add visualizer preferences, defined in the XML file in res->xml->pref_visualizer
    addPreferencesFromResource(R.xml.pref_visualizer);

    // COMPLETED (3) Get the preference screen, get the number of preferences and iterate through
    // all of the preferences if it is not a checkbox preference, call the setSummary method
    // passing in a preference and the value of the preference
    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    int count = preferenceScreen.getPreferenceCount();

    for (int i = 0; i < count; i++) {
        Preference pref = preferenceScreen.getPreference(i);

        if (!(pref instanceof CheckBoxPreference)) {
            setPreferenceSummary(pref, sharedPreferences.getString(pref.getKey(), ""));
        }
    }
}
 
源代码9 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码10 项目: MaterialWeCenter   文件: SettingsFragment.java
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // 显示版本号
    Preference version = findPreference("version");
    version.setSummary(BuildConfig.VERSION_NAME);
    // 打开GitHub项目地址
    Preference github = findPreference("github_repo");
    github.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(getString(R.string.github_url)));
            startActivity(intent);
            return false;
        }
    });
}
 
源代码11 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
源代码12 项目: android_gisapp   文件: SettingsFragment.java
public static void initializeShowStatusPanel(final ListPreference listPreference)
{
    listPreference.setSummary(listPreference.getEntry());

    listPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
    {
        @Override
        public boolean onPreferenceChange(
                Preference preference,
                Object newValue)
        {
            preference.setSummary(listPreference.getEntries()[listPreference.findIndexOfValue(
                    (String) newValue)]);

            return true;
        }
    });
}
 
源代码13 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码14 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码15 项目: haystack   文件: DevelopmentSettings.java
@DexWrap
@Override
/*<7.0*/ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
//>7.0// public boolean onPreferenceTreeClick(Preference preference) {
    if (Utils.isMonkeyRunning()) {
        return false;
    }
    if (mFakeSignatureGlobalPreference != null) {
        if (preference == mFakeSignatureGlobalPreference) {
            writeFakeSignatureGlobalSettingWithWarningDialog(mFakeSignatureGlobalPreference.isChecked());
            return false;
        }
    }
    /*<7.0*/ return onPreferenceTreeClick(preferenceScreen, preference);
    //>7.0// return onPreferenceTreeClick(preference);
}
 
源代码16 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
        SunshineSyncUtils.startImmediateSync(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
源代码17 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码18 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码19 项目: Silence   文件: ChatsPreferenceFragment.java
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
  if (newValue == null || ((String)newValue).trim().length() == 0) {
    return false;
  }

  int value;
  try {
    value = Integer.parseInt((String)newValue);
  } catch (NumberFormatException nfe) {
    Log.w(TAG, nfe);
    return false;
  }

  if (value < 1) {
    return false;
  }

  preference.setSummary(getResources().getQuantityString(R.plurals.ApplicationPreferencesActivity_messages_per_conversation, value, value));
  return true;
}
 
源代码20 项目: Silence   文件: RecipientPreferenceActivity.java
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
  final int           value         = (Integer) newValue;
  final MaterialColor selectedColor = MaterialColors.CONVERSATION_PALETTE.getByColor(getActivity(), value);
  final MaterialColor currentColor  = recipients.getColor();

  if (selectedColor == null) return true;

  if (preference.isEnabled() && !currentColor.equals(selectedColor)) {
    recipients.setColor(selectedColor);

    new AsyncTask<Void, Void, Void>() {
      @Override
      protected Void doInBackground(Void... params) {
        DatabaseFactory.getRecipientPreferenceDatabase(getActivity())
                       .setColor(recipients, selectedColor);
        return null;
      }
    }.execute();
  }
  return true;
}
 
源代码21 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    // Add 'general' preferences, defined in the XML file
    addPreferencesFromResource(R.xml.pref_general);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
}
 
源代码22 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
        SunshineSyncUtils.startImmediateSync(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
源代码23 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
        SunshineSyncUtils.startImmediateSync(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
源代码24 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    // Add 'general' preferences, defined in the XML file
    addPreferencesFromResource(R.xml.pref_general);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
}
 
源代码25 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码26 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码27 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    Activity activity = getActivity();

    if (key.equals(getString(R.string.pref_location_key))) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SunshinePreferences.resetLocationCoordinates(activity);
    } else if (key.equals(getString(R.string.pref_units_key))) {
        // units have changed. update lists of weather entries accordingly
        activity.getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
    Preference preference = findPreference(key);
    if (null != preference) {
        if (!(preference instanceof CheckBoxPreference)) {
            setPreferenceSummary(preference, sharedPreferences.getString(key, ""));
        }
    }
}
 
源代码28 项目: android-dev-challenge   文件: SettingsFragment.java
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    // Add 'general' preferences, defined in the XML file
    addPreferencesFromResource(R.xml.pref_general);

    SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
    PreferenceScreen prefScreen = getPreferenceScreen();
    int count = prefScreen.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        Preference p = prefScreen.getPreference(i);
        if (!(p instanceof CheckBoxPreference)) {
            String value = sharedPreferences.getString(p.getKey(), "");
            setPreferenceSummary(p, value);
        }
    }
}
 
源代码29 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}
 
源代码30 项目: android-dev-challenge   文件: SettingsFragment.java
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();

    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);
    }
}