diff options
| author | 2023-09-26 17:25:51 +0000 | |
|---|---|---|
| committer | 2023-09-26 17:25:51 +0000 | |
| commit | c9e8f1116e2ad1ce3f9aa60efe4be0a1c94eec02 (patch) | |
| tree | 8fc0b8c5ba7a8cd710a3387e0b10493dfcfd78d0 /java/src | |
| parent | a10bad023153e90af9cd4d8ba1b1dccbf76f068f (diff) | |
| parent | c2fcb4099bd4fad19d9bcff4ca197f0ab0c904a2 (diff) | |
Merge "ResolverListAdapter: Switch `Handler`->`Executor`" into main
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/ResolverListAdapter.java | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/java/src/com/android/intentresolver/ResolverListAdapter.java b/java/src/com/android/intentresolver/ResolverListAdapter.java index 4ad8d926..0d199fa3 100644 --- a/java/src/com/android/intentresolver/ResolverListAdapter.java +++ b/java/src/com/android/intentresolver/ResolverListAdapter.java @@ -28,7 +28,6 @@ import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.os.Handler; import android.os.RemoteException; import android.os.Trace; import android.os.UserHandle; @@ -82,7 +81,7 @@ public class ResolverListAdapter extends BaseAdapter { private final Set<DisplayResolveInfo> mRequestedIcons = new HashSet<>(); private final Set<DisplayResolveInfo> mRequestedLabels = new HashSet<>(); private final Executor mBgExecutor; - private final Handler mMainHandler; + private final Executor mCallbackExecutor; private final AtomicBoolean mDestroyed = new AtomicBoolean(); private ResolveInfo mLastChosen; @@ -124,7 +123,7 @@ public class ResolverListAdapter extends BaseAdapter { initialIntentsUserSpace, targetDataLoader, AsyncTask.SERIAL_EXECUTOR, - context.getMainThreadHandler()); + runnable -> context.getMainThreadHandler().post(runnable)); } @VisibleForTesting @@ -141,7 +140,7 @@ public class ResolverListAdapter extends BaseAdapter { UserHandle initialIntentsUserSpace, TargetDataLoader targetDataLoader, Executor bgExecutor, - Handler mainHandler) { + Executor callbackExecutor) { mContext = context; mIntents = payloadIntents; mInitialIntents = initialIntents; @@ -157,7 +156,7 @@ public class ResolverListAdapter extends BaseAdapter { mResolverListCommunicator = resolverListCommunicator; mInitialIntentsUserSpace = initialIntentsUserSpace; mBgExecutor = bgExecutor; - mMainHandler = mainHandler; + mCallbackExecutor = callbackExecutor; } public final DisplayResolveInfo getFirstDisplayResolveInfo() { @@ -236,12 +235,12 @@ public class ResolverListAdapter extends BaseAdapter { /** * Rebuild the list of resolvers. When rebuilding is complete, queue the {@code onPostListReady} - * callback on the main handler with {@code rebuildCompleted} true. + * callback on the callback executor with {@code rebuildCompleted} true. * * In some cases some parts will need some asynchronous work to complete. Then this will first - * immediately queue {@code onPostListReady} (on the main handler) with {@code rebuildCompleted} - * false; only when the asynchronous work completes will this then go on to queue another - * {@code onPostListReady} callback with {@code rebuildCompleted} true. + * immediately queue {@code onPostListReady} (on the callback executor) with + * {@code rebuildCompleted} false; only when the asynchronous work completes will this then go + * on to queue another {@code onPostListReady} callback with {@code rebuildCompleted} true. * * The {@code doPostProcessing} parameter is used to specify whether to update the UI and * load additional targets (e.g. direct share) after the list has been rebuilt. We may choose @@ -456,7 +455,7 @@ public class ResolverListAdapter extends BaseAdapter { throw t; } finally { final List<ResolvedComponentInfo> result = sortedComponents; - mMainHandler.post(() -> onComponentsSorted(result, doPostProcessing)); + mCallbackExecutor.execute(() -> onComponentsSorted(result, doPostProcessing)); } }); return false; @@ -541,7 +540,7 @@ public class ResolverListAdapter extends BaseAdapter { /** * Some necessary methods for creating the list are initiated in onCreate and will also * determine the layout known. We therefore can't update the UI inline and post to the - * handler thread to update after the current task is finished. + * callback executor to update after the current task is finished. * @param doPostProcessing Whether to update the UI and load additional direct share targets * after the list has been rebuilt * @param rebuildCompleted Whether the list has been completely rebuilt @@ -557,7 +556,7 @@ public class ResolverListAdapter extends BaseAdapter { doPostProcessing, rebuildCompleted); } }; - mMainHandler.post(listReadyRunnable); + mCallbackExecutor.execute(listReadyRunnable); } private void addResolveInfoWithAlternates(ResolvedComponentInfo rci) { |