mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 09:56:49 +00:00
Moving various common executors to a single location
Change-Id: I44bca49b8adb6fa22c3b48d10f674e42c28d792c
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
|
||||
import android.content.ContentProviderOperation;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
@@ -31,17 +33,16 @@ import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherAppWidgetHost;
|
||||
import com.android.launcher3.LauncherAppWidgetInfo;
|
||||
import com.android.launcher3.LauncherModel;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.LauncherProvider;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.LauncherSettings.Settings;
|
||||
import com.android.launcher3.WorkspaceItemInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.WorkspaceItemInfo;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.util.ContentWriter;
|
||||
import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -61,7 +62,6 @@ public class ModelWriter {
|
||||
private final BgDataModel mBgDataModel;
|
||||
private final Handler mUiHandler;
|
||||
|
||||
private final Executor mWorkerExecutor;
|
||||
private final boolean mHasVerticalHotseat;
|
||||
private final boolean mVerifyChanges;
|
||||
|
||||
@@ -74,7 +74,6 @@ public class ModelWriter {
|
||||
mContext = context;
|
||||
mModel = model;
|
||||
mBgDataModel = dataModel;
|
||||
mWorkerExecutor = new LooperExecutor(LauncherModel.getWorkerLooper());
|
||||
mHasVerticalHotseat = hasVerticalHotseat;
|
||||
mVerifyChanges = verifyChanges;
|
||||
mUiHandler = new Handler(Looper.getMainLooper());
|
||||
@@ -194,7 +193,7 @@ public class ModelWriter {
|
||||
item.spanX = spanX;
|
||||
item.spanY = spanY;
|
||||
|
||||
mWorkerExecutor.execute(new UpdateItemRunnable(item, () ->
|
||||
((Executor) MODEL_EXECUTOR).execute(new UpdateItemRunnable(item, () ->
|
||||
new ContentWriter(mContext)
|
||||
.put(Favorites.CONTAINER, item.container)
|
||||
.put(Favorites.CELLX, item.cellX)
|
||||
@@ -209,7 +208,7 @@ public class ModelWriter {
|
||||
* Update an item to the database in a specified container.
|
||||
*/
|
||||
public void updateItemInDatabase(ItemInfo item) {
|
||||
mWorkerExecutor.execute(new UpdateItemRunnable(item, () -> {
|
||||
((Executor) MODEL_EXECUTOR).execute(new UpdateItemRunnable(item, () -> {
|
||||
ContentWriter writer = new ContentWriter(mContext);
|
||||
item.onAddToDatabase(writer);
|
||||
return writer;
|
||||
@@ -229,7 +228,7 @@ public class ModelWriter {
|
||||
|
||||
ModelVerifier verifier = new ModelVerifier();
|
||||
final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
|
||||
mWorkerExecutor.execute(() -> {
|
||||
((Executor) MODEL_EXECUTOR).execute(() -> {
|
||||
// Write the item on background thread, as some properties might have been updated in
|
||||
// the background.
|
||||
final ContentWriter writer = new ContentWriter(mContext);
|
||||
@@ -333,14 +332,14 @@ public class ModelWriter {
|
||||
if (mPreparingToUndo) {
|
||||
mDeleteRunnables.add(r);
|
||||
} else {
|
||||
mWorkerExecutor.execute(r);
|
||||
((Executor) MODEL_EXECUTOR).execute(r);
|
||||
}
|
||||
}
|
||||
|
||||
public void commitDelete() {
|
||||
mPreparingToUndo = false;
|
||||
for (Runnable runnable : mDeleteRunnables) {
|
||||
mWorkerExecutor.execute(runnable);
|
||||
((Executor) MODEL_EXECUTOR).execute(runnable);
|
||||
}
|
||||
mDeleteRunnables.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user