HAFRDialog: Add ability to only show Launcher Apps
Change-Id: I79499be92fb75ecf85357cccbf9193971789459a Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
committed by
Hưng Phan
parent
cebca8ba7d
commit
0387fc2a5f
@@ -35,6 +35,7 @@ public abstract class HAFRAppChooserAdapter extends BaseAdapter implements Filte
|
||||
protected List<PackageInfo> mTemporarylist;
|
||||
|
||||
boolean isUpdating;
|
||||
boolean hasLauncherFilter = false;
|
||||
|
||||
public HAFRAppChooserAdapter(Context context) {
|
||||
mContext = context;
|
||||
@@ -60,10 +61,14 @@ public abstract class HAFRAppChooserAdapter extends BaseAdapter implements Filte
|
||||
item.icon = info.applicationInfo.loadIcon(mPackageManager);
|
||||
item.packageName = info.packageName;
|
||||
final int index = Collections.binarySearch(temp, item);
|
||||
if (index < 0) {
|
||||
temp.add((-index - 1), item);
|
||||
} else {
|
||||
temp.add((index + 1), item);
|
||||
final boolean isLauncherApp =
|
||||
mPackageManager.getLaunchIntentForPackage(info.packageName) != null;
|
||||
if (!hasLauncherFilter || isLauncherApp) {
|
||||
if (index < 0) {
|
||||
temp.add((-index - 1), item);
|
||||
} else {
|
||||
temp.add((index + 1), item);
|
||||
}
|
||||
}
|
||||
}
|
||||
mHandler.post(new Runnable() {
|
||||
@@ -179,4 +184,8 @@ public abstract class HAFRAppChooserAdapter extends BaseAdapter implements Filte
|
||||
ImageView icon;
|
||||
TextView pkg;
|
||||
}
|
||||
|
||||
protected void setLauncherFilter(boolean enabled) {
|
||||
hasLauncherFilter = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,5 +76,9 @@ public abstract class HAFRAppChooserDialog extends Dialog {
|
||||
show();
|
||||
}
|
||||
|
||||
public void setLauncherFilter(boolean enabled) {
|
||||
dAdapter.setLauncherFilter(enabled);
|
||||
}
|
||||
|
||||
public abstract void onListViewItemClick(HAFRAppChooserAdapter.AppItem info, int id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user