Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd19b8c4 authored by Matt Pietal's avatar Matt Pietal Committed by Automerger Merge Worker
Browse files

Merge "Sharesheet - Don't update list on bg thread" into rvc-dev am: a4d5e8c9 am: 930b36cc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11884197

Change-Id: Ic50b7c54c8075e759c79729498b191936ee64b9f
parents 2f212aad 930b36cc
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -2800,17 +2800,7 @@ public class ChooserActivity extends ResolverActivity implements
                || chooserListAdapter.mDisplayList.isEmpty()) {
            chooserListAdapter.notifyDataSetChanged();
        } else {
            new AsyncTask<Void, Void, Void>() {
                @Override
                protected Void doInBackground(Void... voids) {
            chooserListAdapter.updateAlphabeticalList();
                    return null;
                }
                @Override
                protected void onPostExecute(Void aVoid) {
                    chooserListAdapter.notifyDataSetChanged();
                }
            }.execute();
        }

        // don't support direct share on low ram devices
+34 −24
Original line number Diff line number Diff line
@@ -275,14 +275,18 @@ public class ChooserListAdapter extends ResolverListAdapter {
    }

    void updateAlphabeticalList() {
        mSortedList.clear();
        List<DisplayResolveInfo> tempList = new ArrayList<>();
        tempList.addAll(mDisplayList);
        tempList.addAll(mCallerTargets);
        if (mEnableStackedApps) {
        new AsyncTask<Void, Void, List<DisplayResolveInfo>>() {
            @Override
            protected List<DisplayResolveInfo> doInBackground(Void... voids) {
                List<DisplayResolveInfo> allTargets = new ArrayList<>();
                allTargets.addAll(mDisplayList);
                allTargets.addAll(mCallerTargets);
                if (!mEnableStackedApps) {
                    return allTargets;
                }
                // Consolidate multiple targets from same app.
                Map<String, DisplayResolveInfo> consolidated = new HashMap<>();
            for (DisplayResolveInfo info : tempList) {
                for (DisplayResolveInfo info : allTargets) {
                    String packageName = info.getResolvedComponentName().getPackageName();
                    DisplayResolveInfo multiDri = consolidated.get(packageName);
                    if (multiDri == null) {
@@ -297,11 +301,17 @@ public class ChooserListAdapter extends ResolverListAdapter {
                        consolidated.put(packageName, multiDisplayResolveInfo);
                    }
                }
            mSortedList.addAll(consolidated.values());
        } else {
            mSortedList.addAll(tempList);
                List<DisplayResolveInfo> groupedTargets = new ArrayList<>();
                groupedTargets.addAll(consolidated.values());
                Collections.sort(groupedTargets, new ChooserActivity.AzInfoComparator(mContext));
                return groupedTargets;
            }
            @Override
            protected void onPostExecute(List<DisplayResolveInfo> newList) {
                mSortedList = newList;
                notifyDataSetChanged();
            }
        Collections.sort(mSortedList, new ChooserActivity.AzInfoComparator(mContext));
        }.execute();
    }

    @Override