mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-18 18:28:20 +00:00
Separating apps list callback from model callback and simplifying various events
Bug: 137568159 Change-Id: I4d8bb5c01cabe642731ebd3f57fe15bdc5a569b7
This commit is contained in:
@@ -17,12 +17,12 @@ package com.android.launcher3.model;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.AllAppsList;
|
||||
import com.android.launcher3.AppInfo;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherModel;
|
||||
import com.android.launcher3.LauncherModel.ModelUpdateTask;
|
||||
import com.android.launcher3.LauncherModel.CallbackTask;
|
||||
import com.android.launcher3.LauncherModel.Callbacks;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.WorkspaceItemInfo;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
@@ -30,6 +30,7 @@ import com.android.launcher3.widget.WidgetListRowEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
@@ -95,12 +96,7 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
|
||||
|
||||
public void bindUpdatedWorkspaceItems(final ArrayList<WorkspaceItemInfo> updatedShortcuts) {
|
||||
if (!updatedShortcuts.isEmpty()) {
|
||||
scheduleCallbackTask(new CallbackTask() {
|
||||
@Override
|
||||
public void execute(Callbacks callbacks) {
|
||||
callbacks.bindWorkspaceItemsChanged(updatedShortcuts);
|
||||
}
|
||||
});
|
||||
scheduleCallbackTask(c -> c.bindWorkspaceItemsChanged(updatedShortcuts));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,23 +109,20 @@ public abstract class BaseModelUpdateTask implements ModelUpdateTask {
|
||||
public void bindUpdatedWidgets(BgDataModel dataModel) {
|
||||
final ArrayList<WidgetListRowEntry> widgets =
|
||||
dataModel.widgetsModel.getWidgetsList(mApp.getContext());
|
||||
scheduleCallbackTask(new CallbackTask() {
|
||||
@Override
|
||||
public void execute(Callbacks callbacks) {
|
||||
callbacks.bindAllWidgets(widgets);
|
||||
}
|
||||
});
|
||||
scheduleCallbackTask(c -> c.bindAllWidgets(widgets));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
scheduleCallbackTask(c -> c.bindWorkspaceComponentsRemoved(matcher));
|
||||
}
|
||||
|
||||
public void bindApplicationsIfNeeded() {
|
||||
if (mAllAppsList.getAndResetChangeFlag()) {
|
||||
AppInfo[] apps = mAllAppsList.copyData();
|
||||
scheduleCallbackTask(c -> c.bindAllApplications(apps));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user