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;
|
protected List<PackageInfo> mTemporarylist;
|
||||||
|
|
||||||
boolean isUpdating;
|
boolean isUpdating;
|
||||||
|
boolean hasLauncherFilter = false;
|
||||||
|
|
||||||
public HAFRAppChooserAdapter(Context context) {
|
public HAFRAppChooserAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@@ -60,10 +61,14 @@ public abstract class HAFRAppChooserAdapter extends BaseAdapter implements Filte
|
|||||||
item.icon = info.applicationInfo.loadIcon(mPackageManager);
|
item.icon = info.applicationInfo.loadIcon(mPackageManager);
|
||||||
item.packageName = info.packageName;
|
item.packageName = info.packageName;
|
||||||
final int index = Collections.binarySearch(temp, item);
|
final int index = Collections.binarySearch(temp, item);
|
||||||
if (index < 0) {
|
final boolean isLauncherApp =
|
||||||
temp.add((-index - 1), item);
|
mPackageManager.getLaunchIntentForPackage(info.packageName) != null;
|
||||||
} else {
|
if (!hasLauncherFilter || isLauncherApp) {
|
||||||
temp.add((index + 1), item);
|
if (index < 0) {
|
||||||
|
temp.add((-index - 1), item);
|
||||||
|
} else {
|
||||||
|
temp.add((index + 1), item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@@ -179,4 +184,8 @@ public abstract class HAFRAppChooserAdapter extends BaseAdapter implements Filte
|
|||||||
ImageView icon;
|
ImageView icon;
|
||||||
TextView pkg;
|
TextView pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setLauncherFilter(boolean enabled) {
|
||||||
|
hasLauncherFilter = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,5 +76,9 @@ public abstract class HAFRAppChooserDialog extends Dialog {
|
|||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLauncherFilter(boolean enabled) {
|
||||||
|
dAdapter.setLauncherFilter(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void onListViewItemClick(HAFRAppChooserAdapter.AppItem info, int id);
|
public abstract void onListViewItemClick(HAFRAppChooserAdapter.AppItem info, int id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user