mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 11:47:39 +00:00
Simplify ApplicationAdapter filter
This commit is contained in:
parent
085fba050a
commit
76e7c5623d
@ -129,30 +129,23 @@ public class ApplicationAdapter extends RecyclerView.Adapter<ApplicationAdapter.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
List<ApplicationInfo> filteredApps;
|
|
||||||
if (constraint == null || constraint.length() == 0) {
|
if (constraint == null || constraint.length() == 0) {
|
||||||
filteredApps = mOriginalList;
|
mList = mOriginalList;
|
||||||
} else {
|
} else {
|
||||||
filteredApps = new ArrayList<>();
|
mList = new ArrayList<>();
|
||||||
String filter = constraint.toString().toLowerCase();
|
String filter = constraint.toString().toLowerCase();
|
||||||
for (ApplicationInfo info : mOriginalList) {
|
for (ApplicationInfo info : mOriginalList) {
|
||||||
if (Utils.lowercaseContains(info.loadLabel(pm), filter)
|
if (Utils.lowercaseContains(info.loadLabel(pm), filter)
|
||||||
|| Utils.lowercaseContains(info.packageName, filter)) {
|
|| Utils.lowercaseContains(info.packageName, filter)) {
|
||||||
filteredApps.add(info);
|
mList.add(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
FilterResults results = new FilterResults();
|
|
||||||
results.values = filteredApps;
|
|
||||||
results.count = filteredApps.size();
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
mList = (List<ApplicationInfo>) results.values;
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user