Merge "Sharesheet - Don't update list on bg thread" into rvc-dev
This commit is contained in:
@@ -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();
|
||||
chooserListAdapter.updateAlphabeticalList();
|
||||
}
|
||||
|
||||
// don't support direct share on low ram devices
|
||||
|
||||
@@ -275,33 +275,43 @@ public class ChooserListAdapter extends ResolverListAdapter {
|
||||
}
|
||||
|
||||
void updateAlphabeticalList() {
|
||||
mSortedList.clear();
|
||||
List<DisplayResolveInfo> tempList = new ArrayList<>();
|
||||
tempList.addAll(mDisplayList);
|
||||
tempList.addAll(mCallerTargets);
|
||||
if (mEnableStackedApps) {
|
||||
// Consolidate multiple targets from same app.
|
||||
Map<String, DisplayResolveInfo> consolidated = new HashMap<>();
|
||||
for (DisplayResolveInfo info : tempList) {
|
||||
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);
|
||||
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 : 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());
|
||||
} else {
|
||||
mSortedList.addAll(tempList);
|
||||
}
|
||||
Collections.sort(mSortedList, new ChooserActivity.AzInfoComparator(mContext));
|
||||
@Override
|
||||
protected void onPostExecute(List<DisplayResolveInfo> newList) {
|
||||
mSortedList = newList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user