Release 1.2.1
- Fixed the dictionary update card taking too long to reappear after
cancelling a download (DownloadManager).
- Bump agp 9.3.0 -> 9.3.1; migrate the release build type from
isMinifyEnabled/isShrinkResources/proguardFiles to
optimization { enable = true } with keep rules moved to
app/src/release/keepRules/proguard-rules.keep.
This commit is contained in:
1 parent
c8adf537d4
commit
69bbb97b2a
6 files changed
+17
-13
No files matched your search
@@ -24,6 +24,7 @@ class DownloadManager(
|
||||
mutableDownloadProgressState.asStateFlow()
|
||||
private val mutex = Mutex()
|
||||
private var downloadJob: Job? = null
|
||||
private var cancelCleanupJob: Job? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DownloadManager"
|
||||
@@ -44,6 +45,7 @@ class DownloadManager(
|
||||
fun startDownload() {
|
||||
if (downloadState.value is DownloadState.Loading) return
|
||||
if (!downloadScope.isActive) return
|
||||
cancelCleanupJob = null
|
||||
downloadJob = downloadScope.launch {
|
||||
mutex.withLock {
|
||||
try {
|
||||
@@ -94,7 +96,7 @@ class DownloadManager(
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) {
|
||||
updateDownloadProgressState(DownloadState.Cancelled, 0f)
|
||||
downloadScope.launch {
|
||||
cancelCleanupJob = downloadScope.launch {
|
||||
try {
|
||||
dictionaryRepository.deleteUnprocessedFiles()
|
||||
} catch (cleanupException: Exception) {
|
||||
@@ -124,6 +126,7 @@ class DownloadManager(
|
||||
fun startDownloadForSources(sourceUrls: List<String>) {
|
||||
if (downloadState.value is DownloadState.Loading) return
|
||||
if (!downloadScope.isActive) return
|
||||
cancelCleanupJob = null
|
||||
downloadJob = downloadScope.launch {
|
||||
mutex.withLock {
|
||||
try {
|
||||
@@ -168,7 +171,7 @@ class DownloadManager(
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) {
|
||||
updateDownloadProgressState(DownloadState.Cancelled, 0f)
|
||||
downloadScope.launch {
|
||||
cancelCleanupJob = downloadScope.launch {
|
||||
try {
|
||||
dictionaryRepository.deleteUnprocessedFiles()
|
||||
} catch (cleanupException: Exception) {
|
||||
@@ -195,10 +198,12 @@ class DownloadManager(
|
||||
}
|
||||
}
|
||||
fun cancelDownload() {
|
||||
downloadJob?.cancel()
|
||||
val jobToCancel = downloadJob
|
||||
jobToCancel?.cancel()
|
||||
updateDownloadProgressState(DownloadState.Cancelled, 0f)
|
||||
downloadScope.launch {
|
||||
delay(TERMINAL_STATE_DURATION)
|
||||
jobToCancel?.join()
|
||||
cancelCleanupJob?.join()
|
||||
if (downloadState.value == DownloadState.Cancelled) {
|
||||
updateDownloadProgressState(DownloadState.Idle, 0f)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user