mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-18 15:47:54 -08:00
Change search to async for smoother UI
This commit is contained in:
@@ -63,14 +63,7 @@ public class MagiskHideFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
fListApps.clear();
|
||||
for (ApplicationInfo info : listApps) {
|
||||
if (info.loadLabel(packageManager).toString().toLowerCase().contains(newText.toLowerCase())
|
||||
|| info.packageName.toLowerCase().contains(newText.toLowerCase())) {
|
||||
fListApps.add(info);
|
||||
}
|
||||
}
|
||||
appAdapter.notifyDataSetChanged();
|
||||
new FilterApps().exec(newText);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -113,6 +106,26 @@ public class MagiskHideFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private class FilterApps extends Async.NormalTask<String, Void, Void> {
|
||||
@Override
|
||||
protected Void doInBackground(String... strings) {
|
||||
String newText = strings[0];
|
||||
fListApps.clear();
|
||||
for (ApplicationInfo info : listApps) {
|
||||
if (info.loadLabel(packageManager).toString().toLowerCase().contains(newText.toLowerCase())
|
||||
|| info.packageName.toLowerCase().contains(newText.toLowerCase())) {
|
||||
fListApps.add(info);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void v) {
|
||||
appAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
appAdapter.notifyDataSetChanged();
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user