插件化安装按钮显示背景修改,下载添加是否是插件字段
This commit is contained in:
@ -37,7 +37,6 @@ import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.MD5Utils;
|
||||
import com.gh.common.util.NetworkUtils;
|
||||
import com.gh.common.util.PackageUtils;
|
||||
import com.gh.common.util.PlatformUtils;
|
||||
@ -51,7 +50,6 @@ import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.ApkEntity;
|
||||
import com.gh.gamecenter.entity.GameCollectionEntity;
|
||||
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.EBReuse;
|
||||
@ -98,7 +96,7 @@ public class DownloadDialog {
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
@Override
|
||||
public void onDataChanged(DownloadEntity downloadEntity) {
|
||||
if (downloadEntity.getName().equals(gameName)
|
||||
if (downloadEntity.getName().equals(gameEntity.getName())
|
||||
&& !"delete".equals(DownloadManager.getInstance(context).getStatus(downloadEntity.getUrl()))) {
|
||||
entryMap.put(downloadEntity.getUrl(), downloadEntity);
|
||||
|
||||
@ -129,16 +127,11 @@ public class DownloadDialog {
|
||||
private ArrayMap<String, String> urlMap;
|
||||
|
||||
private List<ApkEntity> gameApk;
|
||||
private GameEntity gameEntity;
|
||||
private List<GameCollectionEntity> gameCollection;//游戏合集
|
||||
private List<ApkEntity> gameCollectionApk; //和合集合并后的apk集合
|
||||
private String gameName;
|
||||
private String gameIcon;
|
||||
private String gameId;
|
||||
private String gameType;
|
||||
private String entrance;
|
||||
private String mlocation;
|
||||
private TextView download_speed;
|
||||
private TextView download_percentage;
|
||||
private String location;
|
||||
private LinearLayout linearLayout;
|
||||
private ViewPager viewPager;
|
||||
private LinearLayout llCollection;
|
||||
@ -154,62 +147,40 @@ public class DownloadDialog {
|
||||
|
||||
private List<int[]> collectionPositionlist;//存储集合位置
|
||||
|
||||
public void showPopupWindow(View view,
|
||||
GameEntity game,
|
||||
String entrance,
|
||||
String location) {
|
||||
showPopupWindow(view, game, entrance, null, null, location);
|
||||
}
|
||||
|
||||
public void showPopupWindow(View view,
|
||||
GameEntity game,
|
||||
String eStr,
|
||||
TextView dSpeed,
|
||||
TextView dPercentage,
|
||||
String lstr) {
|
||||
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location) {
|
||||
|
||||
if (isShow) {
|
||||
return;
|
||||
}
|
||||
isShow = true;
|
||||
|
||||
this.gameEntity = gameEntity;
|
||||
this.entrance = entrance;
|
||||
this.location = location;
|
||||
|
||||
SharedPreferences sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
|
||||
row = sp.getInt("download_box_row", 3);
|
||||
column = sp.getInt("download_box_column", 3);
|
||||
|
||||
mlocation = lstr;
|
||||
entrance = eStr;
|
||||
download_speed = dSpeed;
|
||||
download_percentage = dPercentage;
|
||||
|
||||
gameName = game.getName();
|
||||
gameIcon = game.getIcon();
|
||||
gameId = game.getId();
|
||||
if (game.getTag() == null || game.getTag().isEmpty()) {
|
||||
gameType = "normal";
|
||||
} else {
|
||||
gameType = "plugin";
|
||||
}
|
||||
|
||||
entryMap = new ArrayMap<>();
|
||||
List<DownloadEntity> entries = DownloadManager.getInstance(context).getAll();
|
||||
for (int i = 0, size = entries.size(); i < size; i++) {
|
||||
if (entries.get(i).getName().equals(gameName)) {
|
||||
if (entries.get(i).getName().equals(gameEntity.getName())) {
|
||||
entryMap.put(entries.get(i).getUrl(), entries.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
gameApk = sortApk(new ArrayList<>(game.getApk()));
|
||||
gameApk = sortApk(new ArrayList<>(gameEntity.getApk()));
|
||||
|
||||
if (game.getCollection() != null){
|
||||
mergeApkCollection(game);
|
||||
if (gameEntity.getCollection() != null){
|
||||
mergeApkCollection(gameEntity);
|
||||
}
|
||||
|
||||
// 一个自定义的布局,作为显示的内容
|
||||
View contentView = View.inflate(context, R.layout.game_download_dialog, null);
|
||||
|
||||
TextView textView = (TextView) contentView.findViewById(R.id.dialog_title);
|
||||
textView.setText(gameName);
|
||||
textView.setText(gameEntity.getName());
|
||||
|
||||
int count = gameApk.size();
|
||||
int vpHeight;
|
||||
@ -449,7 +420,6 @@ public class DownloadDialog {
|
||||
List<ApkEntity> downloadList = new ArrayList<>();
|
||||
List<ApkEntity> noPicList = new ArrayList<>();
|
||||
|
||||
PackageManager packageManager = new PackageManager(context);
|
||||
for (int i = 0, size = apkList.size(); i < size; i++) {
|
||||
String packageName = apkList.get(i).getPackageName();
|
||||
if (PackageManager.isInstalled(packageName)) {
|
||||
@ -457,7 +427,7 @@ public class DownloadDialog {
|
||||
updateList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
} else if (!packageManager.isSignature(packageName)) {
|
||||
} else if (!PackageUtils.isSignature(context, packageName)) {
|
||||
pluginList.add(apkList.remove(i));
|
||||
size--;
|
||||
i--;
|
||||
@ -642,7 +612,7 @@ public class DownloadDialog {
|
||||
public void onConfirem() {
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("操作", "点击插件化安装完成");
|
||||
DataUtils.onEvent(context, "插件化", gameName, kv6);
|
||||
DataUtils.onEvent(context, "插件化", gameEntity.getName(), kv6);
|
||||
|
||||
String path = entryMap.get(apkEntity.getUrl()).getPath();
|
||||
if (FileUtils.isEmptyFile(path)) {
|
||||
@ -730,7 +700,7 @@ public class DownloadDialog {
|
||||
} else if ("启动".equals(status)) {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(context, "游戏启动", gameName, kv);
|
||||
DataUtils.onEvent(context, "游戏启动", gameEntity.getName(), kv);
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(context, apkEntity.getPackageName());
|
||||
} else if ("安装".equals(status) || "安装更新".equals(status)) {
|
||||
@ -795,12 +765,11 @@ public class DownloadDialog {
|
||||
viewHolder.download_item_progressbar.setProgressDrawable(layerDrawable);
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance(
|
||||
context).get(apkEntity.getUrl());
|
||||
PackageManager mPackageManager = new PackageManager(context);
|
||||
if (downloadEntity == null) {
|
||||
viewHolder.download_item_progressbar.setProgress(1000);
|
||||
viewHolder.download_item_tv_status.setText("启动");
|
||||
if (!"normal".equals(gameType)
|
||||
&& !mPackageManager.isSignature(apkEntity.getPackageName())) {
|
||||
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
|
||||
&& !PackageUtils.isSignature(context, apkEntity.getPackageName())) {
|
||||
viewHolder.download_item_tv_status.setText("插件化");
|
||||
} else if (PackageManager.isCanUpdate(apkEntity.getPackageName())) {
|
||||
viewHolder.download_item_tv_status.setText("更新");
|
||||
@ -968,17 +937,7 @@ public class DownloadDialog {
|
||||
DownloadManager.getInstance(context).cancel(apkEntity.getUrl());
|
||||
notifyItemChanged(position);
|
||||
} else {
|
||||
PackageManager manager = new PackageManager(context);
|
||||
if (manager.launchSetup(path)) {
|
||||
context.startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(context, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
context.startActivity(PackageUtils.getUninstallIntent(context, path));
|
||||
}
|
||||
});
|
||||
}
|
||||
PackageUtils.launchSetup(context, path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,35 +946,22 @@ public class DownloadDialog {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
kv.put("状态", "下载开始");
|
||||
DataUtils.onEvent(context, "游戏更新", gameName, kv);
|
||||
DataUtils.onEvent(context, "游戏更新", gameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", gameName);
|
||||
map.put("game_id", gameId);
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("game_id", gameEntity.getId());
|
||||
map.put("method", "更新");
|
||||
map.put("platform", PlatformUtils.getInstance(context)
|
||||
.getPlatformName(apkEntity.getPlatform()));
|
||||
map.put("status", "开始");
|
||||
map.put("location", mlocation);
|
||||
map.put("location", location);
|
||||
map.put("entrance", entrance);
|
||||
map.put("btn_status", "更新");
|
||||
map.put("network", NetworkUtils.getConnectedType(context));
|
||||
DataCollectionManager.onEvent(context, "download", map);
|
||||
|
||||
DownloadEntity downloadEntity = new DownloadEntity();
|
||||
downloadEntity.setUrl(apkEntity.getUrl());
|
||||
downloadEntity.setName(gameName);
|
||||
downloadEntity.setPath(FileUtils.getDownloadPath(context,
|
||||
MD5Utils.getContentMD5(
|
||||
gameName + "_" + System.currentTimeMillis()) + ".apk"));
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameIcon);
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setUpdate(true);
|
||||
downloadEntity.setEntrance(entrance);
|
||||
downloadEntity.setLocation(mlocation);
|
||||
DownloadManager.getInstance(context).add(downloadEntity);
|
||||
DownloadManager.createDownload(context, apkEntity, gameEntity, "更新", entrance, location);
|
||||
}
|
||||
|
||||
//下载插件化游戏
|
||||
@ -1025,89 +971,46 @@ public class DownloadDialog {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
kv.put("状态", "下载开始");
|
||||
DataUtils.onEvent(context, "游戏下载", gameName, kv);
|
||||
DataUtils.onEvent(context, "游戏下载", gameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("版本", apkEntity.getPlatform());
|
||||
kv2.put("状态", "下载开始");
|
||||
kv2.put("位置", entrance + "-开始");
|
||||
DataUtils.onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
DataUtils.onEvent(context, "游戏下载位置", gameEntity.getName(), kv2);
|
||||
|
||||
Map<String, Object> kv3 = new HashMap<>();
|
||||
kv3.put(entrance, "下载数");
|
||||
kv3.put(entrance, "下载开始");
|
||||
DataUtils.onEvent(context, "应用数据", gameName, kv3);
|
||||
|
||||
if ("主页-最新插件".equals(entrance)) {
|
||||
Map<String, Object> kv4 = new HashMap<>();
|
||||
kv4.put(gameName, "下载数");
|
||||
DataUtils.onEvent(context, "主页数据", "最新插件", kv4);
|
||||
} else if ("主页-热门卡牌".equals(entrance)) {
|
||||
Map<String, Object> kv4 = new HashMap<>();
|
||||
kv4.put(gameName, "下载数");
|
||||
DataUtils.onEvent(context, "主页数据", "热门卡牌", kv4);
|
||||
} else if ("主页-新测卡牌".equals(entrance)) {
|
||||
Map<String, Object> kv4 = new HashMap<>();
|
||||
kv4.put(gameName, "下载数");
|
||||
DataUtils.onEvent(context, "主页数据", "新测卡牌", kv4);
|
||||
}
|
||||
DataUtils.onEvent(context, "应用数据", gameEntity.getName(), kv3);
|
||||
|
||||
if (entrance.contains("游戏详情")) {
|
||||
Map<String, Object> kv5 = new HashMap<>();
|
||||
kv5.put("下载", "下载开始");
|
||||
kv5.put("下载", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(context, "插件数据", gameName, kv5);
|
||||
DataUtils.onEvent(context, "插件数据", gameEntity.getName(), kv5);
|
||||
}
|
||||
|
||||
Map<String, Object> kv6 = new HashMap<>();
|
||||
kv6.put("下载", "下载开始");
|
||||
kv6.put("版本", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(context, "插件化", gameName, kv6);
|
||||
DataUtils.onEvent(context, "插件化", gameEntity.getName(), kv6);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", gameName);
|
||||
map.put("game_id", gameId);
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("game_id", gameEntity.getId());
|
||||
map.put("method", "插件化");
|
||||
map.put("platform", PlatformUtils.getInstance(context)
|
||||
.getPlatformName(apkEntity.getPlatform()));
|
||||
map.put("status", "开始");
|
||||
map.put("location", mlocation);
|
||||
map.put("location", location);
|
||||
map.put("entrance", entrance);
|
||||
map.put("btn_status", "插件化");
|
||||
map.put("network", NetworkUtils.getConnectedType(context));
|
||||
DataCollectionManager.onEvent(context, "download", map);
|
||||
|
||||
DownloadEntity downloadEntity = new DownloadEntity();
|
||||
downloadEntity.setUrl(apkEntity.getUrl());
|
||||
downloadEntity.setName(gameName);
|
||||
downloadEntity.setPath(FileUtils.getDownloadPath(context, MD5Utils.getContentMD5(
|
||||
gameName + "_" + System.currentTimeMillis()) + ".apk"));
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameIcon);
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPluggable(true);
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setGameId(gameId);
|
||||
downloadEntity.setEntrance(entrance);
|
||||
downloadEntity.setLocation(mlocation);
|
||||
|
||||
DownloadManager.getInstance(context).add(downloadEntity);
|
||||
|
||||
DownloadManager.getInstance(context).putStatus(downloadEntity.getUrl(), "downloading");
|
||||
|
||||
GameUpdateEntity game = new GameUpdateEntity();
|
||||
game.setId(gameId);
|
||||
game.setName(gameName);
|
||||
game.setIcon(gameIcon);
|
||||
game.setPackageName(apkEntity.getPackageName());
|
||||
game.setSize(apkEntity.getSize());
|
||||
game.setVersion(apkEntity.getVersion());
|
||||
game.setGhVersion(apkEntity.getGhVersion());
|
||||
game.setUrl(apkEntity.getUrl());
|
||||
game.setPlatform(apkEntity.getPlatform());
|
||||
game.setPluggable(true);
|
||||
|
||||
PackageManager.addUpdate(game);
|
||||
DownloadManager.createDownload(context, apkEntity, gameEntity, "插件化", entrance, location);
|
||||
DownloadManager.getInstance(context).putStatus(apkEntity.getUrl(), "downloading");
|
||||
} else {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@ -1120,71 +1023,43 @@ public class DownloadDialog {
|
||||
Map<String, Object> kv = new HashMap<>();
|
||||
kv.put("版本", apkEntity.getPlatform());
|
||||
kv.put("状态", "下载开始");
|
||||
DataUtils.onEvent(context, "游戏下载", gameName, kv);
|
||||
DataUtils.onEvent(context, "游戏下载", gameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<>();
|
||||
kv2.put("版本", apkEntity.getPlatform());
|
||||
kv2.put("状态", "下载开始");
|
||||
kv2.put("位置", entrance + "-开始");
|
||||
DataUtils.onEvent(context, "游戏下载位置", gameName, kv2);
|
||||
DataUtils.onEvent(context, "游戏下载位置", gameEntity.getName(), kv2);
|
||||
|
||||
Map<String, Object> kv3 = new HashMap<>();
|
||||
kv3.put(entrance, "下载数");
|
||||
kv3.put(entrance, "下载开始");
|
||||
DataUtils.onEvent(context, "应用数据", gameName, kv3);
|
||||
|
||||
if ("主页-最新插件".equals(entrance)) {
|
||||
Map<String, Object> kv4 = new HashMap<>();
|
||||
kv4.put(gameName, "下载数");
|
||||
DataUtils.onEvent(context, "主页数据", "最新插件", kv4);
|
||||
} else if ("主页-热门卡牌".equals(entrance)) {
|
||||
Map<String, Object> kv4 = new HashMap<>();
|
||||
kv4.put(gameName, "下载数");
|
||||
DataUtils.onEvent(context, "主页数据", "热门卡牌", kv4);
|
||||
} else if ("主页-新测卡牌".equals(entrance)) {
|
||||
Map<String, Object> kv4 = new HashMap<>();
|
||||
kv4.put(gameName, "下载数");
|
||||
DataUtils.onEvent(context, "主页数据", "新测卡牌", kv4);
|
||||
}
|
||||
DataUtils.onEvent(context, "应用数据", gameEntity.getName(), kv3);
|
||||
|
||||
if (entrance.contains("游戏详情")) {
|
||||
Map<String, Object> kv5 = new HashMap<>();
|
||||
kv5.put("下载", "下载量");
|
||||
kv5.put("下载", apkEntity.getPlatform());
|
||||
DataUtils.onEvent(context, "插件数据", gameName, kv5);
|
||||
DataUtils.onEvent(context, "插件数据", gameEntity.getName(), kv5);
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("game", gameName);
|
||||
map.put("game_id", gameId);
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("game_id", gameEntity.getId());
|
||||
map.put("method", "正常");
|
||||
map.put("platform", PlatformUtils.getInstance(context)
|
||||
.getPlatformName(apkEntity.getPlatform()));
|
||||
map.put("status", "开始");
|
||||
map.put("location", mlocation);
|
||||
map.put("location", location);
|
||||
map.put("entrance", entrance);
|
||||
map.put("btn_status", "下载");
|
||||
map.put("network", NetworkUtils.getConnectedType(context));
|
||||
DataCollectionManager.onEvent(context, "download", map);
|
||||
|
||||
DownloadEntity downloadEntity = new DownloadEntity();
|
||||
downloadEntity.setUrl(apkEntity.getUrl());
|
||||
downloadEntity.setName(gameName);
|
||||
downloadEntity.setPath(FileUtils.getDownloadPath(context, MD5Utils.getContentMD5(
|
||||
gameName + "_" + System.currentTimeMillis()) + ".apk"));
|
||||
downloadEntity.setETag(apkEntity.getEtag());
|
||||
downloadEntity.setIcon(gameIcon);
|
||||
downloadEntity.setPlatform(apkEntity.getPlatform());
|
||||
downloadEntity.setPackageName(apkEntity.getPackageName());
|
||||
downloadEntity.setGameId(gameId);
|
||||
downloadEntity.setEntrance(entrance);
|
||||
downloadEntity.setLocation(mlocation);
|
||||
|
||||
DownloadManager.getInstance(context).add(downloadEntity);
|
||||
DownloadManager.createDownload(context, apkEntity, gameEntity, "下载", entrance, location);
|
||||
DownloadManager.getInstance(context).putStatus(apkEntity.getUrl(), "downloading");
|
||||
|
||||
download_item_tv_status.setText("0.0%");
|
||||
|
||||
DownloadManager.getInstance(context).putStatus(downloadEntity.getUrl(), "downloading");
|
||||
} else {
|
||||
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user