Skip to content

Commit

Permalink
fix downloads getting stuck
Browse files Browse the repository at this point in the history
(cherry picked from commit 2698120)
  • Loading branch information
crackededed committed Sep 10, 2024
1 parent e905337 commit c44d270
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId = "com.github.andreyasadchy.xtra"
minSdk = 21
targetSdk = 35
versionCode = 253
versionName = "2.34.2"
versionCode = 254
versionName = "2.34.3"
}

buildTypes {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/github/andreyasadchy/xtra/XtraApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.github.andreyasadchy.xtra.di.AppInjector
import com.github.andreyasadchy.xtra.util.AppLifecycleObserver
import com.github.andreyasadchy.xtra.util.LifecycleListener
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.Dispatchers
import javax.inject.Inject


Expand Down Expand Up @@ -53,6 +54,7 @@ class XtraApp : Application(), Configuration.Provider, ImageLoaderFactory {

override val workManagerConfiguration: Configuration
get() = Configuration.Builder()
.setWorkerCoroutineContext(Dispatchers.IO)
.setWorkerFactory(workerFactory)
.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withLock
Expand Down Expand Up @@ -96,7 +97,7 @@ class StreamDownloadWorker @AssistedInject constructor(
offlineVideo = firstVideo
offlineRepository.updateVideo(offlineVideo.apply { status = OfflineVideo.STATUS_WAITING_FOR_STREAM })
setForeground(createForegroundInfo(false, firstVideo))
return withContext(Dispatchers.IO) {
return runBlocking {
val path = offlineVideo.downloadPath!!
val channelLogin = offlineVideo.channelLogin!!
val quality = offlineVideo.quality
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,17 @@ import com.github.andreyasadchy.xtra.util.prefs
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.sync.withPermit
import kotlinx.coroutines.withContext
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
Expand Down Expand Up @@ -108,7 +107,7 @@ class VideoDownloadWorker @AssistedInject constructor(
offlineVideo = offlineRepository.getVideoById(inputData.getInt(KEY_VIDEO_ID, 0)) ?: return Result.failure()
offlineRepository.updateVideo(offlineVideo.apply { status = OfflineVideo.STATUS_DOWNLOADING })
setForeground(createForegroundInfo())
return withContext(Dispatchers.IO) {
return runBlocking {
val sourceUrl = offlineVideo.sourceUrl!!
if (sourceUrl.endsWith(".m3u8")) {
val path = offlineVideo.downloadPath!!
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
android-gradle-plugin = "8.6.0"
apollo = "3.8.5"
appcompat = "1.7.0"
checker-qual = "3.46.0"
checker-qual = "3.47.0"
coil = "2.7.0"
constraintlayout = "2.1.4"
core = "1.13.1"
coroutines = "1.8.1"
draglistview = "1.7.3"
fragment = "1.8.2"
fragment = "1.8.3"
glide = "4.16.0"
glide-webpdecoder = "2.6.4.16.0"
hilt = "2.52"
hilt-extension-compiler = "1.2.0"
hilt-work = "1.2.0"
kotlin = "2.0.20"
ksp = "2.0.20-1.0.24"
lifecycle = "2.8.4"
lifecycle = "2.8.5"
material = "1.12.0"
media3 = "1.4.1"
navigation = "2.7.7"
navigation = "2.8.0"
okhttp = "5.0.0-alpha.14"
okio = "3.9.0"
paging = "3.3.2"
Expand All @@ -29,7 +29,7 @@ room = "2.6.1"
serialization = "1.7.2"
swiperefreshlayout = "1.1.0"
webkit = "1.11.0"
work = "2.9.1"
work = "2.10.0-alpha03"

[libraries]
apollo-runtime = { module = "com.apollographql.apollo3:apollo-runtime", version.ref = "apollo" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit c44d270

Please sign in to comment.