entrance检查与统一
This commit is contained in:
@ -36,6 +36,8 @@ import com.gh.gamecenter.listener.OnCollectionCallBackListener;
|
||||
import com.gh.gamecenter.manager.PackageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -275,98 +277,79 @@ public class DownloadDialog implements OnCollectionCallBackListener {
|
||||
viewPager.setCurrentItem(currentItem);
|
||||
}
|
||||
|
||||
private ArrayList<ApkEntity> sortApk(List<ApkEntity> apkList) {
|
||||
List<ApkEntity> pluginDoneList = new ArrayList<>(); // 安装插件
|
||||
List<ApkEntity> pluginDownloadList = new ArrayList<>(); // 插件化下载中
|
||||
List<ApkEntity> pluginList = new ArrayList<>(); // 插件化
|
||||
List<ApkEntity> updateDoneList = new ArrayList<>(); // 安装更新
|
||||
List<ApkEntity> updateDownloadList = new ArrayList<>(); // 更新下载中
|
||||
List<ApkEntity> updateList = new ArrayList<>(); // 更新
|
||||
List<ApkEntity> doneList = new ArrayList<>(); // 安装
|
||||
List<ApkEntity> downloadList = new ArrayList<>(); // 下载中
|
||||
List<ApkEntity> installList = new ArrayList<>(); // 启动
|
||||
List<ApkEntity> noPicList = new ArrayList<>(); // 默认(无图片)
|
||||
private ArrayList<ApkEntity> sortApk(ArrayList<ApkEntity> apkList) {
|
||||
/*
|
||||
* 安装插件 10
|
||||
* 插件化下载中 9
|
||||
* 插件化 8
|
||||
* 安装更新 7
|
||||
* 更新下载中 6
|
||||
* 更新 5
|
||||
* 安装 4
|
||||
* 下载中 3
|
||||
* 启动 2
|
||||
* 默认(有图片)1
|
||||
* 默认(无图片)0
|
||||
*/
|
||||
|
||||
DownloadEntity downloadEntity;
|
||||
String packageName;
|
||||
Object gh_id;
|
||||
for (int i = 0, size = apkList.size(); i < size; i++) {
|
||||
downloadEntity = DownloadManager.getInstance(context).get(apkList.get(i).getUrl());
|
||||
packageName = apkList.get(i).getPackageName();
|
||||
gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
|
||||
for (ApkEntity apkEntity : apkList) {
|
||||
downloadEntity = DownloadManager.getInstance(context).get(apkEntity.getUrl());
|
||||
if (downloadEntity == null) {
|
||||
if (PackageManager.isInstalled(packageName)
|
||||
&& (gh_id == null || gh_id.equals(gameEntity.getId()))) {
|
||||
if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
updateList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
} else if (!PackageUtils.isSignature(context, packageName)) {
|
||||
pluginList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
} else {
|
||||
installList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
}
|
||||
} else {
|
||||
String platform = apkList.get(i).getPlatform();
|
||||
int id = PlatformUtils.getInstance(context).getPlatformPic(platform);
|
||||
if (id == 0) {
|
||||
String path = PlatformUtils.getInstance(context).getPlatformPicPath(platform);
|
||||
if (path == null) {
|
||||
noPicList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
packageName = apkEntity.getPackageName();
|
||||
if (PackageManager.isInstalled(packageName)) {
|
||||
gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
|
||||
if (gh_id == null || gh_id.equals(gameEntity.getId())) {
|
||||
if (!PackageUtils.isSignature(context, packageName)) {
|
||||
apkEntity.setOrder(8);
|
||||
} else if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
|
||||
apkEntity.setOrder(5);
|
||||
} else {
|
||||
apkEntity.setOrder(2);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
apkEntity.setOrder(1);
|
||||
|
||||
String platform = apkEntity.getPlatform();
|
||||
int id = PlatformUtils.getInstance(context).getPlatformPic(platform);
|
||||
if (id == 0) {
|
||||
String path = PlatformUtils.getInstance(context).getPlatformPicPath(platform);
|
||||
if (path == null) {
|
||||
apkEntity.setOrder(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
|
||||
if (downloadEntity.isPluggable()) {
|
||||
pluginDoneList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
apkEntity.setOrder(10);
|
||||
} else if (downloadEntity.isUpdate()) {
|
||||
updateDoneList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
apkEntity.setOrder(7);
|
||||
} else {
|
||||
doneList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
apkEntity.setOrder(4);
|
||||
}
|
||||
} else {
|
||||
if (downloadEntity.isPluggable()) {
|
||||
pluginDownloadList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
apkEntity.setOrder(9);
|
||||
} else if (downloadEntity.isUpdate()) {
|
||||
updateDownloadList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
apkEntity.setOrder(6);
|
||||
} else {
|
||||
downloadList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
apkEntity.setOrder(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<ApkEntity> list = new ArrayList<>();
|
||||
list.addAll(pluginDoneList);
|
||||
list.addAll(pluginDownloadList);
|
||||
list.addAll(pluginList);
|
||||
list.addAll(updateDoneList);
|
||||
list.addAll(updateDownloadList);
|
||||
list.addAll(updateList);
|
||||
list.addAll(doneList);
|
||||
list.addAll(downloadList);
|
||||
list.addAll(installList);
|
||||
list.addAll(apkList);
|
||||
list.addAll(noPicList);
|
||||
return list;
|
||||
Comparator<ApkEntity> comparator = new Comparator<ApkEntity>() {
|
||||
@Override
|
||||
public int compare(ApkEntity lhs, ApkEntity rhs) {
|
||||
return rhs.getOrder() - lhs.getOrder();
|
||||
}
|
||||
};
|
||||
Collections.sort(apkList, comparator);
|
||||
return apkList;
|
||||
}
|
||||
|
||||
// 接收安装成功的消息,更新界面
|
||||
|
||||
Reference in New Issue
Block a user