fix: offline mode failing
This commit is contained in:
parent
ea29449413
commit
7ca44480a9
6 changed files with 28 additions and 8 deletions
|
@ -1350,7 +1350,11 @@ fun blurImage(imageView: ImageView, banner: String?) {
|
||||||
if (!(context as Activity).isDestroyed) {
|
if (!(context as Activity).isDestroyed) {
|
||||||
val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner }
|
val url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { banner }
|
||||||
Glide.with(context as Context)
|
Glide.with(context as Context)
|
||||||
.load(GlideUrl(url))
|
.load(
|
||||||
|
if (banner.startsWith("http")) GlideUrl(url) else if (banner.startsWith("content://")) Uri.parse(
|
||||||
|
url
|
||||||
|
) else File(url)
|
||||||
|
)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE).override(400)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE).override(400)
|
||||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling)))
|
.apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling)))
|
||||||
.into(imageView)
|
.into(imageView)
|
||||||
|
|
|
@ -36,6 +36,7 @@ import ani.dantotsu.download.DownloadsManager
|
||||||
import ani.dantotsu.download.DownloadsManager.Companion.compareName
|
import ani.dantotsu.download.DownloadsManager.Companion.compareName
|
||||||
import ani.dantotsu.download.anime.AnimeDownloaderService
|
import ani.dantotsu.download.anime.AnimeDownloaderService
|
||||||
import ani.dantotsu.dp
|
import ani.dantotsu.dp
|
||||||
|
import ani.dantotsu.isOnline
|
||||||
import ani.dantotsu.media.Media
|
import ani.dantotsu.media.Media
|
||||||
import ani.dantotsu.media.MediaDetailsActivity
|
import ani.dantotsu.media.MediaDetailsActivity
|
||||||
import ani.dantotsu.media.MediaDetailsViewModel
|
import ani.dantotsu.media.MediaDetailsViewModel
|
||||||
|
@ -198,10 +199,15 @@ class AnimeWatchFragment : Fragment() {
|
||||||
ConcatAdapter(headerAdapter, episodeAdapter)
|
ConcatAdapter(headerAdapter, episodeAdapter)
|
||||||
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
awaitAll(
|
val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode)
|
||||||
async { model.loadKitsuEpisodes(media) },
|
if (offline) {
|
||||||
async { model.loadFillerEpisodes(media) }
|
media.selected!!.sourceIndex = model.watchSources!!.list.lastIndex
|
||||||
)
|
} else {
|
||||||
|
awaitAll(
|
||||||
|
async { model.loadKitsuEpisodes(media) },
|
||||||
|
async { model.loadFillerEpisodes(media) }
|
||||||
|
)
|
||||||
|
}
|
||||||
model.loadEpisodes(media, media.selected!!.sourceIndex)
|
model.loadEpisodes(media, media.selected!!.sourceIndex)
|
||||||
}
|
}
|
||||||
loaded = true
|
loaded = true
|
||||||
|
|
|
@ -38,6 +38,7 @@ import ani.dantotsu.download.DownloadsManager.Companion.compareName
|
||||||
import ani.dantotsu.download.manga.MangaDownloaderService
|
import ani.dantotsu.download.manga.MangaDownloaderService
|
||||||
import ani.dantotsu.download.manga.MangaServiceDataSingleton
|
import ani.dantotsu.download.manga.MangaServiceDataSingleton
|
||||||
import ani.dantotsu.dp
|
import ani.dantotsu.dp
|
||||||
|
import ani.dantotsu.isOnline
|
||||||
import ani.dantotsu.media.Media
|
import ani.dantotsu.media.Media
|
||||||
import ani.dantotsu.media.MediaDetailsActivity
|
import ani.dantotsu.media.MediaDetailsActivity
|
||||||
import ani.dantotsu.media.MediaDetailsViewModel
|
import ani.dantotsu.media.MediaDetailsViewModel
|
||||||
|
@ -202,6 +203,8 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener {
|
||||||
ConcatAdapter(headerAdapter, chapterAdapter)
|
ConcatAdapter(headerAdapter, chapterAdapter)
|
||||||
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
|
val offline = !isOnline(binding.root.context) || PrefManager.getVal(PrefName.OfflineMode)
|
||||||
|
if (offline) media.selected!!.sourceIndex = model.mangaReadSources!!.list.lastIndex
|
||||||
model.loadMangaChapters(media, media.selected!!.sourceIndex)
|
model.loadMangaChapters(media, media.selected!!.sourceIndex)
|
||||||
}
|
}
|
||||||
loaded = true
|
loaded = true
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package ani.dantotsu.profile
|
package ani.dantotsu.profile
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
data class User(
|
data class User(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val name: String,
|
val name: String,
|
||||||
|
@ -11,4 +14,8 @@ data class User(
|
||||||
val progress: Int? = null,
|
val progress: Int? = null,
|
||||||
val totalEpisodes : Int? = null,
|
val totalEpisodes : Int? = null,
|
||||||
val nextAiringEpisode : Int? = null,
|
val nextAiringEpisode : Int? = null,
|
||||||
)
|
) : java.io.Serializable {
|
||||||
|
companion object {
|
||||||
|
private const val serialVersionUID: Long = 1
|
||||||
|
}
|
||||||
|
}
|
|
@ -65,7 +65,7 @@ class StoragePermissions {
|
||||||
force: Boolean = false,
|
force: Boolean = false,
|
||||||
complete: (Boolean) -> Unit
|
complete: (Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
if ((PrefManager.getVal<String>(PrefName.DownloadsDir).isNotEmpty() || hasDirAccess(this)) && !force) {
|
if (hasDirAccess(this) && !force) {
|
||||||
complete(true)
|
complete(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.3.1'
|
classpath 'com.android.tools.build:gradle:8.3.2'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
classpath "com.google.devtools.ksp:symbol-processing-api:$ksp_version"
|
classpath "com.google.devtools.ksp:symbol-processing-api:$ksp_version"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue