feat:【V5.16.0】光环下载进度条优化—客户端 https://jira.shanqu.cc/browse/GHZS-84

This commit is contained in:
叶子维
2022-11-21 15:28:01 +08:00
parent 6244387c79
commit 8564bc95e9
33 changed files with 737 additions and 632 deletions

View File

@ -0,0 +1 @@
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_dark","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_dark","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_dark","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.156862750649,0.533333361149,0.878431379795,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}

View File

@ -0,0 +1 @@
{"v":"5.9.1","fr":60,"ip":0,"op":100,"w":64,"h":64,"nm":"多版本下载提示_light","ddd":0,"assets":[{"id":"comp_0","nm":"arrow 合成_light","fr":60,"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.333],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":24,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.667],"y":[0]},"t":76,"s":[100]},{"t":100,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.333,"y":1},"o":{"x":0.364,"y":0},"t":0,"s":[28,-12,0],"to":[0,6.382,0],"ti":[0,-0.284,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":24,"s":[28,28,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.667,"y":0},"t":76,"s":[28,28,0],"to":[0,6.667,0],"ti":[0,-6.667,0]},{"t":100,"s":[28,68,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,2],[0,-2]],"c":false},"ix":2},"nm":"路径 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-2,0],[0,2]],"c":false},"ix":2},"nm":"路径 2","mn":"ADBE Vector Shape - Group","hd":false},{"ind":2,"ty":"sh","ix":3,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2,0],[0,2]],"c":false},"ix":2},"nm":"路径 3","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.333,0.333],"y":[1,1]},"o":{"x":[0.333,0.333],"y":[0,0]},"t":0,"s":[80,120]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":24,"s":[100,100]},{"i":{"x":[0.667,0.667],"y":[1,1]},"o":{"x":[0.667,0.667],"y":[0,0]},"t":76,"s":[100,100]},{"t":100,"s":[80,120]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"组 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Vector 97","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}]}],"layers":[{"ddd":0,"ind":1,"ty":0,"nm":"arrow 合成_light","refId":"comp_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[28,28,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"w":56,"h":56,"ip":0,"op":100,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"base","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[32,32,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[15,15],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"椭圆路径 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.141176477075,0.588235318661,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":1,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"stroke","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"filling","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[400,400],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"变换"}],"nm":"Ellipse 44","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"bm":0}],"markers":[]}

View File

