Converting ModelTask to an interface instead of an abstract class

This allows extensibility and better use of lambdas

Bug: 338282246
Test: Presubmit
Flag: None

Change-Id: Ia41067f0068b3b631eeb4faf877dc77f8587e1f6
This commit is contained in:
Sunny Goyal
2024-05-01 14:47:43 -07:00
parent c113ce9f9f
commit 993893895c
17 changed files with 285 additions and 378 deletions

View File

@@ -24,6 +24,7 @@ import android.os.UserHandle;
import androidx.annotation.NonNull;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel.ModelUpdateTask;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.shortcuts.ShortcutKey;
@@ -40,7 +41,7 @@ import java.util.Iterator;
/**
* Task to handle changing of lock state of the user
*/
public class UserLockStateChangedTask extends BaseModelUpdateTask {
public class UserLockStateChangedTask implements ModelUpdateTask {
@NonNull
private final UserHandle mUser;
@@ -52,8 +53,9 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
}
@Override
public void execute(@NonNull final LauncherAppState app, @NonNull final BgDataModel dataModel,
@NonNull final AllAppsList apps) {
public void execute(@NonNull ModelTaskController taskController, @NonNull BgDataModel dataModel,
@NonNull AllAppsList apps) {
LauncherAppState app = taskController.getApp();
Context context = app.getContext();
HashMap<ShortcutKey, ShortcutInfo> pinnedShortcuts = new HashMap<>();
@@ -98,9 +100,10 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
}
});
}
bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
taskController.bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
if (!removedKeys.isEmpty()) {
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys),
taskController.deleteAndBindComponentsRemoved(
ItemInfoMatcher.ofShortcutKeys(removedKeys),
"removed during unlock because it's no longer available"
+ " (possibly due to clear data)");
}
@@ -118,6 +121,6 @@ public class UserLockStateChangedTask extends BaseModelUpdateTask {
null, mUser,
new ShortcutRequest(context, mUser).query(ShortcutRequest.ALL));
}
bindDeepShortcuts(dataModel);
taskController.bindDeepShortcuts(dataModel);
}
}