diff options
| author | 2023-09-25 19:32:19 +0000 | |
|---|---|---|
| committer | 2023-09-25 19:32:19 +0000 | |
| commit | 82df935c3d39e61eaf5fe0917bf94833bf37caec (patch) | |
| tree | 4d110702969b69162545ac278aabe79650261f2d /java/src/com | |
| parent | 8032474f8fd95a5a5f96227908abba2e73e98b2f (diff) | |
| parent | fb8126b8fc336d681ba2ded6214d90a6f113b92e (diff) | |
Merge "For consistency, stop throttling "list ready" CBs." into main
Diffstat (limited to 'java/src/com')
| -rw-r--r-- | java/src/com/android/intentresolver/ResolverListAdapter.java | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/java/src/com/android/intentresolver/ResolverListAdapter.java b/java/src/com/android/intentresolver/ResolverListAdapter.java index a243ac2a..4ad8d926 100644 --- a/java/src/com/android/intentresolver/ResolverListAdapter.java +++ b/java/src/com/android/intentresolver/ResolverListAdapter.java @@ -58,6 +58,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; +import java.util.concurrent.atomic.AtomicBoolean; public class ResolverListAdapter extends BaseAdapter { private static final String TAG = "ResolverListAdapter"; @@ -82,6 +83,7 @@ public class ResolverListAdapter extends BaseAdapter { private final Set<DisplayResolveInfo> mRequestedLabels = new HashSet<>(); private final Executor mBgExecutor; private final Handler mMainHandler; + private final AtomicBoolean mDestroyed = new AtomicBoolean(); private ResolveInfo mLastChosen; private DisplayResolveInfo mOtherProfile; @@ -93,7 +95,6 @@ public class ResolverListAdapter extends BaseAdapter { private int mLastChosenPosition = -1; private final boolean mFilterLastUsed; - private Runnable mPostListReadyRunnable; private boolean mIsTabLoaded; // Represents the UserSpace in which the Initial Intents should be resolved. private final UserHandle mInitialIntentsUserSpace; @@ -546,17 +547,17 @@ public class ResolverListAdapter extends BaseAdapter { * @param rebuildCompleted Whether the list has been completely rebuilt */ void postListReadyRunnable(boolean doPostProcessing, boolean rebuildCompleted) { - if (mPostListReadyRunnable == null) { - mPostListReadyRunnable = new Runnable() { - @Override - public void run() { - mResolverListCommunicator.onPostListReady(ResolverListAdapter.this, - doPostProcessing, rebuildCompleted); - mPostListReadyRunnable = null; + Runnable listReadyRunnable = new Runnable() { + @Override + public void run() { + if (mDestroyed.get()) { + return; } - }; - mMainHandler.post(mPostListReadyRunnable); - } + mResolverListCommunicator.onPostListReady(ResolverListAdapter.this, + doPostProcessing, rebuildCompleted); + } + }; + mMainHandler.post(listReadyRunnable); } private void addResolveInfoWithAlternates(ResolvedComponentInfo rci) { @@ -772,10 +773,8 @@ public class ResolverListAdapter extends BaseAdapter { } public void onDestroy() { - if (mPostListReadyRunnable != null) { - mMainHandler.removeCallbacks(mPostListReadyRunnable); - mPostListReadyRunnable = null; - } + mDestroyed.set(true); + if (mResolverListController != null) { mResolverListController.destroy(); } |