Merge "Sharesheet - Don't update list on bg thread" into rvc-dev am: a4d5e8c9b7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11884197 Change-Id: I34bf0fac7e18abd1528f0db35c4f70455145d03c
This commit is contained in:
@@ -2800,17 +2800,7 @@ public class ChooserActivity extends ResolverActivity implements
|
|||||||
|| chooserListAdapter.mDisplayList.isEmpty()) {
|
|| chooserListAdapter.mDisplayList.isEmpty()) {
|
||||||
chooserListAdapter.notifyDataSetChanged();
|
chooserListAdapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
chooserListAdapter.updateAlphabeticalList();
|
||||||
@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
|
// don't support direct share on low ram devices
|
||||||
|
|||||||
@@ -275,33 +275,43 @@ public class ChooserListAdapter extends ResolverListAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateAlphabeticalList() {
|
void updateAlphabeticalList() {
|
||||||
mSortedList.clear();
|
new AsyncTask<Void, Void, List<DisplayResolveInfo>>() {
|
||||||
List<DisplayResolveInfo> tempList = new ArrayList<>();
|
@Override
|
||||||
tempList.addAll(mDisplayList);
|
protected List<DisplayResolveInfo> doInBackground(Void... voids) {
|
||||||
tempList.addAll(mCallerTargets);
|
List<DisplayResolveInfo> allTargets = new ArrayList<>();
|
||||||
if (mEnableStackedApps) {
|
allTargets.addAll(mDisplayList);
|
||||||
// Consolidate multiple targets from same app.
|
allTargets.addAll(mCallerTargets);
|
||||||
Map<String, DisplayResolveInfo> consolidated = new HashMap<>();
|
if (!mEnableStackedApps) {
|
||||||
for (DisplayResolveInfo info : tempList) {
|
return allTargets;
|
||||||
String packageName = info.getResolvedComponentName().getPackageName();
|
|
||||||
DisplayResolveInfo multiDri = consolidated.get(packageName);
|
|
||||||
if (multiDri == null) {
|
|
||||||
consolidated.put(packageName, info);
|
|
||||||
} else if (multiDri instanceof MultiDisplayResolveInfo) {
|
|
||||||
((MultiDisplayResolveInfo) multiDri).addTarget(info);
|
|
||||||
} else {
|
|
||||||
// create consolidated target from the single DisplayResolveInfo
|
|
||||||
MultiDisplayResolveInfo multiDisplayResolveInfo =
|
|
||||||
new MultiDisplayResolveInfo(packageName, multiDri);
|
|
||||||
multiDisplayResolveInfo.addTarget(info);
|
|
||||||
consolidated.put(packageName, multiDisplayResolveInfo);
|
|
||||||
}
|
}
|
||||||
|
// Consolidate multiple targets from same app.
|
||||||
|
Map<String, DisplayResolveInfo> consolidated = new HashMap<>();
|
||||||
|
for (DisplayResolveInfo info : allTargets) {
|
||||||
|
String packageName = info.getResolvedComponentName().getPackageName();
|
||||||
|
DisplayResolveInfo multiDri = consolidated.get(packageName);
|
||||||
|
if (multiDri == null) {
|
||||||
|
consolidated.put(packageName, info);
|
||||||
|
} else if (multiDri instanceof MultiDisplayResolveInfo) {
|
||||||
|
((MultiDisplayResolveInfo) multiDri).addTarget(info);
|
||||||
|
} else {
|
||||||
|
// create consolidated target from the single DisplayResolveInfo
|
||||||
|
MultiDisplayResolveInfo multiDisplayResolveInfo =
|
||||||
|
new MultiDisplayResolveInfo(packageName, multiDri);
|
||||||
|
multiDisplayResolveInfo.addTarget(info);
|
||||||
|
consolidated.put(packageName, multiDisplayResolveInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<DisplayResolveInfo> groupedTargets = new ArrayList<>();
|
||||||
|
groupedTargets.addAll(consolidated.values());
|
||||||
|
Collections.sort(groupedTargets, new ChooserActivity.AzInfoComparator(mContext));
|
||||||
|
return groupedTargets;
|
||||||
}
|
}
|
||||||
mSortedList.addAll(consolidated.values());
|
@Override
|
||||||
} else {
|
protected void onPostExecute(List<DisplayResolveInfo> newList) {
|
||||||
mSortedList.addAll(tempList);
|
mSortedList = newList;
|
||||||
}
|
notifyDataSetChanged();
|
||||||
Collections.sort(mSortedList, new ChooserActivity.AzInfoComparator(mContext));
|
}
|
||||||
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user