@ -15,12 +15,14 @@ import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
import com.gh.gamecenter.common.constant.Constants;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.core.utils.SPUtils;
import com.gh.gamecenter.common.entity.LinkEntity;
import com.gh.gamecenter.entity.PluginLocation;
import com.gh.gamecenter.manager.PackagesManager;
import com.gh.vspace.VHelper;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.DownloadStatus;
/**
* Created by khy on 27/06/17.
@ -36,6 +38,10 @@ public class DetailDownloadUtils {
viewHolder.getOverlayTv().setVisibility(View.GONE);
}
if (viewHolder.mMultiVersionDownloadTv != null) {
viewHolder.mMultiVersionDownloadTv.setVisibility(View.GONE);
}
if (viewHolder.gameEntity != null
&& Config.isShowDownload(viewHolder.gameEntity.getId())
&& !"光环助手".equals(viewHolder.gameEntity.getName())) {
@ -171,8 +177,34 @@ public class DetailDownloadUtils {
}
viewHolder.mDownloadPb.setText(downloadText);
} else {
viewHolder.mDownloadPb.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord) + " >");
viewHolder.mMultiVersionDownloadTv.setText("选择下载你的版本" + (TextUtils.isEmpty(downloadAddWord) ? "" : "-" + downloadAddWord));
viewHolder.mMultiVersionDownloadTv.setVisibility(View.VISIBLE);
viewHolder.mDownloadPb.setText("");
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(viewHolder.gameEntity);
if (downloadEntity != null) {
switch (downloadEntity.getStatus()) {
case downloading:
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, true);
break;
case done:
case pause:
case waiting:
case timeout:
case subscribe:
case neterror:
case overflow:
viewHolder.mDownloadTips.setVisibility(View.VISIBLE);
ExtensionsKt.setDownloadTipsAnimation(viewHolder.mDownloadTips, false);
break;
default:
viewHolder.mDownloadTips.setVisibility(View.GONE);
break;
}
} else {
viewHolder.mDownloadTips.setVisibility(View.GONE);
}
}
if (isCheck && viewHolder.gameEntity.getApk().size() == 1) {
@ -203,10 +235,14 @@ public class DetailDownloadUtils {
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
viewHolder.mDownloadPb.setText("解压中" + percent + "%");
viewHolder.mDownloadPb.setText("游戏解压中 " + percent + "%");
viewHolder.mDownloadPb.setProgress((int) (Float.valueOf(percent) * 10));
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
return;
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
viewHolder.mDownloadPb.setText(R.string.install);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.XAPK_FAILURE);
return;
}
viewHolder.mDownloadPb.setProgress((int) (viewHolder.downloadEntity.getPercent() * 10));
@ -223,11 +259,9 @@ public class DetailDownloadUtils {
case downloading:
case pause:
case overflow:
if (SPUtils.getBoolean(Constants.SP_USE_BROWSER_TO_INSTALL)) {
viewHolder.mDownloadPb.setText(R.string.browser_install_downloading);
} else {
viewHolder.mDownloadPb.setText(R.string.downloading);
}
String downloadingText = "游戏加载中 " + downloadEntity.getPercent() + "%";
String resumeText = "继续加载 " + downloadEntity.getPercent() + "%";
viewHolder.mDownloadPb.setText(downloadEntity.getStatus() == DownloadStatus.downloading ? downloadingText : resumeText);
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
} else {
@ -240,9 +274,9 @@ public class DetailDownloadUtils {
case subscribe:
viewHolder.mDownloadPb.setText(R.string.waiting);
if (downloadEntity.isPluggable() && PackagesManager.INSTANCE.isInstalled(downloadEntity.getPackageName())) {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_PLUGIN);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
} else {
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
viewHolder.mDownloadPb.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
}
break;
case done:

View File

@ -19,26 +19,25 @@ import com.gh.common.simulator.SimulatorDownloadManager
import com.gh.common.simulator.SimulatorGameManager
import com.gh.common.view.DownloadButton
import com.gh.common.xapk.XapkInstaller
import com.gh.common.xapk.XapkInstaller.cancelUnzipTask
import com.gh.common.xapk.XapkUnzipStatus
import com.gh.download.DownloadManager
import com.gh.download.dialog.DownloadDialog
import com.gh.gamecenter.DownloadManagerActivity
import com.gh.gamecenter.R
import com.gh.gamecenter.WebActivity
import com.gh.gamecenter.adapter.viewholder.GameViewHolder
import com.gh.gamecenter.common.callback.CancelListener
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.constant.EntranceConsts
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.utils.*
import com.gh.gamecenter.core.utils.*
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.energy.EnergyBridge
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.PluginLocation
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment
import com.gh.gamecenter.manager.PackagesManager
import com.gh.gamecenter.teenagermode.TeenagerModeActivity
import com.gh.vspace.VDownloadManagerActivity
import com.gh.vspace.VHelper
import com.lightgame.download.DownloadConfig
import com.lightgame.download.DownloadEntity
@ -126,7 +125,7 @@ object DownloadItemUtils {
holder.gameDownloadBtn.text = "已预约"
holder.gameDownloadBtn.visibility = View.VISIBLE
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.RESERVED
updateItemViewStatus(holder, false, null, null)
updateItemViewStatus(holder, null, null)
}
}
@ -166,7 +165,7 @@ object DownloadItemUtils {
) {
// 显示预约
if (gameEntity.isReservable) {
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateDownloadButton(
context,
holder.gameDownloadBtn,
@ -177,11 +176,16 @@ object DownloadItemUtils {
return
}
if (gameEntity.getApk().isEmpty() || gameEntity.downloadOffStatus != null) {
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
holder.multiVersionDownloadTv?.visibility = View.GONE
holder.gameDownloadTips?.visibility = View.GONE
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
} else if (gameEntity.getApk().size == 1) {
updateNormalItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
holder.multiVersionDownloadTv?.visibility = View.GONE
holder.gameDownloadTips?.visibility = View.GONE
updateNormalItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
} else {
updatePluginItem(context, holder, gameEntity, isShowPlatform, briefStyle, isShowRecommendStar)
holder.multiVersionDownloadTv?.visibility = View.VISIBLE
updatePluginItem(context, holder, gameEntity, briefStyle, isShowRecommendStar)
}
updateDownloadButton(
context,
@ -265,31 +269,20 @@ object DownloadItemUtils {
if (downloadEntity != null) {
downloadBtn.apply {
val status = downloadEntity.status
if (status == DownloadStatus.downloading) {
setText(R.string.downloading)
buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
} else if (status == DownloadStatus.waiting) {
setText(R.string.waiting)
buttonStyle = DownloadButton.ButtonStyle.WAITING
} else if (status == DownloadStatus.pause || status == DownloadStatus.timeout || status == DownloadStatus.neterror || status == DownloadStatus.subscribe || status == DownloadStatus.overflow) {
setText(R.string.downloading)
buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
} else if (status == DownloadStatus.done) {
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
setText(R.string.unzipping)
buttonStyle = DownloadButton.ButtonStyle.NORMAL
return
}
if (status == DownloadStatus.done) {
if (downloadEntity.isSimulatorGame() && gameEntity.simulator != null) {
GameUtils.setDownloadBtnStatus(context, gameEntity, downloadBtn, pluginLocation)
} else if (downloadEntity.isVGame()) {
if (PackagesManager.isCanUpdate(downloadEntity.gameId, downloadEntity.packageName)) {
setText(R.string.update)
} else {
setText(R.string.launch)
}
buttonStyle =
if (PackagesManager.isCanUpdate(downloadEntity.gameId, downloadEntity.packageName)) {
setText(R.string.update)
DownloadButton.ButtonStyle.NORMAL
} else {
setText(R.string.launch)
DownloadButton.ButtonStyle.LAUNCH_OR_OPEN
}
} else {
buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
setText(R.string.install)
}
buttonStyle =
@ -310,8 +303,10 @@ object DownloadItemUtils {
// 更新正常的条目只有一个apk包
private fun updateNormalItem(
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
isShowPlatform: Boolean, briefStyle: String?,
context: Context,
holder: GameViewHolder,
gameEntity: GameEntity,
briefStyle: String?,
isShowRecommendStar: Boolean = false
) {
val entryMap: ArrayMap<String, DownloadEntity> = gameEntity.getEntryMap()
@ -322,23 +317,25 @@ object DownloadItemUtils {
if (downloadEntity.isSimulatorGame()) {
if (downloadEntity.status != DownloadStatus.done) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, true)
changeStatus(context, holder, downloadEntity)
return
}
} else {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, true, isShowRecommendStar)
changeStatus(context, holder, downloadEntity)
return
}
}
}
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
}
// 更新插件的条目有多个apk包
private fun updatePluginItem(
context: Context, holder: GameViewHolder, gameEntity: GameEntity,
isShowPlatform: Boolean, briefStyle: String?,
context: Context,
holder: GameViewHolder,
gameEntity: GameEntity,
briefStyle: String?,
isShowRecommendStar: Boolean = false
) {
val entryMap = gameEntity.getEntryMap()
@ -351,151 +348,131 @@ object DownloadItemUtils {
}
if (downloadEntity != null) {
// 更改进度条和提示文本的状态
changeStatus(context, holder, downloadEntity, isShowPlatform, false, isShowRecommendStar)
changeStatus(context, holder, downloadEntity, gameEntity.getApk().size > 1)
return
}
}
updateItemViewStatus(holder, false, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
updateItemViewStatus(holder, briefStyle, gameEntity.columnRecommend, isShowRecommendStar)
}
// 更改进度条和提示文本的状态
fun changeStatus(
context: Context, holder: GameViewHolder, downloadEntity: DownloadEntity,
isShowPlatform: Boolean, isNormal: Boolean, isShowRecommendStar: Boolean = false
context: Context,
holder: GameViewHolder,
downloadEntity: DownloadEntity,
isMultiVersion: Boolean = false
) {
val status = downloadEntity.status
// 畅玩游戏下载完成时不再需要显示进度条
val shouldShowDownload = !(downloadEntity.isVGame() && status == DownloadStatus.done)
val platform = PlatformUtils.getInstance(context).getPlatformName(downloadEntity.platform)
updateItemViewStatus(holder, shouldShowDownload, null, null, isShowRecommendStar)
holder.gameProgressbar.progressDrawable = R.drawable.progressbar_bg_style.toDrawable()
if (status == DownloadStatus.downloading) {
if (DownloadStatus.pause != DownloadManager.getInstance().getStatus(downloadEntity.url)) {
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format(
"%s - %s(剩%s)", platform,
SpeedUtils.getSpeed(downloadEntity.speed),
SpeedUtils.getRemainTime(
downloadEntity.size,
downloadEntity.progress,
downloadEntity.speed * 1024
)
)
when (downloadEntity.status) {
DownloadStatus.downloading -> {
if (isMultiVersion) {
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
val darkMode = (holder.gameDownloadTips?.getTag(R.string.is_dark_mode_on_id) as? Boolean) ?: false
val isDarkModeChanged = DarkModeUtils.isDarkModeOn(context) != darkMode
if (holder.gameDownloadTips?.visibility == View.GONE || holder.gameDownloadTips?.isAnimating == false || isDarkModeChanged) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(true)
}
holder.gameDownloadTips?.setTag(R.string.is_dark_mode_on_id, DarkModeUtils.isDarkModeOn(context))
} else {
holder.gameDownloadSpeed.text = String.format(
"%s(剩%s)", SpeedUtils.getSpeed(downloadEntity.speed),
SpeedUtils.getRemainTime(
downloadEntity.size,
downloadEntity.progress,
downloadEntity.speed * 1024
)
)
holder.gameDownloadTips?.visibility = View.GONE
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
if (DownloadStatus.pause != DownloadManager.getInstance().getStatus(downloadEntity.url)) {
holder.gameDownloadBtn.progress = (downloadEntity.percent * 10).toInt()
holder.gameDownloadBtn.text = downloadEntity.percent.toString() + "%"
}
}
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
}
} else if (status == DownloadStatus.waiting) {
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format("%s - 等待", platform)
} else {
holder.gameDownloadSpeed.text = "等待"
DownloadStatus.waiting -> {
if (isMultiVersion) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
}
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.WAITING
holder.gameDownloadBtn.text = context.getString(R.string.waiting)
}
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
} else if (status == DownloadStatus.pause || status == DownloadStatus.timeout || status == DownloadStatus.neterror || status == DownloadStatus.subscribe || status == DownloadStatus.overflow) {
holder.gameProgressbar.progress = (downloadEntity.percent * 10).toInt()
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format("%s - 暂停", platform)
} else {
holder.gameDownloadSpeed.text = "暂停"
DownloadStatus.pause,
DownloadStatus.timeout,
DownloadStatus.neterror,
DownloadStatus.subscribe,
DownloadStatus.overflow -> {
if (isMultiVersion) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
}
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.NORMAL
holder.gameDownloadBtn.text = context.getString(R.string.resume)
}
holder.gameDownloadPercentage.text = downloadEntity.percent.toString() + "%"
} else if (status == DownloadStatus.done) {
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
holder.gameProgressbar.progressDrawable =
context.resources.getDrawable(R.drawable.progressbar_xapk_style)
holder.gameDownloadSpeed.setText(R.string.unzipping)
holder.gameProgressbar.progress = (java.lang.Float.valueOf(percent) * 10).toInt()
holder.gameDownloadPercentage.text = "$percent%"
return
DownloadStatus.done -> {
if (isMultiVersion) {
holder.gameDownloadTips?.visibility = View.VISIBLE
holder.gameDownloadTips?.setDownloadTipsAnimation(false)
}
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
val percent = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_PERCENT]
holder.gameDownloadBtn.progress = (java.lang.Float.valueOf(percent) * 10).toInt()
holder.gameDownloadBtn.text = "$percent%"
return
} else if (XapkUnzipStatus.FAILURE.name == xapkStatus) {
holder.gameDownloadBtn.setText(R.string.install)
holder.gameDownloadBtn.buttonStyle = DownloadButton.ButtonStyle.INSTALL_NORMAL
return
}
holder.gameDownloadBtn.progress = 1000
holder.gameDownloadBtn.setText(R.string.hundred_percent)
}
holder.gameProgressbar.progress = 1000
if (isShowPlatform && platform != null) {
holder.gameDownloadSpeed.text = String.format("%s - 下载完成", platform)
} else {
holder.gameDownloadSpeed.text = "下载完成"
else -> {
holder.gameDownloadTips?.visibility = View.GONE
}
holder.gameDownloadPercentage.setText(R.string.hundred_percent)
}
}
private fun updateItemViewStatus(
holder: GameViewHolder,
showDownload: Boolean,
briefStyle: String?,
recommendStyle: LinkEntity?,
isShowRecommendStar: Boolean = false
) {
if (showDownload) {
// 推荐指数优先,现暂时为游戏单详情列表游戏使用
if (isShowRecommendStar && holder.recommendStarInfo != null) {
holder.recommendStarInfo!!.visibility = View.VISIBLE
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes.visibility = View.GONE
holder.gameProgressbar.visibility = View.VISIBLE
holder.gameInfo.visibility = View.VISIBLE
return
}
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
if (briefStyle != null && recommendStyle != null && briefStyle.contains("recommend")) {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.VISIBLE
}
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes.visibility = View.GONE
holder.recommendTv.text = recommendStyle.text
if (TextUtils.isEmpty(recommendStyle.icon)) {
holder.recommendIv.visibility = View.GONE
holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0)
} else {
holder.recommendIv.visibility = View.VISIBLE
ImageUtils.display(holder.recommendIv, recommendStyle.icon)
}
return
} else {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.GONE
}
if (holder.recommendStarInfo != null) {
holder.recommendStarInfo!!.visibility = View.GONE
}
}
if (briefStyle != null && briefStyle.contains("star")) {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
} else {
holder.gameProgressbar.visibility = View.GONE
holder.gameInfo.visibility = View.GONE
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
}
// 推荐指数优先,现暂时为游戏单详情列表游戏使用
if (isShowRecommendStar && holder.recommendStarInfo != null) {
holder.recommendStarInfo!!.visibility = View.VISIBLE
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes.visibility = View.GONE
return
}
// 推荐优先,有推荐内容时不执行下面的 star 和 brief 代码块
if (briefStyle != null && recommendStyle != null && briefStyle.contains("recommend")) {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.VISIBLE
}
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
holder.gameDes.visibility = View.GONE
holder.recommendTv.text = recommendStyle.text
if (TextUtils.isEmpty(recommendStyle.icon)) {
holder.recommendIv.visibility = View.GONE
holder.recommendContainer?.setPadding(6F.dip2px(), 0, 8F.dip2px(), 0)
} else {
holder.recommendIv.visibility = View.VISIBLE
ImageUtils.display(holder.recommendIv, recommendStyle.icon)
}
return
} else {
if (holder.recommendContainer != null) {
holder.recommendContainer!!.visibility = View.GONE
}
}
if (briefStyle != null && briefStyle.contains("star")) {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.VISIBLE
} else {
if (holder.gameRating != null) holder.gameRating!!.visibility = View.GONE
}
// 缺省情况下回落到游戏简介
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
holder.gameDes.visibility = View.VISIBLE
} else {
holder.gameDes.visibility = View.GONE
}
// 缺省情况下回落到游戏简介
if (TextUtils.isEmpty(briefStyle) || briefStyle!!.contains("brief") || briefStyle.contains("recommend")) {
holder.gameDes.visibility = View.VISIBLE
} else {
holder.gameDes.visibility = View.GONE
}
}
@ -911,15 +888,32 @@ object DownloadItemUtils {
}
})
} else {
if (gameEntity.isVGame()) {
context.startActivity(VDownloadManagerActivity.getIntent(context, true))
} else {
context.startActivity(
DownloadManagerActivity.getDownloadMangerIntent(
context,
apk.url, entrance + "+(" + location.split(":").toTypedArray()[0] + ")"
)
)
val entryMap = gameEntity.getEntryMap()
if (entryMap.isNotEmpty()) {
val queue = DownloadManager.getInstance().getQueue(gameEntity.name)
val downloadEntity = if (queue != null && !queue.isEmpty()) {
entryMap[queue.peek()]
} else {
entryMap[entryMap.keyAt(0)]
}
if (downloadEntity != null) {
val xapkStatus = downloadEntity.meta[XapkInstaller.XAPK_UNZIP_STATUS]
if (XapkUnzipStatus.UNZIPPING.name == xapkStatus) {
cancelUnzipTask(downloadEntity)
return
}
when (str) {
context.getString(R.string.resume) -> {
DownloadManager.getInstance().resume(downloadEntity, true)
}
context.getString(R.string.waiting) -> {
Utils.toast(context, "最多只能同时下载三个任务,请稍等")
}
else -> {
DownloadManager.getInstance().pause(downloadEntity.url)
}
}
}
}
}
}
@ -948,7 +942,7 @@ object DownloadItemUtils {
traceEvent
)
Utils.toast(context, gameEntity.name + "已加入下载队列")
downloadBtn.setText(R.string.downloading)
downloadBtn.text = "0%"
downloadBtn.buttonStyle = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
DeviceRemindDialog.showDeviceRemindDialog(context, gameEntity)
} else {

View File

@ -1,16 +1,17 @@
package com.gh.common.util;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.widget.TextView;
import com.gh.common.view.DownloadButton;
import com.gh.gamecenter.core.AppExecutor;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.gh.common.constant.Config;
import com.gh.common.simulator.SimulatorGameManager;
import com.gh.common.view.DownloadButton;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.R;
import com.gh.gamecenter.core.AppExecutor;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.ApkLink;
import com.gh.gamecenter.entity.GameCollectionEntity;
@ -26,9 +27,6 @@ import com.lightgame.download.DownloadStatus;
import java.util.ArrayList;
import java.util.List;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
public class GameUtils {
/**
@ -80,7 +78,7 @@ public class GameUtils {
@WorkerThread
public static String getDownloadBtnText(Context context, GameEntity gameEntity, PluginLocation pluginLocation) {
if (gameEntity.getApk().size() > 1) {
return context.getString(R.string.expand);
return "";
}
int doneCount = 0; // 下载完成数量

View File

@ -45,12 +45,7 @@ class DownloadButton @JvmOverloads constructor(
}
var text: String
get() {
if (showProgress && mText.contains("%")) {
return context.getString(R.string.downloading)
}
return mText
}
get() = mText
set(value) {
mText = value
invalidate()
@ -123,11 +118,7 @@ class DownloadButton @JvmOverloads constructor(
}
fun setText(@StringRes res: Int) {
text = if (mShowPercent && res == R.string.downloading) {
"${progress / 10}%"
} else {
context.getString(res)
}
text = context.getString(res)
invalidate()
}
@ -156,6 +147,7 @@ class DownloadButton @JvmOverloads constructor(
when (buttonStyle) {
ButtonStyle.NORMAL,
ButtonStyle.INSTALL_NORMAL,
ButtonStyle.XAPK_FAILURE,
ButtonStyle.NONE_WITH_HINT,
ButtonStyle.H5_GAME,
ButtonStyle.SPECIAL_DOWNLOAD,
@ -187,6 +179,7 @@ class DownloadButton @JvmOverloads constructor(
progress = 0
mDefaultColor = R.color.white.toColor(context)
}
ButtonStyle.FAILURE,
ButtonStyle.NONE,
ButtonStyle.RESERVED -> {
progressDrawable = null
@ -201,6 +194,8 @@ class DownloadButton @JvmOverloads constructor(
progress = 0
mDefaultColor = R.color.white.toColor(context)
}
ButtonStyle.XAPK_SUCCESS,
ButtonStyle.XAPK_UNZIPPING,
ButtonStyle.DOWNLOADING_NORMAL -> {
if (showProgress) {
progressDrawable =
@ -239,18 +234,6 @@ class DownloadButton @JvmOverloads constructor(
progress = 0
mDefaultColor = R.color.theme_font.toColor(context)
}
ButtonStyle.FAILURE -> {
progressDrawable = null
background = R.drawable.game_item_btn_pause_style.toDrawable(context)
progress = 0
mDefaultColor = R.color.white.toColor(context)
}
ButtonStyle.XAPK_FAILURE,
ButtonStyle.XAPK_SUCCESS,
ButtonStyle.XAPK_UNZIPPING -> {
mDefaultColor = R.color.white.toColor(context)
progressDrawable = R.drawable.progressbar_xapk_detail_style.toDrawable(context)
}
}
mPaintColor = mDefaultColor
}

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
@ -11,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import com.airbnb.lottie.LottieAnimationView;
import com.gh.common.chain.BrowserInstallHandler;
import com.gh.common.chain.CertificationHandler;
import com.gh.common.chain.ChainBuilder;
@ -36,6 +38,8 @@ import com.gh.common.simulator.SimulatorDownloadManager;
import com.gh.common.simulator.SimulatorGameManager;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DirectUtils;
import com.gh.common.xapk.XapkInstaller;
import com.gh.common.xapk.XapkUnzipStatus;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.utils.DataLogUtils;
import com.gh.common.util.DetailDownloadUtils;
@ -65,6 +69,7 @@ import com.gh.gamecenter.entity.SimulatorEntity;
import com.gh.gamecenter.eventbus.EBScroll;
import com.gh.gamecenter.gamedetail.GameDetailFragment;
import com.gh.gamecenter.gamedetail.dialog.GamePermissionDialogFragment;
import com.gh.gamecenter.manager.PackagesManager;
import com.gh.gamecenter.teenagermode.TeenagerModeActivity;
import com.gh.vspace.VDownloadManagerActivity;
import com.gh.vspace.VHelper;
@ -96,14 +101,18 @@ public class DetailViewHolder {
public View downloadBottom;
public DownloadButton mDownloadPb;
public LottieAnimationView mDownloadTips;
public TextView mOverlayTv; // 额外的文字 (用于一些含图片的情况)
public TextView mMultiVersionDownloadTv; // 多版本下载文字
// 注意View的命名
public DetailViewHolder(View view, GameEntity gameEntity, DownloadEntity downloadEntity,
boolean isNewsDetail, String entrance, String name, String title, @Nullable ExposureEvent traceEvent) {
downloadBottom = view.findViewById(R.id.detail_ll_bottom);
mDownloadPb = view.findViewById(R.id.detail_progressbar);
mDownloadTips = view.findViewById(R.id.downloadTipsLottie);
mOverlayTv = view.findViewById(R.id.overlayTv);
mMultiVersionDownloadTv = view.findViewById(R.id.multiVersionDownloadTv);
this.gameEntity = gameEntity;
this.downloadEntity = downloadEntity;
@ -193,6 +202,37 @@ public class DetailViewHolder {
}
v.setTag(null);
if (mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_NORMAL
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_PLUGIN
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.LAUNCH_OR_OPEN) {
EventBus.getDefault().post(new EBScroll(Constants.EB_GAME_DETAIL, mGameEntity.getId()));
}
if (mDownloadEntity == null) {
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity);
}
if (mDownloadEntity != null) {
String xapkStatus = mDownloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
XapkInstaller.cancelUnzipTask(mDownloadEntity);
return;
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
if (mDownloadEntity != null) {
final String path = mDownloadEntity.getPath();
if (FileUtils.isEmptyFile(path)) {
Utils.toast(mViewHolder.context, R.string.install_failure_hint);
DownloadManager.getInstance().cancel(mDownloadEntity.getUrl());
} else {
PackageInstaller.install(mViewHolder.context, mDownloadEntity);
}
}
});
return;
}
}
switch (mViewHolder.mDownloadPb.getButtonStyle()) {
case NONE_WITH_HINT:
case NONE:
@ -269,7 +309,7 @@ public class DetailViewHolder {
if (mGameEntity.getApk().size() == 1) {
//启动模拟器游戏
if (SimulatorGameManager.isSimulatorGame(mGameEntity)) {
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(mViewHolder.context)){
if (NewSimulatorGameManager.shouldShowUpdateNewSimulatorAlert(mViewHolder.context)) {
NewSimulatorGameManager.showUpdateNewsSimulator(mViewHolder.context, null);
return;
}
@ -336,7 +376,7 @@ public class DetailViewHolder {
PermissionHelper.checkStoragePermissionBeforeAction(mViewHolder.context, () -> {
if (mDownloadEntity == null) {
mDownloadEntity = DownloadManager.getInstance().getDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity);
}
if (mDownloadEntity != null) {
@ -412,6 +452,24 @@ public class DetailViewHolder {
DirectUtils.directForumDetail(mViewHolder.context, info.getBbsId(), mEntrance);
}
break;
case WAITING:
Utils.toast(mViewHolder.context, "最多只能同时下载三个任务,请稍等");
break;
case DOWNLOADING_NORMAL:
case DOWNLOADING_PLUGIN:
if (mDownloadEntity == null) {
mDownloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(mGameEntity);
}
if (mDownloadEntity != null) {
if (downloadText.contains("继续加载")) {
DownloadManager.getInstance().resume(mDownloadEntity, true);
} else {
DownloadManager.getInstance().pause(mDownloadEntity.getUrl());
mViewHolder.mDownloadPb.setText("继续加载 " + mDownloadEntity.getPercent() + "%");
}
}
break;
default:
if (mGameEntity.isVGame()) {
mViewHolder.context.startActivity(VDownloadManagerActivity.getIntent(mViewHolder.context, true));
@ -423,12 +481,6 @@ public class DetailViewHolder {
}
break;
}
if (mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_NORMAL
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.INSTALL_PLUGIN
&& mViewHolder.mDownloadPb.getButtonStyle() != DownloadButton.ButtonStyle.LAUNCH_OR_OPEN) {
EventBus.getDefault().post(new EBScroll(Constants.EB_GAME_DETAIL, mGameEntity.getId()));
}
}
private void showOffServiceDialog(GameEntity.Dialog dialog) {

View File

@ -15,10 +15,6 @@ public class GameTestViewHolder extends GameViewHolder {
gameDownloadBtn = binding.home2DownloadBtn;
gameDes = binding.home2GameDes;
gameLabelList = binding.home2LabelList;
gameInfo = binding.home2GameLlInfo;
gameProgressbar = binding.home2GameProgressbar;
gameDownloadSpeed = binding.home2DownloadSpeed;
gameDownloadPercentage = binding.home2DownloadPercentage;
gameServerType = binding.home2GameServerType;
}

View File

@ -1,6 +1,7 @@
package com.gh.gamecenter.adapter.viewholder;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -8,6 +9,7 @@ import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.airbnb.lottie.LottieAnimationView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.common.view.DownloadButton;
import com.gh.common.view.GameIconView;
@ -25,15 +27,13 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
public DownloadButton gameDownloadBtn;
public TextView gameDes;
public LinearLayout gameLabelList;
public View gameInfo;
public ProgressBar gameProgressbar;
@Nullable
public View recommendContainer;
public TextView recommendTv;
public SimpleDraweeView recommendIv;
public TextView gameDownloadSpeed;
public TextView gameDownloadPercentage;
public TextView gameServerType;
public LottieAnimationView gameDownloadTips;
public TextView multiVersionDownloadTv;
@Nullable
public TextView gameRating;
@ -48,11 +48,9 @@ public class GameViewHolder extends RecyclerView.ViewHolder {
public GameViewHolder(GameItemBinding binding) {
super(binding.getRoot());
gameDownloadBtn = binding.downloadBtn;
gameProgressbar = binding.gameProgressbar;
gameInfo = binding.gameInfo;
gameDownloadPercentage = binding.downloadPercentage;
gameDes = binding.gameDes;
gameDownloadSpeed = binding.downloadSpeed;
gameDownloadTips = binding.downloadTipsLottie;
multiVersionDownloadTv = binding.multiVersionDownloadTv;
gameRating = binding.gameRating;
recommendContainer = binding.recommendContainer;
recommendTv = binding.recommendTv;

View File

@ -271,11 +271,7 @@ class CategoryV2ListAdapter(
inner class CategoryGameViewHolder(val binding: CategoryGameItemBinding) : GameViewHolder(binding.root) {
init {
gameDownloadBtn = binding.downloadBtn
gameProgressbar = binding.gameProgressbar
gameInfo = binding.gameInfo
gameDownloadPercentage = binding.downloadPercentage
gameDes = binding.gameDes
gameDownloadSpeed = binding.downloadSpeed
gameRating = binding.gameRating
recommendContainer = binding.recommendContainer
recommendTv = binding.recommendTv

View File

@ -279,11 +279,7 @@ class DiscoveryAdapter(
class DiscoveryGameViewHolder(val binding: DiscoveryGameItemBinding) : GameViewHolder(binding.root) {
init {
gameDownloadBtn = binding.downloadBtn
gameProgressbar = binding.gameProgressbar
gameInfo = binding.gameInfo
gameDownloadPercentage = binding.downloadPercentage
gameDes = binding.gameDes
gameDownloadSpeed = binding.downloadSpeed
gameRating = binding.gameRating
recommendContainer = binding.recommendContainer
recommendIv = binding.recommendIv

View File

@ -89,81 +89,79 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi
}
if (location != null) {
if (!"pause".equals(adapter.getStatusMap().get(downloadEntity.getUrl()))) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
// 检查对应下载列表中是否存在该数据
boolean isContains = false;
for (DownloadEntity entity : adapter.getDownloadingList()) {
if (entity.getUrl().equals(downloadEntity.getUrl())) {
isContains = true;
break;
}
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
// 检查对应下载列表中是否存在该数据
boolean isContains = false;
for (DownloadEntity entity : adapter.getDownloadingList()) {
if (entity.getUrl().equals(downloadEntity.getUrl())) {
isContains = true;
break;
}
if (isContains) {
// 删除下载中列表对应数据
if (adapter.getDownloadingList().size() == 1) {
location = adapter.getLocation(downloadEntity.getUrl());
if (location != null) {
adapter.getDownloadingList().remove(location.intValue());
adapter.initLocationMap();
adapter.notifyItemRangeRemoved(adapter.getBase(), 2);
}
} else {
location = adapter.getLocation(downloadEntity.getUrl());
if (location != null) {
adapter.getDownloadingList().remove(location.intValue());
adapter.initLocationMap();
adapter.notifyItemRemoved(adapter.getBase() + location + 1);
adapter.notifyItemChanged(adapter.getBase() + 1);
}
}
// 添加进已完成列表
if (adapter.getDoneList().isEmpty()) {
adapter.getDoneList().add(0, downloadEntity);
}
if (isContains) {
// 删除下载中列表对应数据
if (adapter.getDownloadingList().size() == 1) {
location = adapter.getLocation(downloadEntity.getUrl());
if (location != null) {
adapter.getDownloadingList().remove(location.intValue());
adapter.initLocationMap();
adapter.notifyItemRangeInserted(0, 2);
} else {
adapter.getDoneList().add(0, downloadEntity);
adapter.initLocationMap();
adapter.notifyItemInserted(1);
adapter.notifyItemRangeRemoved(adapter.getBase(), 2);
}
} else {
location = adapter.getLocation(downloadEntity.getUrl());
if (location != null) {
adapter.notifyItemChanged(location + 1);
adapter.getDownloadingList().remove(location.intValue());
adapter.initLocationMap();
adapter.notifyItemRemoved(adapter.getBase() + location + 1);
adapter.notifyItemChanged(adapter.getBase() + 1);
}
}
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(HaloApp.getInstance().getApplication(),
downloadEntity.getPath()), downloadEntity.getUrl());
// 用户焦点在下载管理页面时有任务完成,直接把所有下载完成的任务标记为已读
DownloadManager.getInstance().markDownloadedTaskAsRead();
} else if (DownloadStatus.cancel.equals(downloadEntity.getStatus())) { // 有可能由于网络劫持造成的
adapter.initMap();
adapter.notifyDataSetChanged();
int listSize = adapter.getDownloadingList().size() + adapter.getDoneList().size();
if (listSize == 0) {
EventBus.getDefault().post(new EBDownloadChanged("download", View.GONE, listSize));
if (mBinding.reuseNoneData.getRoot().getVisibility() == View.GONE) {
mBinding.reuseNoneData.getRoot().setVisibility(View.VISIBLE);
}
// 添加进已完成列表
if (adapter.getDoneList().isEmpty()) {
adapter.getDoneList().add(0, downloadEntity);
adapter.initLocationMap();
adapter.notifyItemRangeInserted(0, 2);
} else {
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
adapter.getDownloadingList().size()));
adapter.getDoneList().add(0, downloadEntity);
adapter.initLocationMap();
adapter.notifyItemInserted(1);
}
} else {
location = adapter.getLocation(downloadEntity.getUrl());
if (location != null && adapter.getDownloadingList().size() > location) {
adapter.getDownloadingList().set(location, downloadEntity);
adapter.notifyItemChanged(adapter.getBase() + location + 1);
if (location != null) {
adapter.notifyItemChanged(location + 1);
}
}
if (downloadEntity.getStatus() == DownloadStatus.neterror) {
adapter.notifyItemChanged(adapter.getBase());
adapter.getUrlMap().put(PackageUtils.getPackageNameByPath(HaloApp.getInstance().getApplication(),
downloadEntity.getPath()), downloadEntity.getUrl());
// 用户焦点在下载管理页面时有任务完成,直接把所有下载完成的任务标记为已读
DownloadManager.getInstance().markDownloadedTaskAsRead();
} else if (DownloadStatus.cancel.equals(downloadEntity.getStatus())) { // 有可能由于网络劫持造成的
adapter.initMap();
adapter.notifyDataSetChanged();
int listSize = adapter.getDownloadingList().size() + adapter.getDoneList().size();
if (listSize == 0) {
EventBus.getDefault().post(new EBDownloadChanged("download", View.GONE, listSize));
if (mBinding.reuseNoneData.getRoot().getVisibility() == View.GONE) {
mBinding.reuseNoneData.getRoot().setVisibility(View.VISIBLE);
}
} else {
EventBus.getDefault().post(new EBDownloadChanged("download", View.VISIBLE,
adapter.getDownloadingList().size()));
}
} else {
location = adapter.getLocation(downloadEntity.getUrl());
if (location != null && adapter.getDownloadingList().size() > location) {
adapter.getDownloadingList().set(location, downloadEntity);
adapter.notifyItemChanged(adapter.getBase() + location + 1);
}
}
if (downloadEntity.getStatus() == DownloadStatus.neterror) {
adapter.notifyItemChanged(adapter.getBase());
}
} else {
if (!adapter.getDeleteList().contains(downloadEntity.getUrl())) {

View File

@ -106,8 +106,7 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
viewHolder.binding.getRoot().setBackground(ContextCompat.getDrawable(mContext, R.drawable.reuse_listview_item_style));
viewHolder.binding.dmItemTvTitle.setTextColor(ContextCompat.getColor(mContext, R.color.text_title));
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_9a9a9a));
ExtensionsKt.removeDrawable(viewHolder.binding.dmItemTvSpeed);
final DownloadEntity downloadEntity;
if (mDownloadedList.size() != 0 && position > 0 && position <= mDownloadedList.size()) {
@ -157,113 +156,99 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
DownloadStatus status = downloadEntity.getStatus();
if (status.equals(DownloadStatus.done)) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
viewHolder.binding.dmItemTvDownloads.setText("下载完成");
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
viewHolder.binding.dmItemTvSpeed.setText("加载完成");
viewHolder.binding.dmItemTvStartorpause.setText(R.string.install);
if (downloadEntity.isPluggable()
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
viewHolder.binding.dmItemTvStartorpause.setText("安装");
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_PLUGIN);
} else {
viewHolder.binding.dmItemTvStartorpause.setText("安装");
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
}
viewHolder.binding.dmItemTvSpeed.setText(R.string.hundred_percent);
} else if (status.equals(DownloadStatus.downloading)) {
if (!"pause".equals(statusMap.get(downloadEntity.getUrl()))) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams.weight = 4;
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
viewHolder.binding.dmItemTvDownloads.setText(String.format("%s(剩%s)",
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
viewHolder.binding.dmItemTvSpeed.setText(String.format("%s(剩%s)",
SpeedUtils.getSpeed(downloadEntity.getSpeed()),
SpeedUtils.getRemainTime(downloadEntity.getSize(), downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
viewHolder.binding.dmItemIvDelete.setVisibility(View.GONE);
viewHolder.binding.dmItemTvStartorpause.setText("暂停");
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.PAUSE);
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
viewHolder.binding.dmItemTvStartorpause.setText(downloadEntity.getPercent() + "%");
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (downloadEntity.getPercent() * 10));
}
} else if (status.equals(DownloadStatus.waiting)) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
viewHolder.binding.dmItemTvDownloads.setText("等待中");
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
viewHolder.binding.dmItemTvStartorpause.setText("等待");
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
viewHolder.binding.dmItemTvSpeed.setText(R.string.waiting);
viewHolder.binding.dmItemTvStartorpause.setText(R.string.waiting);
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.WAITING);
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
} else if (status.equals(DownloadStatus.pause)
|| status.equals(DownloadStatus.timeout)
|| status.equals(DownloadStatus.neterror)
|| status.equals(DownloadStatus.subscribe)) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
viewHolder.binding.dmItemTvStartorpause.setText("继续");
viewHolder.binding.dmItemTvStartorpause.setText(R.string.resume);
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
if (status.equals(DownloadStatus.timeout)
|| status.equals(DownloadStatus.neterror)
|| status.equals(DownloadStatus.subscribe)) {
viewHolder.binding.dmItemTvDownloads.setText("已暂停连接WiFi自动下载");
viewHolder.binding.dmItemTvSpeed.setText("等待WIFI");
} else {
viewHolder.binding.dmItemTvDownloads.setText("已暂停");
viewHolder.binding.dmItemTvSpeed.setText("已暂停");
}
} else if (status.equals(DownloadStatus.overflow)) {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(mContext.getResources().getColor(R.color.theme_red));
viewHolder.binding.dmItemTvDownloads.setText("数据异常,请重新下载");
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
viewHolder.binding.dmItemTvSpeed.setText("数据异常,请重新下载");
viewHolder.binding.dmItemTvStartorpause.setText("失败");
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.FAILURE);
viewHolder.binding.dmItemTvSpeed.setText(downloadEntity.getPercent() + "%");
}
String xapkStatus = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
viewHolder.binding.dmItemTvStartorpause.setText("取消");
String percent = downloadEntity.getMeta().get(XapkInstaller.XAPK_UNZIP_PERCENT);
viewHolder.binding.dmItemProgressbar.setProgress((int) (Float.parseFloat(percent == null ? "0" : percent) * 10));
viewHolder.binding.dmItemProgressbar.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progressbar_xapk_style));
viewHolder.binding.dmItemTvSpeed.setText((percent + "%"));
viewHolder.binding.dmItemTvSpeed.setTextColor(mContext.getResources().getColor(R.color.theme_font));
viewHolder.binding.dmItemTvDownloads.setText("解压中");
viewHolder.binding.unzipFailureHint.setVisibility(View.GONE);
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.XAPK_UNZIPPING);
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (Float.parseFloat(percent == null ? "0" : percent) * 10));
viewHolder.binding.dmItemTvStartorpause.setText(percent + "%");
viewHolder.binding.dmItemTvSpeed.setTextColor(mContext.getResources().getColor(R.color.text_subtitleDesc));
viewHolder.binding.dmItemTvSpeed.setText(R.string.unzipping);
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
viewHolder.binding.dmItemProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
viewHolder.binding.dmItemProgressbar.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progressbar_bg_style));
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.text_F10000));
viewHolder.binding.unzipFailureHint.setVisibility(View.VISIBLE);
viewHolder.binding.dmItemTvDownloads.setText("解压失败");
} else {
viewHolder.binding.dmItemProgressbar.setProgress((int) (downloadEntity.getPercent() * 10));
viewHolder.binding.dmItemProgressbar.setProgressDrawable(mContext.getResources().getDrawable(R.drawable.progressbar_bg_style));
viewHolder.binding.unzipFailureHint.setVisibility(View.GONE);
viewHolder.binding.dmItemTvSpeed.setTextColor(mContext.getResources().getColor(R.color.text_9a9a9a));
viewHolder.binding.dmItemTvStartorpause.setText(R.string.install);
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.INSTALL_NORMAL);
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.theme_red));
viewHolder.binding.dmItemTvSpeed.setText("解压失败");
ExtensionsKt.setDrawableStart(viewHolder.binding.dmItemTvSpeed, R.drawable.unzip_failure_hint, null, null);
}
viewHolder.binding.dmItemTvStartorpause.setOnClickListener(v -> {
String str = ((DownloadButton) v).getText();
final String url = downloadEntity.getUrl();
DownloadManager.getInstance().put(url, System.currentTimeMillis());
switch (str) {
case "继续":
case "下载":
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
XapkInstaller.cancelUnzipTask(downloadEntity);
return;
} else if (XapkUnzipStatus.FAILURE.name().equals(xapkStatus)) {
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
final String path = downloadEntity.getPath();
if (downloadEntity.isPluggable()
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
showPluginDialog(downloadEntity.getPath());
} else {
if (FileUtils.isEmptyFile(path)) {
Utils.toast(mContext, R.string.install_failure_hint);
removeDownload(downloadEntity);
} else {
PackageInstaller.install(mContext, downloadEntity);
}
}
});
return;
}
switch (status) {
case pause:
case timeout:
case neterror:
case subscribe:
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
// 下载管理不用判断是否大于50M
DialogUtils.checkDownload(mContext, Float.toString(100F), isSubscribe -> {
@ -273,19 +258,14 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
notifyItemChanged(mDownloadedList.isEmpty() ? 0 : 1 + mDownloadedList
.size());
} else {
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
0, LinearLayout.LayoutParams.WRAP_CONTENT);
lparams.weight = 4;
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
viewHolder.binding.dmItemTvDownloads.setText(String.format("%s(剩%s)",
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.theme_font));
viewHolder.binding.dmItemTvSpeed.setText(String.format("%s(剩%s)",
SpeedUtils.getSpeed(downloadEntity.getSpeed()),
SpeedUtils.getRemainTime(downloadEntity.getSize(),
downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024)));
viewHolder.binding.dmItemIvDelete.setVisibility(View.GONE);
viewHolder.binding.dmItemTvStartorpause.setText("暂停");
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.PAUSE);
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.DOWNLOADING_NORMAL);
viewHolder.binding.dmItemTvStartorpause.setText(downloadEntity.getPercent() + "%");
viewHolder.binding.dmItemTvStartorpause.setProgress((int) (downloadEntity.getPercent() * 10));
statusMap.put(url, DownloadStatus.downloading.getStatus());
notifyItemChanged(mDownloadedList.isEmpty() ? 0 : 1 + mDownloadedList
.size());
@ -298,31 +278,31 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
});
});
break;
case "安装":
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
final String path = downloadEntity.getPath();
if (downloadEntity.isPluggable()
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
showPluginDialog(downloadEntity.getPath());
} else {
if (FileUtils.isEmptyFile(path)) {
Utils.toast(mContext, R.string.install_failure_hint);
removeDownload(downloadEntity);
case done:
if (str.equals(mContext.getString(R.string.install))) {
PermissionHelper.checkStoragePermissionBeforeAction(mContext, () -> {
final String path = downloadEntity.getPath();
if (downloadEntity.isPluggable()
&& PackagesManager.isInstalled(downloadEntity.getPackageName())) {
showPluginDialog(downloadEntity.getPath());
} else {
PackageInstaller.install(mContext, downloadEntity);
if (FileUtils.isEmptyFile(path)) {
Utils.toast(mContext, R.string.install_failure_hint);
removeDownload(downloadEntity);
} else {
PackageInstaller.install(mContext, downloadEntity);
}
}
}
});
});
} else if (str.equals(mContext.getString(R.string.launch))) {
PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName());
}
break;
case "暂停":
viewHolder.binding.dmItemTvStartorpause.setText("继续");
case downloading:
viewHolder.binding.dmItemTvStartorpause.setText(R.string.resume);
viewHolder.binding.dmItemTvStartorpause.setButtonStyle(DownloadButton.ButtonStyle.NORMAL);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
viewHolder.binding.dmItemTvDownloads.setLayoutParams(lparams);
viewHolder.binding.dmItemTvDownloads.setTextColor(0xFF9A9A9A);
viewHolder.binding.dmItemTvDownloads.setText("已暂停");
viewHolder.binding.dmItemIvDelete.setVisibility(View.VISIBLE);
viewHolder.binding.dmItemTvSpeed.setText("已暂停");
viewHolder.binding.dmItemTvSpeed.setTextColor(ContextCompat.getColor(mContext, R.color.text_subtitleDesc));
statusMap.put(url, DownloadStatus.pause.getStatus());
notifyItemChanged(mDownloadedList.isEmpty() ? 0 : 1 + mDownloadedList.size());
Message msg = Message.obtain();
@ -332,13 +312,10 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
// DownloadManager.getInstance().pause(downloadEntity);
break;
case "等待":
case waiting:
Utils.toast(mContext, "最多只能同时下载三个任务,请稍等");
break;
case "启动":
PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName());
break;
case "失败":
case overflow:
DialogHelper.showCenterDialog(mContext
, "下载失败"
, "安装包数据校验失败,无法完成下载,建议删除任务重新下载"
@ -346,39 +323,18 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
}, () -> {
});
break;
case "取消":
XapkInstaller.cancelUnzipTask(downloadEntity);
break;
}
// DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "下载管理", "游戏下载", str);
});
viewHolder.binding.dmItemTvDownloads.setOnClickListener(v -> {
if (viewHolder.binding.unzipFailureHint.getVisibility() == View.VISIBLE) {
DialogUtils.showUnzipFailureDialog(mContext, downloadEntity);
} else if (viewHolder.binding.dmItemIvDelete.getVisibility() == View.VISIBLE) {
showDeleteDialog(downloadEntity, viewHolder.getPosition());
}
});
viewHolder.binding.dmItemIvDelete.setOnClickListener(v -> {
if (viewHolder.binding.dmItemIvDelete.getVisibility() == View.VISIBLE) {
showDeleteDialog(downloadEntity, viewHolder.getPosition());
}
});
if (downloadEntity.getUrl().equals(url)) {
viewHolder.binding.getRoot().setBackgroundColor(ContextCompat.getColor(mContext, R.color.select));
} else {
viewHolder.binding.getRoot().setBackgroundResource(R.drawable.reuse_listview_item_style);
}
viewHolder.binding.getRoot().setOnLongClickListener(v -> {
if (viewHolder.binding.dmItemIvDelete.getVisibility() == View.VISIBLE) {
showDeleteDialog(downloadEntity, viewHolder.getPosition());
return true;
}
return false;
showDeleteDialog(viewHolder.binding.dmItemTvStartorpause, downloadEntity, viewHolder.getPosition());
return true;
});
} else if (holder instanceof DownloadHeadViewHolder) {
@ -566,23 +522,31 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
}
// 显示删除提示框
private void showDeleteDialog(final DownloadEntity entry, final int position) {
private void showDeleteDialog(DownloadButton downloadButton, final DownloadEntity entry, final int position) {
boolean autoPause = DownloadStatus.downloading.equals(entry.getStatus());
if (autoPause) {
downloadButton.performClick();
}
String xapkStatus = entry.getMeta().get(XapkInstaller.XAPK_UNZIP_STATUS);
String msg;
String contentText;
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
msg = "游戏正在解压安装哦,确定删除?";
contentText = "游戏正在解压安装哦,确定删除?";
} else if (mDownloadedList.size() != 0 && position <= mDownloadedList.size()) {
msg = "游戏还没安装哦,确定删除?";
contentText = "游戏还没安装哦,确定删除?";
} else {
msg = "游戏还没下载完,确定删除?";
contentText = "游戏还没下载完,确定删除?";
}
DialogHelper.showCenterWarningDialog(mContext, "删除下载", msg, () -> {
DialogHelper.showDeleteDialog(mContext, "删除游戏", contentText, "删除", "再等等", () -> {
removeDownload(entry);
if (XapkUnzipStatus.UNZIPPING.name().equals(xapkStatus)) {
XapkInstaller.cancelUnzipTask(entry);
}
});
}, () -> {
if (autoPause) {
downloadButton.performClick();
}
}, true);
}
public void initLocationMap() {

View File

@ -33,8 +33,6 @@ class GameItemViewHolder(var binding: GameItemBinding) : BaseRecyclerViewHolder<
gameKaifuType.setBackgroundColor(R.color.theme.toColor(root.context))
gameName.setTextColor(R.color.text_title.toColor(root.context))
gameDes.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadSpeed.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadPercentage.setTextColor(R.color.theme_font.toColor(root.context))
recommendStarPref.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
gameIconView.displayGameIcon(entity)

View File

@ -11,12 +11,15 @@ import android.widget.LinearLayout
import android.widget.Space
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.Group
import androidx.core.content.ContextCompat
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat
import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieDrawable
import com.facebook.drawee.view.SimpleDraweeView
import com.gh.common.view.DownloadButton
import com.gh.common.view.GameIconView
import com.gh.gamecenter.R
import com.gh.gamecenter.common.utils.setDrawableEnd
import com.gh.gamecenter.common.view.GameTagContainerView
import splitties.dimensions.dip
import splitties.views.backgroundColor
@ -46,17 +49,15 @@ class GameItemUi(override val ctx: Context) : Ui {
var gameSubtitleTv: TextView
var adLabelTv: TextView
var downloadTv: DownloadButton
var multiVersionDownloadTv: TextView
var downloadTipsLottie: LottieAnimationView
var gameDesTv: TextView
var serverTypeTv: TextView
var gameRatingTv: TextView
var recommendIv: SimpleDraweeView
var recommendTv: TextView
var downloadSpeedTv: TextView
var downloadPercentageTv: TextView
var downloadButton: DownloadButton
var gameTagContainer: GameTagContainerView
var recommendConstraintLayout: ConstraintLayout
var gameInfoGroup: Group
var mGameDesSpace: Space
@ -69,28 +70,38 @@ class GameItemUi(override val ctx: Context) : Ui {
gameSubtitleTv = initGameSubtitleTv()
adLabelTv = initAdLabelTv()
downloadTv = initDownloadTv()
multiVersionDownloadTv = initMultiVersionDownloadTv()
downloadTipsLottie = initDownloadTipsLottie()
gameDesTv = initGameDesTv()
gameRatingTv = initGameRatingTv()
recommendIv = SimpleDraweeView(ctx).apply { id = R.id.recommendIv }
recommendTv = initRecommendTv()
downloadSpeedTv = initDownloadSpeedTv()
downloadPercentageTv = initDownloadPercentageTv()
downloadButton = initDownloadButton()
gameTagContainer = GameTagContainerView(ctx).apply { id = R.id.label_list }
mGameDesSpace = space { }.apply { id = R.id.gameDesSpace }
recommendConstraintLayout = initRecommendConstraintLayout()
gameInfoGroup = group(downloadSpeedTv, downloadPercentageTv).apply { id = R.id.gameInfoContainer }
add(iconIv, lParams(dip(64), dip(64)) {
topOfParent()
bottomOfParent()
startOfParent()
})
add(downloadTv, lParams(dip(60), dip(28.5F).toInt()) {
add(downloadTv, lParams(dip(56), dip(28)) {
topOfParent()
endOfParent()
bottomOfParent()
})
add(multiVersionDownloadTv, lParams(wrapContent, dip(28)) {
topToTopOf(downloadTv)
bottomToBottomOf(downloadTv)
startToStartOf(downloadTv)
endToEndOf(downloadTv)
})
add(downloadTipsLottie, lParams(dip(16), dip(16)) {
topToTopOf(downloadTv)
endToEndOf(downloadTv)
topMargin = dip(-8)
})
add(gameNameTv, lParams(wrapContent, wrapContent) {
constrainedWidth = true
startToStartOf(mGameDesSpace)
@ -139,32 +150,6 @@ class GameItemUi(override val ctx: Context) : Ui {
constrainedWidth = true
horizontalBias = 0F
})
add(downloadSpeedTv, lParams(0, wrapContent) {
topToTopOf(mGameDesSpace)
bottomToTopOf(downloadButton)
startToStartOf(mGameDesSpace)
endToStartOf(downloadPercentageTv)
horizontalWeight = 4F
topMargin = dip(2)
})
add(downloadPercentageTv, lParams(0, wrapContent) {
topToTopOf(mGameDesSpace)
bottomToTopOf(downloadButton)
startToEndOf(downloadSpeedTv)
endToEndOf(mGameDesSpace)
horizontalWeight = 1F
topMargin = dip(2)
})
add(downloadButton, lParams(0, dip(3)) {
topToBottomOf(downloadSpeedTv)
startToStartOf(mGameDesSpace)
endToEndOf(mGameDesSpace)
horizontalBias = 0F
bottomMargin = dip(4)
})
add(gameTagContainer, lParams(0, wrapContent) {
topToBottomOf(mGameDesSpace)
bottomToBottomOf(iconIv)
@ -189,8 +174,6 @@ class GameItemUi(override val ctx: Context) : Ui {
startMargin = dip(4)
})
gameInfoGroup.visibility = View.GONE
}
private fun initIconView(): GameIconView {
@ -258,6 +241,7 @@ class GameItemUi(override val ctx: Context) : Ui {
private fun initDownloadTv() = DownloadButton(ctx).apply {
id = R.id.download_btn
text = "下载"
showProgress = true
}
private fun initGameRatingTv() = textView {
@ -307,31 +291,28 @@ class GameItemUi(override val ctx: Context) : Ui {
setTextColor(ContextCompat.getColor(context, R.color.text_FF7C1F))
}
private fun initDownloadPercentageTv() = textView {
id = R.id.download_percentage
textSize = 9F
setSingleLine()
ellipsize = TextUtils.TruncateAt.END
gravity = Gravity.END
setTextColor(ContextCompat.getColor(context, R.color.theme_font))
private fun initMultiVersionDownloadTv(): TextView {
return textView {
id = R.id.multiVersionDownloadTv
textSize = 12F
gravity = Gravity.CENTER
text = "展开"
setTextColor(ContextCompat.getColor(context, R.color.white))
setDrawableEnd(
VectorDrawableCompat.create(
resources, R.drawable.ic_jump_universal, null
)
)
compoundDrawablePadding = dip(2)
visibility = View.GONE
}
}
private fun initDownloadSpeedTv() = textView {
id = R.id.download_speed
textSize = 9F
setSingleLine()
ellipsize = TextUtils.TruncateAt.END
setTextColor(ContextCompat.getColor(context, R.color.text_subtitleDesc))
}
private fun initDownloadButton(): DownloadButton {
return DownloadButton(ctx, null, android.R.attr.progressBarStyleHorizontal).apply {
id = R.id.game_progressbar
max = 1000
progress = 500
progressDrawable = ContextCompat.getDrawable(context, R.drawable.progressbar_bg_style)
private fun initDownloadTipsLottie(): LottieAnimationView {
return LottieAnimationView(ctx).apply {
id = R.id.downloadTipsLottie
repeatMode = LottieDrawable.RESTART
repeatCount = LottieDrawable.INFINITE
visibility = View.GONE
}
}

View File

@ -73,8 +73,6 @@ class GameVerticalAdapter(
serverTypeTv.setTextColor(R.color.theme.toColor(mContext))
downloadTv.background = R.drawable.download_button_normal_style.toDrawable(mContext)
gameDesTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
downloadSpeedTv.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
downloadPercentageTv.setTextColor(R.color.theme_font.toColor(mContext))
BindingAdapters.setGameName(
gameNameTv,
@ -158,14 +156,12 @@ class GameVerticalAdapter(
}
tempViewHolder.gameDes = gameDesTv
tempViewHolder.gameDownloadBtn = downloadTv
tempViewHolder.gameDownloadPercentage = downloadPercentageTv
tempViewHolder.gameDownloadSpeed = downloadSpeedTv
tempViewHolder.multiVersionDownloadTv = multiVersionDownloadTv
tempViewHolder.gameDownloadTips = downloadTipsLottie
tempViewHolder.gameLabelList = gameTagContainer
tempViewHolder.gameProgressbar = downloadButton
tempViewHolder.recommendIv = recommendIv
tempViewHolder.recommendTv = recommendTv
tempViewHolder.recommendContainer = recommendConstraintLayout
tempViewHolder.gameInfo = gameInfoGroup
tempViewHolder.gameServerType = serverTypeTv
DownloadItemUtils.updateItem(

View File

@ -576,8 +576,6 @@ open class GameCollectionDetailAdapter(
gameKaifuType.setBackgroundColor(R.color.theme.toColor(mContext))
gameName.setTextColor(R.color.text_title.toColor(mContext))
gameDes.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
downloadSpeed.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
downloadPercentage.setTextColor(R.color.theme_font.toColor(mContext))
recommendStarPref.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
gameIconView.displayGameIcon(gameEntity)

View File

@ -202,6 +202,26 @@ class GameDetailFragment : ToolbarFragment(), IScrollable {
)
}
}
} else if ((mGameEntity?.getApk()?.size ?: 0) > 1) {
when (downloadEntity.status) {
DownloadStatus.downloading -> {
if (detailViewHolder.mDownloadTips.visibility == View.GONE || !detailViewHolder.mDownloadTips.isAnimating) {
detailViewHolder.mDownloadTips.visibility = View.VISIBLE
detailViewHolder.mDownloadTips.setDownloadTipsAnimation(true)
}
}
DownloadStatus.done,
DownloadStatus.pause,
DownloadStatus.waiting,
DownloadStatus.timeout,
DownloadStatus.subscribe,
DownloadStatus.overflow,
DownloadStatus.neterror -> {
detailViewHolder.mDownloadTips.visibility = View.VISIBLE
detailViewHolder.mDownloadTips.setDownloadTipsAnimation(false)
}
else -> detailViewHolder.mDownloadTips.visibility = View.GONE
}
}
}
}
@ -2094,6 +2114,9 @@ class GameDetailFragment : ToolbarFragment(), IScrollable {
updateGameDetailTopArea()
controlReserveBtn()
detailViewHolder.mDownloadPb.buttonStyle = detailViewHolder.mDownloadPb.buttonStyle
if (detailViewHolder.mDownloadTips.visibility == View.VISIBLE) {
detailViewHolder.mDownloadTips.setDownloadTipsAnimation(detailViewHolder.mDownloadTips.isAnimating)
}
mBodyBinding.collapsingToolbar.setContentScrimColor(R.color.background_white.toColor(requireContext()))
mBodyBinding.gamedetailAppbar.setBackgroundColor(R.color.background_white.toColor(requireContext()))
mBodyBinding.toolbarGapView.setBackgroundColor(R.color.background.toColor(requireContext()))

View File

@ -77,8 +77,6 @@ class MyFollowedGameAdapter(context: Context, var mViewModel: MyFollowedGameView
gameKaifuType.setBackgroundColor(R.color.theme.toColor(root.context))
gameName.setTextColor(R.color.text_title.toColor(root.context))
gameDes.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadSpeed.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadPercentage.setTextColor(R.color.theme_font.toColor(root.context))
recommendStarPref.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
cardContainer.background = R.drawable.bg_shape_space_radius_8.toDrawable(root.context)

View File

@ -85,8 +85,6 @@ class MyReservationAdapter(context: Context, var mViewModel: MyReservationViewMo
gameKaifuType.setBackgroundColor(R.color.theme.toColor(root.context))
gameName.setTextColor(R.color.text_title.toColor(root.context))
gameDes.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadSpeed.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadPercentage.setTextColor(R.color.theme_font.toColor(root.context))
recommendStarPref.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
gameIconView.displayGameIcon(gameEntity)

View File

@ -112,8 +112,6 @@ open class PlayedGameAdapter(
gameKaifuType.setBackgroundColor(R.color.theme.toColor(root.context))
gameName.setTextColor(R.color.text_title.toColor(root.context))
gameDes.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadSpeed.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadPercentage.setTextColor(R.color.theme_font.toColor(root.context))
recommendStarPref.setTextColor(R.color.text_subtitleDesc.toColor(root.context))
downloadBtn.layoutParams = downloadBtn.layoutParams.apply {

View File

@ -284,8 +284,6 @@ class GameServersContentAdapter(
binding.contentContainer.background = R.drawable.reuse_listview_item_style.toDrawable(mContext)
gameName.setTextColor(R.color.text_title.toColor(mContext))
gameDes.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
gameDownloadSpeed.setTextColor(R.color.text_subtitleDesc.toColor(mContext))
gameDownloadPercentage.setTextColor(R.color.theme_font.toColor(mContext))
}
viewHolder.gameName.text = gameEntity.name

View File

@ -3,9 +3,12 @@ package com.gh.vspace
import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import android.widget.LinearLayout
import android.widget.PopupWindow
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import com.gh.common.databind.BindingAdapters
@ -27,12 +30,14 @@ import com.gh.gamecenter.core.AppExecutor
import com.gh.gamecenter.core.runOnIoThread
import com.gh.gamecenter.core.utils.CurrentActivityHolder
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.core.utils.SpeedUtils
import com.gh.gamecenter.core.utils.ToastUtils
import com.gh.gamecenter.databinding.ItemVgameDownloadManagerBinding
import com.gh.gamecenter.databinding.PopupHistoryOptionBinding
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.history.ManageOption
import com.gh.gamecenter.manager.PackagesManager
import com.google.android.exoplayer2.offline.Download
import com.lightgame.download.DownloadEntity
import com.lightgame.download.DownloadStatus
import com.lightgame.utils.Utils
@ -131,8 +136,20 @@ class VDownloadManagerAdapter(
BindingAdapters.setGameName(holder.binding.nameTv, gameEntity, false, true)
holder.binding.iconIv.displayGameIcon(gameEntity)
holder.binding.descTv.goneIf(!mViewModel.isTypeDownloaded() || gameEntity.des?.isEmpty() == true)
holder.binding.descTv.text = gameEntity.des
holder.binding.descTv.goneIf(mViewModel.isTypeDownloaded() && gameEntity.des?.isEmpty() == true)
if (mViewModel.isTypeDownloaded()) {
holder.binding.descTv.text = gameEntity.des
} else {
holder.binding.descTv.layoutParams =
(holder.binding.descTv.layoutParams as MarginLayoutParams).apply {
setMargins(
0,
8F.dip2px(),
0,
0
)
}
}
holder.binding.selectIv.setImageDrawable(R.drawable.selector_ic_simulator.toDrawable(mContext))
holder.binding.selectIv.goneIf(mCurrentOption == ManageOption.OPTION_MANAGER)
@ -154,16 +171,33 @@ class VDownloadManagerAdapter(
}
}
updateDownloadBtn(mContext, holder.binding.downloadBtn, gameEntity)
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
?: VHelper.getDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
updateDownloadBtnAndDes(
mContext,
downloadEntity,
holder.binding.downloadBtn,
holder.binding.descTv,
gameEntity
)
holder.itemView.setOnLongClickListener {
val autoPause = downloadEntity?.status == DownloadStatus.downloading
if (autoPause) {
holder.binding.downloadBtn.performClick()
}
DialogHelper.showDialog(
holder.binding.root.context,
"删除游戏",
"单机类游戏被删除将可能导致本地存档、充值数据丢失,请确认后操作(网游类游戏删除不会影响游戏存档和充值数据)",
"再等等",
"删除",
{},
{
if (autoPause) {
holder.binding.downloadBtn.performClick()
}
},
{
runOnIoThread {
val apk = gameEntity.getApk().firstOrNull()
@ -179,7 +213,11 @@ class VDownloadManagerAdapter(
it.confirmTv.setTextColor(R.color.text_subtitle.toColor(it.root.context))
},
extraConfig = DialogHelper.Config(centerTitle = true)
)
)?.setOnCancelListener {
if (autoPause) {
holder.binding.downloadBtn.performClick()
}
}
return@setOnLongClickListener false
}
}
@ -292,8 +330,12 @@ class VDownloadManagerAdapter(
}
}
private fun updateDownloadBtn(
context: Context, downloadBtn: DownloadButton, gameEntity: GameEntity
private fun updateDownloadBtnAndDes(
context: Context,
downloadEntity: DownloadEntity?,
downloadBtn: DownloadButton,
downloadDes: TextView,
gameEntity: GameEntity
) {
// 青少年模式显示查看
if (SPUtils.getBoolean(Constants.SP_TEENAGER_MODE)) {
@ -304,9 +346,6 @@ class VDownloadManagerAdapter(
downloadBtn.goneIf(mCurrentOption != ManageOption.OPTION_MANAGER)
val downloadEntity = DownloadManager.getInstance().getDownloadEntitySnapshot(gameEntity)
?: VHelper.getDownloadEntitySnapshot(gameEntity.id, gameEntity.getUniquePackageName())
if (downloadEntity != null) {
val status = downloadEntity.status
var btnText = context.getText(R.string.downloading)
@ -316,6 +355,15 @@ class VDownloadManagerAdapter(
when (status) {
DownloadStatus.downloading -> {
btnText = "${downloadEntity.percent}%"
downloadDes.visibility = View.VISIBLE
val speedText = SpeedUtils.getSpeed(downloadEntity.speed)
val remainTimeText = SpeedUtils.getRemainTime(
downloadEntity.size,
downloadEntity.progress,
downloadEntity.speed * 1024
)
downloadDes.text = "$speedText(剩$remainTimeText)"
downloadDes.setTextColor(R.color.theme_font.toColor(mContext))
backgroundType = DownloadButton.ButtonStyle.DOWNLOADING_NORMAL
progress = (downloadEntity.percent * 10).toInt()
setOnClickListener {
@ -324,6 +372,9 @@ class VDownloadManagerAdapter(
}
DownloadStatus.waiting -> {
btnText = context.getString(R.string.waiting)
downloadDes.visibility = View.VISIBLE
downloadDes.text = context.getString(R.string.waiting)
downloadDes.setTextColor(R.color.theme_font.toColor(mContext))
setOnClickListener { Utils.toast(mContext, "最多只能同时下载三个任务,请稍等"); }
}
DownloadStatus.pause,
@ -332,6 +383,9 @@ class VDownloadManagerAdapter(
DownloadStatus.subscribe,
DownloadStatus.overflow -> {
btnText = context.getString(R.string.resume)
downloadDes.visibility = View.VISIBLE
downloadDes.text = "已暂停"
downloadDes.setTextColor(R.color.theme_font.toColor(mContext))
setOnClickListener {
DownloadManager.getInstance().resume(downloadEntity, true)
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 B

View File

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="6dp"
android:height="12dp"
android:viewportWidth="6"
android:viewportHeight="12">
<path
android:strokeWidth="1"
android:pathData="M1,2L5,6L1,10"
android:strokeLineJoin="round"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round" />
</vector>

View File

@ -260,13 +260,42 @@
<com.gh.common.view.DownloadButton
android:id="@+id/download_btn"
android:layout_width="52dp"
android:layout_height="26dp"
android:layout_width="56dp"
android:layout_height="28dp"
android:layout_marginLeft="8dp"
app:download_button_show_progress="false"
app:download_button_show_progress="true"
app:download_button_text_size="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/gameDescContainer"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/multiVersionDownloadTv"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:drawablePadding="2dp"
android:gravity="center"
android:text="展开"
android:textColor="@color/white"
android:textSize="@dimen/secondary_size"
android:visibility="gone"
app:drawableEndCompat="@drawable/ic_jump_universal"
app:layout_constraintBottom_toBottomOf="@id/download_btn"
app:layout_constraintEnd_toEndOf="@id/download_btn"
app:layout_constraintStart_toStartOf="@id/download_btn"
app:layout_constraintTop_toTopOf="@id/download_btn" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/downloadTipsLottie"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="-8dp"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@+id/download_btn"
app:layout_constraintTop_toTopOf="@+id/download_btn"
app:lottie_autoPlay="false"
app:lottie_loop="true"
app:lottie_repeatMode="restart" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -281,6 +281,19 @@
app:layout_constraintStart_toEndOf="@+id/iv_switch"
app:layout_constraintTop_toTopOf="parent" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/downloadTipsLottie"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="-8dp"
android:layout_marginRight="8dp"
android:visibility="gone"
app:lottie_autoPlay="false"
app:lottie_loop="true"
app:lottie_repeatMode="restart"
app:layout_constraintRight_toRightOf="@+id/detail_progressbar"
app:layout_constraintTop_toTopOf="@+id/detail_progressbar" />
<TextView
android:id="@+id/overlayTv"
android:layout_width="wrap_content"
@ -295,6 +308,22 @@
app:layout_constraintEnd_toEndOf="@id/detail_progressbar"
app:layout_constraintStart_toStartOf="@id/detail_progressbar"
app:layout_constraintTop_toTopOf="@id/detail_progressbar" />
<TextView
android:id="@+id/multiVersionDownloadTv"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:drawablePadding="4dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="@dimen/primary_text_size"
android:visibility="gone"
app:drawableEndCompat="@drawable/ic_jump_universal"
app:layout_constraintBottom_toBottomOf="@id/detail_progressbar"
app:layout_constraintEnd_toEndOf="@id/detail_progressbar"
app:layout_constraintStart_toStartOf="@id/detail_progressbar"
app:layout_constraintTop_toTopOf="@id/detail_progressbar"
tools:text="选择下载你的版本" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/reuse_listview_item_style"
@ -43,69 +44,24 @@
</LinearLayout>
<LinearLayout
<TextView
android:id="@+id/dm_item_tv_speed"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/unzip_failure_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:src="@drawable/unzip_failure_hint"
android:visibility="gone" />
<TextView
android:id="@+id/dm_item_tv_downloads"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_weight="4"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/text_subtitleDesc"
android:textSize="10sp" />
<ImageView
android:id="@+id/dm_item_iv_delete"
android:layout_width="20dp"
android:layout_height="match_parent"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:src="@drawable/ic_delete" />
<TextView
android:id="@+id/dm_item_tv_speed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:gravity="right"
android:textColor="@color/text_9a9a9a"
android:textSize="10sp" />
</LinearLayout>
<ProgressBar
android:id="@+id/dm_item_progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginBottom="3dp"
android:max="1000"
android:progress="500"
android:progressDrawable="@drawable/progressbar_bg_style" />
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:drawablePadding="2dp"
android:includeFontPadding="false"
android:textColor="@color/theme_font"
android:textSize="@dimen/little_secondary_size"
tools:text="2.41MB/s(剩37秒)" />
</LinearLayout>
<com.gh.common.view.DownloadButton
android:id="@+id/dm_item_tv_startorpause"
android:layout_width="60dp"
android:layout_height="28.5dp"
app:download_button_show_progress="false"
android:layout_width="56dp"
android:layout_height="28dp"
app:download_button_show_progress="true"
app:download_button_text_size="12sp" />
</LinearLayout>

View File

@ -180,61 +180,6 @@
app:layout_constraintTop_toTopOf="@+id/gameDesSpace"
tools:text="巫妖王再怒霜之哀殤又飢渴" />
<TextView
android:id="@+id/download_speed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:singleLine="true"
android:text="@string/game_downloading_formattable"
android:textColor="@color/text_subtitleDesc"
android:textSize="9sp"
app:layout_constraintBottom_toTopOf="@+id/game_progressbar"
app:layout_constraintHorizontal_weight="4"
app:layout_constraintLeft_toLeftOf="@+id/gameDesSpace"
app:layout_constraintRight_toLeftOf="@+id/download_percentage"
app:layout_constraintTop_toTopOf="@+id/gameDesSpace" />
<TextView
android:id="@+id/download_percentage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:gravity="right"
android:singleLine="true"
android:text="@string/game_percentage"
android:textColor="@color/theme_font"
android:textSize="9sp"
app:layout_constraintBottom_toTopOf="@+id/game_progressbar"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@+id/download_speed"
app:layout_constraintRight_toRightOf="@+id/gameDesSpace"
app:layout_constraintTop_toTopOf="@+id/gameDesSpace" />
<androidx.constraintlayout.widget.Group
android:id="@+id/game_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="download_speed,download_percentage" />
<ProgressBar
android:id="@+id/game_progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_marginBottom="4dp"
android:max="1000"
android:progress="500"
android:progressDrawable="@drawable/progressbar_bg_style"
android:visibility="gone"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toLeftOf="@+id/gameDesSpace"
app:layout_constraintRight_toRightOf="@+id/gameDesSpace"
app:layout_constraintTop_toBottomOf="@+id/download_speed" />
<LinearLayout
android:id="@+id/recommendContainer"
android:layout_width="wrap_content"
@ -322,13 +267,42 @@
<com.gh.common.view.DownloadButton
android:id="@+id/download_btn"
android:layout_width="60dp"
android:layout_height="28.5dp"
android:layout_width="56dp"
android:layout_height="28dp"
android:layout_marginLeft="8dp"
app:download_button_show_progress="false"
app:download_button_show_progress="true"
app:download_button_text_size="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/gameDesSpace"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/multiVersionDownloadTv"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:drawablePadding="2dp"
android:gravity="center"
android:text="展开"
android:textColor="@color/white"
android:textSize="@dimen/secondary_size"
android:visibility="gone"
app:drawableEndCompat="@drawable/ic_jump_universal"
app:layout_constraintBottom_toBottomOf="@id/download_btn"
app:layout_constraintEnd_toEndOf="@id/download_btn"
app:layout_constraintStart_toStartOf="@id/download_btn"
app:layout_constraintTop_toTopOf="@id/download_btn" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/downloadTipsLottie"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="-8dp"
android:visibility="gone"
app:lottie_autoPlay="false"
app:lottie_loop="true"
app:lottie_repeatMode="restart"
app:layout_constraintRight_toRightOf="@+id/download_btn"
app:layout_constraintTop_toTopOf="@+id/download_btn" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -191,12 +191,11 @@
<string name="open">打开</string>
<string name="attempt">试玩</string>
<string name="smooth">畅玩</string>
<string name="expand">展开 ></string>
<string name="expand">展开</string>
<string name="unzipping">解压中</string>
<string name="check">查看</string>
<string name="none">暂无</string>
<string name="start_playing">开始玩</string>
<string name="browser_install_downloading">下载后前往浏览器解压安装</string>
<string name="browser_install_install">浏览器解压安装</string>
<string name="taoed_code">已淘号:<Data><![CDATA[<font color="#ffb13c">%1$s</font>]]></Data></string>

View File

@ -529,6 +529,41 @@ object DialogHelper {
)
}
@JvmStatic
fun showDeleteDialog(
context: Context,
title: String,
msg: CharSequence,
confirmText: String,
cancelText: String,
confirmClickCallback: EmptyCallback?,
cancelClickCallback: EmptyCallback?,
isReverse: Boolean
) {
showDialog(
context,
title,
msg,
if (isReverse) cancelText else confirmText,
if (isReverse) confirmText else cancelText,
confirmClickCallback = {
if (isReverse) cancelClickCallback?.onCallback() else confirmClickCallback?.onCallback()
},
cancelClickCallback = {
if (isReverse) confirmClickCallback?.onCallback() else cancelClickCallback?.onCallback()
},
uiModificationCallback = {
val colorAccentRes = if (isReverse) R.color.theme_red else R.color.text_subtitle
val colorDefaultRes = if (isReverse) R.color.text_subtitle else R.color.theme_red
it.cancelTv.setTextColor(colorAccentRes.toColor(context))
it.confirmTv.setTextColor(colorDefaultRes.toColor(context))
},
extraConfig = Config(centerTitle = true, centerContent = true)
)?.setOnCancelListener {
cancelClickCallback?.onCallback()
}
}
/**
* @param context may be is application context
* @return activity context

View File

@ -1423,4 +1423,19 @@ fun TextView.setDrawableBottom(@DrawableRes drawableRes: Int, width: Int? = null
fun TextView.setDrawableBottom(drawable: Drawable?, width: Int? = null, height: Int? = null) {
drawable?.setBounds(0, 0, width ?: drawable.minimumWidth, height ?: drawable.minimumHeight)
this.setCompoundDrawables(null, null, null, drawable)
}
/**
* 设置下载提示Lottie动画
*/
fun LottieAnimationView.setDownloadTipsAnimation(isPlaying: Boolean = false) {
cancelAnimation()
setAnimation(if (DarkModeUtils.isDarkModeOn(context)) "lottie/downloadtips_dark.json" else "lottie/downloadtips_light.json")
if (isPlaying) {
// 动态
playAnimation()
} else {
// 静态
progress = 0.5F
}
}

View File

@ -52,4 +52,6 @@
<string name="game_empty_desc_content">你可能是第一个发现这个地方的人</string>
<string name="reset_load">重试</string>
<string name="loading_network_error_desc">检测网络设置或是点击按钮重试</string>
<string name="is_dark_mode_on_id">is_dark_mode_on_id</string>
</resources>