Initial commit
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package com.google.zxing.client.android.share;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.pm.PackageItemInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import com.google.zxing.client.android.R$id;
|
||||
import com.google.zxing.client.android.R$layout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class LoadPackagesAsyncTask extends AsyncTask<Object, Object, List<AppInfo>> {
|
||||
private static final String[] b = {"com.google.android.apps."};
|
||||
private static final String[] c = {"com.android.", "android", "com.google.android.", "com.htc"};
|
||||
private final ListActivity a;
|
||||
|
||||
LoadPackagesAsyncTask(ListActivity listActivity) {
|
||||
this.a = listActivity;
|
||||
}
|
||||
|
||||
private static boolean a(String str) {
|
||||
if (str == null) {
|
||||
return true;
|
||||
}
|
||||
for (String str2 : b) {
|
||||
if (str.startsWith(str2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (String str3 : c) {
|
||||
if (str.startsWith(str3)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public List<AppInfo> doInBackground(Object... objArr) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
PackageManager packageManager = this.a.getPackageManager();
|
||||
for (PackageItemInfo packageItemInfo : packageManager.getInstalledApplications(0)) {
|
||||
String str = packageItemInfo.packageName;
|
||||
if (!a(str)) {
|
||||
CharSequence loadLabel = packageItemInfo.loadLabel(packageManager);
|
||||
Drawable loadIcon = packageItemInfo.loadIcon(packageManager);
|
||||
if (loadLabel != null) {
|
||||
arrayList.add(new AppInfo(str, loadLabel.toString(), loadIcon));
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(arrayList);
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onPostExecute(final List<AppInfo> list) {
|
||||
this.a.setListAdapter(new ArrayAdapter<AppInfo>(this, this.a, R$layout.app_picker_list_item, R$id.app_picker_list_item_label, list) { // from class: com.google.zxing.client.android.share.LoadPackagesAsyncTask.1
|
||||
@Override // android.widget.ArrayAdapter, android.widget.Adapter
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
View view2 = super.getView(i, view, viewGroup);
|
||||
Drawable c2 = ((AppInfo) list.get(i)).c();
|
||||
if (c2 != null) {
|
||||
((ImageView) view2.findViewById(R$id.app_picker_list_item_icon)).setImageDrawable(c2);
|
||||
}
|
||||
return view2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user