尝试缓存下载队列状态,避免下载按钮直接访问数据库

This commit is contained in:
juntao
2021-09-29 17:44:40 +08:00
parent 047c45db9a
commit ad6114a44b
5 changed files with 20 additions and 9 deletions

View File

@ -465,7 +465,7 @@ public class BindingAdapters {
case INSTALL_PLUGIN:
case INSTALL_NORMAL:
if (gameEntity.getApk().size() == 1) {
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntitySnapshotByUrl(gameEntity.getApk().get(0).getUrl());
if (downloadEntity != null) {
PackageInstaller.install(v.getContext(), downloadEntity);
}
@ -574,7 +574,7 @@ public class BindingAdapters {
// 显示下载过程状态
if (gameEntity.getApk().size() == 1) {
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntityByUrl(gameEntity.getApk().get(0).getUrl());
DownloadEntity downloadEntity = DownloadManager.getInstance(progressBar.getContext()).getDownloadEntitySnapshotByUrl(gameEntity.getApk().get(0).getUrl());
if (downloadEntity != null) {
progressBar.setProgress((int) (downloadEntity.getPercent() * 10));
switch (downloadEntity.getStatus()) {