List of usage examples for android.preference Preference setLayoutResource
public void setLayoutResource(@LayoutRes int layoutResId)
From source file:com.bluros.updater.UpdatesSettings.java
private void refreshPreferences(LinkedList<UpdateInfo> updates) { if (mUpdatesList == null) { return;/*from w w w. ja v a 2 s . co m*/ } // Clear the list mUpdatesList.removeAll(); // Convert the installed version name to the associated filename String installedZip = "cm-" + Utils.getInstalledVersion() + ".zip"; // Determine installed incremental String installedIncremental = Utils.getIncremental(); // Convert LinkedList to HashMap, keyed on filename. HashMap<String, UpdateInfo> updatesMap = new HashMap<String, UpdateInfo>(); for (UpdateInfo ui : updates) { updatesMap.put(ui.getFileName(), ui); } // Add the updates for (UpdateInfo ui : updates) { // Skip if this is an incremental if (ui.isIncremental()) { continue; } // Check to see if there is an incremental boolean haveIncremental = false; String incrementalFile = "incremental-" + installedIncremental + "-" + ui.getIncremental() + ".zip"; if (updatesMap.containsKey(incrementalFile)) { haveIncremental = true; ui.setFileName(incrementalFile); } // Determine the preference style and create the preference boolean isDownloading = ui.getFileName().equals(mDownloadFileName); int style; if (isDownloading) { // In progress download style = UpdatePreference.STYLE_DOWNLOADING; } else if (haveIncremental) { style = UpdatePreference.STYLE_DOWNLOADED; } else if (ui.getFileName().equals(installedZip)) { // This is the currently installed version style = UpdatePreference.STYLE_INSTALLED; } else if (ui.getDownloadUrl() != null) { style = UpdatePreference.STYLE_NEW; } else { style = UpdatePreference.STYLE_DOWNLOADED; } UpdatePreference up = new UpdatePreference(this, ui, style); up.setOnActionListener(this); up.setKey(ui.getFileName()); // If we have an in progress download, link the preference if (isDownloading) { mDownloadingPreference = up; up.setOnReadyListener(this); mDownloading = true; } // Add to the list mUpdatesList.addPreference(up); } // If no updates are in the list, show the default message if (mUpdatesList.getPreferenceCount() == 0) { Preference pref = new Preference(this); pref.setLayoutResource(R.layout.preference_empty_list); if (!Utils.hasLeanback(this)) { pref.setTitle(R.string.no_available_updates_intro); } else { pref.setTitle(R.string.no_available_updates_intro_tv); } pref.setEnabled(false); mUpdatesList.addPreference(pref); } }
From source file:org.linphone.SettingsFragment.java
private void hidePreference(Preference preference) { preference.setLayoutResource(R.layout.hidden); }