82 lines
2.2 KiB
Java
82 lines
2.2 KiB
Java
package com.xxpatx.os.bean;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import com.xxpatx.os.BuildConfig;
|
|
import com.xxpatx.os.utils.IconUtils;
|
|
|
|
import java.io.Serializable;
|
|
|
|
public class DailyAppBean implements Serializable {
|
|
private static final long serialVersionUID = 5054284058523960678L;
|
|
|
|
String appName;
|
|
String packageName;
|
|
String className;
|
|
|
|
public DailyAppBean(String packageName) {
|
|
this.packageName = packageName;
|
|
}
|
|
|
|
public DailyAppBean(String appName, String packageName) {
|
|
this.appName = appName;
|
|
this.packageName = packageName;
|
|
}
|
|
|
|
public DailyAppBean(String appName, String packageName, String className) {
|
|
this.appName = appName;
|
|
this.packageName = packageName;
|
|
this.className = className;
|
|
}
|
|
|
|
public String getAppName() {
|
|
return appName;
|
|
}
|
|
|
|
public void setAppName(String appName) {
|
|
this.appName = appName;
|
|
}
|
|
|
|
public String getPackageName() {
|
|
return packageName;
|
|
}
|
|
|
|
public void setPackageName(String packageName) {
|
|
this.packageName = packageName;
|
|
}
|
|
|
|
public String getClassName() {
|
|
return className;
|
|
}
|
|
|
|
public void setClassName(String className) {
|
|
this.className = className;
|
|
}
|
|
|
|
public Drawable getIcon(Context context) {
|
|
PackageManager pm = context.getPackageManager();
|
|
ApplicationInfo info = null;
|
|
try {
|
|
info = pm.getApplicationInfo(packageName, 0);
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
e.printStackTrace();
|
|
}
|
|
if (info == null) {
|
|
return null;
|
|
} else {
|
|
int i = IconUtils.appClassNameList.indexOf(packageName);
|
|
if (i != -1) {
|
|
String val = IconUtils.appIconList.get(i);
|
|
int resID = context.getResources().getIdentifier(val, "drawable", BuildConfig.APPLICATION_ID);
|
|
if (resID != 0) {
|
|
return context.getResources().getDrawable(resID);
|
|
}
|
|
}
|
|
return info.loadIcon(pm);
|
|
}
|
|
}
|
|
}
|