Simplifying some package matching code by using common itemInfo mathcher

Change-Id: Ib98d528391e19c0de3fe11304330dfa37710548c
This commit is contained in:
Sunny Goyal
2017-08-17 03:01:19 -07:00
parent b23980cc0e
commit 6e13dd3aa8
7 changed files with 100 additions and 101 deletions

View File

@@ -26,6 +26,7 @@ import com.android.launcher3.LauncherModel.CallbackTask;
import com.android.launcher3.LauncherModel.Callbacks;
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiHashMap;
import java.util.ArrayList;
@@ -94,19 +95,12 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
public void bindUpdatedShortcuts(
ArrayList<ShortcutInfo> updatedShortcuts, UserHandle user) {
bindUpdatedShortcuts(updatedShortcuts, new ArrayList<ShortcutInfo>(), user);
}
public void bindUpdatedShortcuts(
final ArrayList<ShortcutInfo> updatedShortcuts,
final ArrayList<ShortcutInfo> removedShortcuts,
final UserHandle user) {
if (!updatedShortcuts.isEmpty() || !removedShortcuts.isEmpty()) {
final ArrayList<ShortcutInfo> updatedShortcuts, final UserHandle user) {
if (!updatedShortcuts.isEmpty()) {
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
callbacks.bindShortcutsChanged(updatedShortcuts, removedShortcuts, user);
callbacks.bindShortcutsChanged(updatedShortcuts, user);
}
});
}
@@ -132,4 +126,16 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
}
});
}
public void deleteAndBindComponentsRemoved(final ItemInfoMatcher matcher) {
getModelWriter().deleteItemsFromDatabase(matcher);
// Call the components-removed callback
scheduleCallbackTask(new CallbackTask() {
@Override
public void execute(Callbacks callbacks) {
callbacks.bindWorkspaceComponentsRemoved(matcher);
}
});
}
}