Java Code Examples for android.preference.PreferenceScreen#removeAll()
The following examples show how to use
android.preference.PreferenceScreen#removeAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberGroups.java From callmeter with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @Override protected void onResume() { super.onResume(); PreferenceScreen ps = (PreferenceScreen) findPreference("container"); ps.removeAll(); Cursor c = getContentResolver().query(DataProvider.NumbersGroup.CONTENT_URI, DataProvider.NumbersGroup.PROJECTION, null, null, null); if (c.moveToFirst()) { do { Preference p = new Preference(this); p.setPersistent(false); p.setTitle(c.getString(DataProvider.NumbersGroup.INDEX_NAME)); p.setKey("group_" + c.getInt(DataProvider.NumbersGroup.INDEX_ID)); p.setOnPreferenceClickListener(this); ps.addPreference(p); } while (c.moveToNext()); } c.close(); }
Example 2
Source File: HourGroups.java From callmeter with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("deprecation") @Override protected void onResume() { super.onResume(); PreferenceScreen ps = (PreferenceScreen) findPreference("container"); ps.removeAll(); Cursor c = getContentResolver().query(DataProvider.HoursGroup.CONTENT_URI, DataProvider.HoursGroup.PROJECTION, null, null, null); if (c.moveToFirst()) { do { Preference p = new Preference(this); p.setPersistent(false); p.setTitle(c.getString(DataProvider.HoursGroup.INDEX_NAME)); p.setKey("group_" + c.getInt(DataProvider.HoursGroup.INDEX_ID)); p.setOnPreferenceClickListener(this); ps.addPreference(p); } while (c.moveToNext()); } c.close(); }
Example 3
Source File: SettingsFragment.java From Linphone4Android with GNU General Public License v3.0 | 5 votes |
private void emptyAndHidePreferenceScreen(int preferenceKey) { Preference preference = findPreference(getString(preferenceKey)); if (!(preference instanceof PreferenceScreen)) return; PreferenceScreen preferenceScreen = (PreferenceScreen) preference; preferenceScreen.removeAll(); hidePreference(preferenceScreen); }
Example 4
Source File: HourGroupEdit.java From callmeter with GNU General Public License v3.0 | 5 votes |
/** * Reload numbers. */ @SuppressWarnings("deprecation") private void reload() { Cursor c = getContentResolver().query( ContentUris.withAppendedId(DataProvider.HoursGroup.CONTENT_URI, gid), DataProvider.HoursGroup.PROJECTION, null, null, null); if (c.moveToFirst()) { CallMeter.setActivitySubtitle(this, c.getString(DataProvider.HoursGroup.INDEX_NAME)); } c.close(); PreferenceScreen ps = (PreferenceScreen) findPreference("container"); ps.removeAll(); c = getContentResolver().query( ContentUris.withAppendedId(DataProvider.Hours.GROUP_URI, gid), DataProvider.Hours.PROJECTION, null, null, DataProvider.Hours.DAY + ", " + DataProvider.Hours.HOUR); if (c.moveToFirst()) { do { Preference p = new Preference(this); p.setPersistent(false); final int day = c.getInt(DataProvider.Hours.INDEX_DAY); final int hour = c.getInt(DataProvider.Hours.INDEX_HOUR); p.setTitle(resDays[day] + ": " + resHours[hour]); p.setKey("item_" + c.getInt(DataProvider.Hours.INDEX_ID)); p.setOnPreferenceClickListener(this); ps.addPreference(p); } while (c.moveToNext()); } c.close(); }
Example 5
Source File: Plans.java From callmeter with GNU General Public License v3.0 | 5 votes |
/** * Reload plans from ContentProvider. */ @SuppressWarnings("deprecation") private void reload() { PreferenceScreen ps = (PreferenceScreen) findPreference("container"); ps.removeAll(); Cursor c = getContentResolver().query(DataProvider.Plans.CONTENT_URI, DataProvider.Plans.PROJECTION, null, null, null); if (c.moveToFirst()) { String[] types = getResources().getStringArray(R.array.plans_type); do { UpDownPreference p = new UpDownPreference(this, this); p.setKey("group_" + c.getInt(DataProvider.Plans.INDEX_ID)); p.setTitle(c.getString(DataProvider.Plans.INDEX_NAME)); int t = c.getInt(DataProvider.Plans.INDEX_TYPE); String hint; if (t >= 0 && t < types.length) { hint = types[t]; } else { hint = "???"; } String s = c.getString(DataProvider.Plans.INDEX_MERGED_PLANS); if (s != null && s.length() > 0) { hint += ", " + getString(R.string.merge_plans_); } p.setSummary(hint); p.setOnPreferenceClickListener(this); ps.addPreference(p); } while (c.moveToNext()); } c.close(); }
Example 6
Source File: NumberGroupEdit.java From callmeter with GNU General Public License v3.0 | 5 votes |
/** * Reload numbers. */ @SuppressWarnings("deprecation") private void reload() { Cursor c = getContentResolver().query( ContentUris.withAppendedId(DataProvider.NumbersGroup.CONTENT_URI, gid), DataProvider.NumbersGroup.PROJECTION, null, null, null); if (c.moveToFirst()) { CallMeter.setActivitySubtitle(this, c.getString(DataProvider.NumbersGroup.INDEX_NAME)); } c.close(); PreferenceScreen ps = (PreferenceScreen) findPreference("container"); ps.removeAll(); c = getContentResolver().query( ContentUris.withAppendedId(DataProvider.Numbers.GROUP_URI, gid), DataProvider.Numbers.PROJECTION, null, null, DataProvider.Numbers.NUMBER); if (c.moveToFirst()) { do { Preference p = new Preference(this); p.setPersistent(false); String number = c.getString(DataProvider.Numbers.INDEX_NUMBER); p.setTitle(number); p.setKey("item_" + c.getInt(DataProvider.Numbers.INDEX_ID)); p.setOnPreferenceClickListener(this); ps.addPreference(p); if (number != null && !number.contains("%") && CallMeter.hasPermission(this, Manifest.permission.READ_CONTACTS)) { String name = CWRAPPER.getNameForNumber(getContentResolver(), number); if (!TextUtils.isEmpty(name)) { p.setSummary(name); } } } while (c.moveToNext()); } c.close(); }
Example 7
Source File: Rules.java From callmeter with GNU General Public License v3.0 | 4 votes |
/** * Reload rules from ContentProvider. */ @SuppressWarnings("deprecation") private void reload() { PreferenceScreen ps = (PreferenceScreen) findPreference("container"); ps.removeAll(); Cursor c = getContentResolver().query(DataProvider.Rules.CONTENT_URI, DataProvider.Rules.PROJECTION, null, null, null); if (c.moveToFirst()) { String[] types = getResources().getStringArray(R.array.rules_type); do { UpDownPreference p = new UpDownPreference(this, this); p.setKey("group_" + c.getInt(DataProvider.Rules.INDEX_ID)); p.setTitle(c.getString(DataProvider.Rules.INDEX_NAME)); String hint = ""; final int t = c.getInt(DataProvider.Rules.INDEX_WHAT); if (t >= 0 && t < types.length) { hint += types[t]; } else { hint += "???"; } int i = c.getInt(DataProvider.Rules.INDEX_LIMIT_NOT_REACHED); if (i == 1) { hint += " & " + getString(R.string.limitnotreached_); } i = c.getInt(DataProvider.Rules.INDEX_DIRECTION); if (i >= 0 && i < DataProvider.Rules.NO_MATTER) { String[] strs; final Resources r = getResources(); if (t == DataProvider.TYPE_SMS) { strs = r.getStringArray(R.array.direction_sms); } else if (t == DataProvider.TYPE_MMS) { strs = r.getStringArray(R.array.direction_mms); } else if (t == DataProvider.TYPE_DATA) { strs = r.getStringArray(R.array.direction_data); } else { strs = r.getStringArray(R.array.direction_calls); } hint += " & " + strs[i]; } i = c.getInt(DataProvider.Rules.INDEX_ROAMED); if (i == 0) { hint += " & " + getString(R.string.roamed_); } else if (i == 1) { hint += " & \u00AC " + getString(R.string.roamed_); } String s = c.getString(DataProvider.Rules.INDEX_INHOURS_ID); if (s != null && !s.equals("-1")) { hint += " & " + getString(R.string.hourgroup_); } s = c.getString(DataProvider.Rules.INDEX_EXHOURS_ID); if (s != null && !s.equals("-1")) { hint += " & " + getString(R.string.exhourgroup_); } s = c.getString(DataProvider.Rules.INDEX_INNUMBERS_ID); if (s != null && !s.equals("-1")) { hint += " & " + getString(R.string.numbergroup_); } s = c.getString(DataProvider.Rules.INDEX_EXNUMBERS_ID); if (s != null && !s.equals("-1")) { hint += " & " + getString(R.string.exnumbergroup_); } p.setSummary(hint); p.setOnPreferenceClickListener(this); ps.addPreference(p); } while (c.moveToNext()); } c.close(); }