去掉MainActivity的entryMap、uninstallMap,使用下载是添加packageNam来进行获取DownloadEntity

This commit is contained in:
huangzhuanghua
2016-09-23 14:49:44 +08:00
parent 154f7b5a54
commit 39350b2cfb
21 changed files with 186 additions and 330 deletions

View File

@ -47,7 +47,6 @@ import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.MainActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameCollectionEntity;
@ -55,7 +54,6 @@ import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBPutUrl;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.manager.PackageManager;
@ -653,7 +651,6 @@ public class DownloadDialog {
DownloadManager.getInstance(context).cancel(apkEntity.getUrl());
adapter.notifyItemChanged(location);
} else {
MainActivity.uninstallMap.put(PackageUtils.getPackageNameByPath(context, path), path);
context.startActivity(PackageUtils.getUninstallIntent(context, path));
}
}
@ -865,8 +862,6 @@ public class DownloadDialog {
|| status.equals(DownloadStatus.waiting)) {
viewHolder.download_item_tv_status.setText("下载中");
} else if (status.equals(DownloadStatus.done)) {
EventBus.getDefault().post(new EBPutUrl(PackageUtils.getPackageNameByPath(
context, downloadEntity.getPath()), downloadEntity.getUrl()));
viewHolder.download_item_tv_status.setText("安装");
} else if (status.equals(DownloadStatus.cancel)
|| status.equals(DownloadStatus.hijack)) {
@ -975,14 +970,11 @@ public class DownloadDialog {
} else {
PackageManager manager = new PackageManager(context);
if (manager.launchSetup(path)) {
EventBus.getDefault().post(new EBPutUrl(apkEntity.getPackageName(), apkEntity.getUrl()));
context.startActivity(PackageUtils.getInstallIntent(path));
} else {
DialogUtils.showPluginDialog(context, new DialogUtils.ConfiremListener() {
@Override
public void onConfirem() {
MainActivity.uninstallMap.put(
PackageUtils.getPackageNameByPath(context, path), path);
context.startActivity(PackageUtils.getUninstallIntent(context, path));
}
});
@ -1006,6 +998,7 @@ public class DownloadDialog {
downloadEntity.setETag(apkEntity.getEtag());
downloadEntity.setIcon(gameIcon);
downloadEntity.setPlatform(apkEntity.getPlatform());
downloadEntity.setPackageName(apkEntity.getPackageName());
downloadEntity.setUpdate(true);
DownloadManager.getInstance(context).add(downloadEntity);
}
@ -1165,6 +1158,7 @@ public class DownloadDialog {
downloadEntity.setETag(apkEntity.getEtag());
downloadEntity.setIcon(gameIcon);
downloadEntity.setPlatform(apkEntity.getPlatform());
downloadEntity.setPackageName(apkEntity.getPackageName());
downloadEntity.setGameId(gameId);
HashMap<String, String> meta = new HashMap<>();
meta.put("entrance", entrance);