大于两个的if分支,使用switch
This commit is contained in:
@ -329,48 +329,55 @@ public class DownloadItemUtils {
|
||||
final String location) {
|
||||
|
||||
String str = downloadBtn.getText().toString();
|
||||
if ("下载".equals(str)) {
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
download(context, gameEntity, downloadBtn, entrance, location);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
download(context, gameEntity, downloadBtn, entrance, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if ("插件化".equals(str)) {
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if ("安装".equals(str)) {
|
||||
install(context, gameEntity, position, adapter);
|
||||
} else if ("启动".equals(str)) {
|
||||
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
switch (str) {
|
||||
case "下载":
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
download(context, gameEntity, downloadBtn, entrance, location);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
download(context, gameEntity, downloadBtn, entrance, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "插件化":
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
plugin(context, gameEntity, downloadBtn, entrance, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "安装":
|
||||
install(context, gameEntity, position, adapter);
|
||||
break;
|
||||
case "启动":
|
||||
DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location);
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
} else if ("下载中".equals(str)) {
|
||||
context.startActivity(
|
||||
DownloadManagerActivity.getDownloadMangerIntent(context, gameEntity.getApk().get(0).getUrl(), entrance + "+(" + location.split(":")[0] + ")"));
|
||||
} else if ("更新".equals(str)) {
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
update(context, gameEntity, entrance, location);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
update(context, gameEntity, entrance, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName());
|
||||
break;
|
||||
case "下载中":
|
||||
context.startActivity(
|
||||
DownloadManagerActivity.getDownloadMangerIntent(context, gameEntity.getApk().get(0).getUrl(), entrance + "+(" + location.split(":")[0] + ")"));
|
||||
break;
|
||||
case "更新":
|
||||
if (NetworkUtils.isWifiConnected(context)) {
|
||||
update(context, gameEntity, entrance, location);
|
||||
} else {
|
||||
DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
update(context, gameEntity, entrance, location);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user