зеркало из https://github.com/mozilla/gecko-dev.git
Bug 968170 - Factor out method to replace a PanelConfig in a list (r=margaret)
This commit is contained in:
Родитель
61c41506af
Коммит
32b5207f11
|
@ -125,6 +125,22 @@ public class HomeConfigInvalidator implements GeckoEventListener {
|
|||
Log.d(LOGTAG, "scheduleInvalidation: scheduled new invalidation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace an element if a matching PanelConfig is
|
||||
* present in the given list.
|
||||
*/
|
||||
private boolean replacePanelConfig(List<PanelConfig> panelConfigs, PanelConfig panelConfig) {
|
||||
final int index = panelConfigs.indexOf(panelConfig);
|
||||
if (index >= 0) {
|
||||
panelConfigs.set(index, panelConfig);
|
||||
Log.d(LOGTAG, "executePendingChanges: replaced position " + index + " with " + panelConfig.getId());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs in the background thread.
|
||||
*/
|
||||
|
@ -143,11 +159,7 @@ public class HomeConfigInvalidator implements GeckoEventListener {
|
|||
break;
|
||||
|
||||
case INSTALL:
|
||||
final int index = panelConfigs.indexOf(panelConfig);
|
||||
if (index >= 0) {
|
||||
panelConfigs.set(index, panelConfig);
|
||||
Log.d(LOGTAG, "executePendingChanges: replaced position " + index + " with " + id);
|
||||
} else {
|
||||
if (!replacePanelConfig(panelConfigs, panelConfig)) {
|
||||
panelConfigs.add(panelConfig);
|
||||
Log.d(LOGTAG, "executePendingChanges: added panel " + id);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче