use of com.amaze.filemanager.adapters.data.AppDataSorter in project AmazeFileManager by TeamAmaze.
the class AppListLoader method loadInBackground.
@Override
public List<AppDataParcelable> loadInBackground() {
List<ApplicationInfo> apps = packageManager.getInstalledApplications(PackageManager.MATCH_UNINSTALLED_PACKAGES | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS);
if (apps == null)
return Collections.emptyList();
mApps = new ArrayList<>(apps.size());
PackageInfo androidInfo = null;
try {
androidInfo = packageManager.getPackageInfo("android", PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
for (ApplicationInfo object : apps) {
if (object.sourceDir == null) {
continue;
}
File sourceDir = new File(object.sourceDir);
String label = object.loadLabel(packageManager).toString();
PackageInfo info;
try {
info = packageManager.getPackageInfo(object.packageName, PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
info = null;
}
boolean isSystemApp = isAppInSystemPartition(object) || isSignedBySystem(info, androidInfo);
AppDataParcelable elem = new AppDataParcelable(label == null ? object.packageName : label, object.sourceDir, object.packageName, object.flags + "_" + (info != null ? info.versionName : ""), Formatter.formatFileSize(getContext(), sourceDir.length()), sourceDir.length(), sourceDir.lastModified(), isSystemApp, null);
mApps.add(elem);
}
Collections.sort(mApps, new AppDataSorter(sortBy, isAscending));
return mApps;
}
Aggregations