mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
Merge "Rename LoaderResults to LauncherBinder." into tm-qpr-dev am: bf69ef034a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20543148 Change-Id: I6099c3312aac8cfeed3d6dafaaf8470f9c8f3687 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -22,11 +22,11 @@ import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
|
||||
/**
|
||||
* Helper class to handle results of {@link com.android.launcher3.model.LoaderTask}.
|
||||
* Binds the results of {@link com.android.launcher3.model.LoaderTask} to the Callbacks objects.
|
||||
*/
|
||||
public class LoaderResults extends BaseLoaderResults {
|
||||
public class LauncherBinder extends BaseLauncherBinder {
|
||||
|
||||
public LoaderResults(LauncherAppState app, BgDataModel dataModel,
|
||||
public LauncherBinder(LauncherAppState app, BgDataModel dataModel,
|
||||
AllAppsList allAppsList, Callbacks[] callbacks) {
|
||||
super(app, dataModel, allAppsList, callbacks, MAIN_EXECUTOR);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ import com.android.launcher3.model.BgDataModel;
|
||||
import com.android.launcher3.model.BgDataModel.Callbacks;
|
||||
import com.android.launcher3.model.CacheDataUpdatedTask;
|
||||
import com.android.launcher3.model.ItemInstallQueue;
|
||||
import com.android.launcher3.model.LoaderResults;
|
||||
import com.android.launcher3.model.LauncherBinder;
|
||||
import com.android.launcher3.model.LoaderTask;
|
||||
import com.android.launcher3.model.ModelDelegate;
|
||||
import com.android.launcher3.model.ModelWriter;
|
||||
@@ -405,22 +405,22 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
MAIN_EXECUTOR.execute(cb::clearPendingBinds);
|
||||
}
|
||||
|
||||
LoaderResults loaderResults = new LoaderResults(
|
||||
LauncherBinder launcherBinder = new LauncherBinder(
|
||||
mApp, mBgDataModel, mBgAllAppsList, callbacksList);
|
||||
if (bindDirectly) {
|
||||
// Divide the set of loaded items into those that we are binding synchronously,
|
||||
// and everything else that is to be bound normally (asynchronously).
|
||||
loaderResults.bindWorkspace(bindAllCallbacks);
|
||||
launcherBinder.bindWorkspace(bindAllCallbacks);
|
||||
// For now, continue posting the binding of AllApps as there are other
|
||||
// issues that arise from that.
|
||||
loaderResults.bindAllApps();
|
||||
loaderResults.bindDeepShortcuts();
|
||||
loaderResults.bindWidgets();
|
||||
launcherBinder.bindAllApps();
|
||||
launcherBinder.bindDeepShortcuts();
|
||||
launcherBinder.bindWidgets();
|
||||
return true;
|
||||
} else {
|
||||
stopLoader();
|
||||
mLoaderTask = new LoaderTask(
|
||||
mApp, mBgAllAppsList, mBgDataModel, mModelDelegate, loaderResults);
|
||||
mApp, mBgAllAppsList, mBgDataModel, mModelDelegate, launcherBinder);
|
||||
|
||||
// Always post the loader task, instead of running directly
|
||||
// (even on same thread) so that we exit any nested synchronized blocks
|
||||
|
||||
@@ -47,12 +47,11 @@ import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Base Helper class to handle results of {@link com.android.launcher3.model.LoaderTask}.
|
||||
* Binds the results of {@link com.android.launcher3.model.LoaderTask} to the Callbacks objects.
|
||||
*/
|
||||
public abstract class BaseLoaderResults {
|
||||
public abstract class BaseLauncherBinder {
|
||||
|
||||
protected static final String TAG = "LoaderResults";
|
||||
protected static final int INVALID_SCREEN_ID = -1;
|
||||
protected static final String TAG = "LauncherBinder";
|
||||
private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons
|
||||
|
||||
protected final LooperExecutor mUiExecutor;
|
||||
@@ -65,7 +64,7 @@ public abstract class BaseLoaderResults {
|
||||
|
||||
private int mMyBindingId;
|
||||
|
||||
public BaseLoaderResults(LauncherAppState app, BgDataModel dataModel,
|
||||
public BaseLauncherBinder(LauncherAppState app, BgDataModel dataModel,
|
||||
AllAppsList allAppsList, Callbacks[] callbacksList, LooperExecutor uiExecutor) {
|
||||
mUiExecutor = uiExecutor;
|
||||
mApp = app;
|
||||
@@ -101,8 +100,14 @@ public abstract class BaseLoaderResults {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BindDeepShortcuts is abstract because it is a no-op for the go launcher.
|
||||
*/
|
||||
public abstract void bindDeepShortcuts();
|
||||
|
||||
/**
|
||||
* Binds the all apps results from LoaderTask to the callbacks UX.
|
||||
*/
|
||||
public void bindAllApps() {
|
||||
// shallow copy
|
||||
AppInfo[] apps = mBgAllAppsList.copyData();
|
||||
@@ -110,6 +115,9 @@ public abstract class BaseLoaderResults {
|
||||
executeCallbacksTask(c -> c.bindAllApplications(apps, flags), mUiExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* bindWidgets is abstract because it is a no-op for the go launcher.
|
||||
*/
|
||||
public abstract void bindWidgets();
|
||||
|
||||
/**
|
||||
@@ -160,6 +168,9 @@ public abstract class BaseLoaderResults {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Only used in LoaderTask.
|
||||
*/
|
||||
public LooperIdleLock newIdleLock(Object lock) {
|
||||
LooperIdleLock idleLock = new LooperIdleLock(lock, mUiExecutor.getLooper());
|
||||
// If we are not binding or if the main looper is already idle, there is no reason to wait
|
||||
@@ -125,7 +125,7 @@ public class LoaderTask implements Runnable {
|
||||
|
||||
private FirstScreenBroadcast mFirstScreenBroadcast;
|
||||
|
||||
private final LoaderResults mResults;
|
||||
private final LauncherBinder mLauncherBinder;
|
||||
|
||||
private final LauncherApps mLauncherApps;
|
||||
private final UserManager mUserManager;
|
||||
@@ -145,12 +145,12 @@ public class LoaderTask implements Runnable {
|
||||
private String mDbName;
|
||||
|
||||
public LoaderTask(LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel dataModel,
|
||||
ModelDelegate modelDelegate, LoaderResults results) {
|
||||
ModelDelegate modelDelegate, LauncherBinder launcherBinder) {
|
||||
mApp = app;
|
||||
mBgAllAppsList = bgAllAppsList;
|
||||
mBgDataModel = dataModel;
|
||||
mModelDelegate = modelDelegate;
|
||||
mResults = results;
|
||||
mLauncherBinder = launcherBinder;
|
||||
|
||||
mLauncherApps = mApp.getContext().getSystemService(LauncherApps.class);
|
||||
mUserManager = mApp.getContext().getSystemService(UserManager.class);
|
||||
@@ -163,7 +163,7 @@ public class LoaderTask implements Runnable {
|
||||
// Wait until the either we're stopped or the other threads are done.
|
||||
// This way we don't start loading all apps until the workspace has settled
|
||||
// down.
|
||||
LooperIdleLock idleLock = mResults.newIdleLock(this);
|
||||
LooperIdleLock idleLock = mLauncherBinder.newIdleLock(this);
|
||||
// Just in case mFlushingWorkerThread changes but we aren't woken up,
|
||||
// wait no longer than 1sec at a time
|
||||
while (!mStopped && idleLock.awaitLocked(1000));
|
||||
@@ -221,7 +221,7 @@ public class LoaderTask implements Runnable {
|
||||
}
|
||||
|
||||
verifyNotStopped();
|
||||
mResults.bindWorkspace(true /* incrementBindId */);
|
||||
mLauncherBinder.bindWorkspace(true /* incrementBindId */);
|
||||
logASplit(logger, "bindWorkspace");
|
||||
|
||||
mModelDelegate.workspaceLoadComplete();
|
||||
@@ -245,7 +245,7 @@ public class LoaderTask implements Runnable {
|
||||
logASplit(logger, "loadAllApps");
|
||||
|
||||
verifyNotStopped();
|
||||
mResults.bindAllApps();
|
||||
mLauncherBinder.bindAllApps();
|
||||
logASplit(logger, "bindAllApps");
|
||||
|
||||
verifyNotStopped();
|
||||
@@ -271,7 +271,7 @@ public class LoaderTask implements Runnable {
|
||||
logASplit(logger, "loadDeepShortcuts");
|
||||
|
||||
verifyNotStopped();
|
||||
mResults.bindDeepShortcuts();
|
||||
mLauncherBinder.bindDeepShortcuts();
|
||||
logASplit(logger, "bindDeepShortcuts");
|
||||
|
||||
verifyNotStopped();
|
||||
@@ -290,7 +290,7 @@ public class LoaderTask implements Runnable {
|
||||
logASplit(logger, "load widgets");
|
||||
|
||||
verifyNotStopped();
|
||||
mResults.bindWidgets();
|
||||
mLauncherBinder.bindWidgets();
|
||||
logASplit(logger, "bindWidgets");
|
||||
verifyNotStopped();
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper class to handle results of {@link com.android.launcher3.model.LoaderTask}.
|
||||
* Binds the results of {@link com.android.launcher3.model.LoaderTask} to the Callbacks objects.
|
||||
*/
|
||||
public class LoaderResults extends BaseLoaderResults {
|
||||
public class LauncherBinder extends BaseLauncherBinder {
|
||||
|
||||
public LoaderResults(LauncherAppState app, BgDataModel dataModel,
|
||||
public LauncherBinder(LauncherAppState app, BgDataModel dataModel,
|
||||
AllAppsList allAppsList, Callbacks[] callbacks) {
|
||||
super(app, dataModel, allAppsList, callbacks, MAIN_EXECUTOR);
|
||||
}
|
||||
Reference in New Issue
Block a user