下载管理相关优化

This commit is contained in:
chenjuntao
2021-08-21 10:57:45 +08:00
parent 9c044ae98b
commit 1d9e1bc9d8
74 changed files with 1763 additions and 118 deletions

View File

@ -32,6 +32,7 @@ import com.gh.common.util.PackageUtils;
import com.gh.common.util.PageSwitchDataHelper;
import com.gh.common.util.SPUtils;
import com.gh.gamecenter.BuildConfig;
import com.gh.gamecenter.download.DownloadedGameIdAndPackageNameDao;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.GameUpdateEntity;
@ -88,6 +89,7 @@ public class DownloadManager implements DownloadStatusListener {
private ArrayMap<String, DownloadEntity> downloadingMap;
private DownloadDao mDownloadDao;
private DownloadedGameIdAndPackageNameDao mDownloadedGameIdAndPackageNameDao;
private Set<String> mUpdateMarks;
@ -132,6 +134,8 @@ public class DownloadManager implements DownloadStatusListener {
public void onTaskDone(DownloadEntity entity) {
downloadingMap.remove(entity.getUrl());
mDownloadedGameIdAndPackageNameDao.add(entity.getGameId() + entity.getPackageName());
if (downloadingMap.isEmpty()) {
DownloadWorkManager.cancelWorker();
}
@ -145,6 +149,7 @@ public class DownloadManager implements DownloadStatusListener {
private DownloadManager(Context context) {
mContext = context.getApplicationContext();
mDownloadDao = DownloadDao.getInstance(mContext);
mDownloadedGameIdAndPackageNameDao = new DownloadedGameIdAndPackageNameDao();
mUpdateMarks = SPUtils.getStringSet(UPDATE_IS_READ_MARK);