diff --git a/go/src/com/android/launcher3/model/LoaderResults.java b/go/src/com/android/launcher3/model/LauncherBinder.java similarity index 82% rename from go/src/com/android/launcher3/model/LoaderResults.java rename to go/src/com/android/launcher3/model/LauncherBinder.java index 5f71061a6e..437d8caf94 100644 --- a/go/src/com/android/launcher3/model/LoaderResults.java +++ b/go/src/com/android/launcher3/model/LauncherBinder.java @@ -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); } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 20df89763b..2c6458bc49 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -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 diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLauncherBinder.java similarity index 95% rename from src/com/android/launcher3/model/BaseLoaderResults.java rename to src/com/android/launcher3/model/BaseLauncherBinder.java index 8c6428b028..9f8db51629 100644 --- a/src/com/android/launcher3/model/BaseLoaderResults.java +++ b/src/com/android/launcher3/model/BaseLauncherBinder.java @@ -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 diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 1d6971e27d..46a6a66c76 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -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(); diff --git a/src_shortcuts_overrides/com/android/launcher3/model/LoaderResults.java b/src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java similarity index 88% rename from src_shortcuts_overrides/com/android/launcher3/model/LoaderResults.java rename to src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java index abce2a24f4..e1a5f24148 100644 --- a/src_shortcuts_overrides/com/android/launcher3/model/LoaderResults.java +++ b/src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java @@ -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); }