[fix] Offline mode display exception
This commit is contained in:
@@ -120,6 +120,10 @@ class FetchManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun startVideoDownload(video: Video) {
|
suspend fun startVideoDownload(video: Video) {
|
||||||
|
if(getAllDownloadsAsync().any{
|
||||||
|
it.extras.getString("class", "") == video.klass && it.extras.getString("id", "") == video.id })
|
||||||
|
return
|
||||||
|
|
||||||
makeFolder(video)
|
makeFolder(video)
|
||||||
File(
|
File(
|
||||||
context.getExternalFilesDir(null),
|
context.getExternalFilesDir(null),
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import kotlinx.coroutines.withContext
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.collections.sortedWith
|
import kotlin.collections.sortedWith
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TransmissionScreen(
|
fun TransmissionScreen(
|
||||||
@@ -254,7 +255,7 @@ private fun VideoDownloadCard(
|
|||||||
|
|
||||||
// progress bar
|
// progress bar
|
||||||
LinearProgressIndicator(
|
LinearProgressIndicator(
|
||||||
progress = { model.progress.coerceIn(0, 100) / 100f },
|
progress = { abs(model.progress).coerceIn(0, 100) / 100f },
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(top = 8.dp, bottom = 8.dp),
|
.padding(top = 8.dp, bottom = 8.dp),
|
||||||
|
|||||||
@@ -349,13 +349,14 @@ fun VideoCard(
|
|||||||
{
|
{
|
||||||
videoScreenViewModel.download(i)
|
videoScreenViewModel.download(i)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
videoScreenViewModel.context,
|
videoScreenViewModel.context,
|
||||||
"Start downloading ${video.video.group}",
|
"Start downloading ${video.video.group}",
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
),
|
),
|
||||||
shape = RoundedCornerShape(6.dp),
|
shape = RoundedCornerShape(6.dp),
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import javax.inject.Singleton
|
|||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class VideoScreenViewModel @Inject constructor(
|
class VideoScreenViewModel @Inject constructor(
|
||||||
private val fetchManager: FetchManager,
|
val fetchManager: FetchManager,
|
||||||
@ApplicationContext val context: Context,
|
@ApplicationContext val context: Context,
|
||||||
val mediaManager: MediaManager,
|
val mediaManager: MediaManager,
|
||||||
val recentManager: RecentManager,
|
val recentManager: RecentManager,
|
||||||
@@ -82,7 +82,9 @@ class VideoScreenViewModel @Inject constructor(
|
|||||||
videoLibrary.classesMap["Offline"] = mutableStateListOf<Video>()
|
videoLibrary.classesMap["Offline"] = mutableStateListOf<Video>()
|
||||||
|
|
||||||
val downloaded = fetchManager.getAllDownloadsAsync().filter {
|
val downloaded = fetchManager.getAllDownloadsAsync().filter {
|
||||||
it.status == Status.COMPLETED && it.extras.getString("class", "") != "comic"
|
it.status == Status.COMPLETED &&
|
||||||
|
it.extras.getString("class", "") != "comic" &&
|
||||||
|
it.extras.getString("type", "") == "main"
|
||||||
}
|
}
|
||||||
|
|
||||||
val jsonQuery = downloaded.map{ File(
|
val jsonQuery = downloaded.map{ File(
|
||||||
|
|||||||
Reference in New Issue
Block a user