fix: novel loading

This commit is contained in:
rebelonion 2024-04-21 07:36:23 -05:00
parent 513b937e59
commit 4ffe9d7505
4 changed files with 22 additions and 6 deletions

View file

@ -636,6 +636,23 @@ fun ImageView.loadImage(file: FileUrl?, size: Int = 0) {
}
}
fun ImageView.loadImage(file: FileUrl?, width: Int = 0, height: Int = 0) {
file?.url = PrefManager.getVal<String>(PrefName.ImageUrl).ifEmpty { file?.url ?: "" }
if (file?.url?.isNotEmpty() == true) {
tryWith {
if (file.url.startsWith("content://")) {
Glide.with(this.context).load(Uri.parse(file.url)).transition(withCrossFade())
.override(width, height).into(this)
} else {
val glideUrl = GlideUrl(file.url) { file.headers }
Glide.with(this.context).load(glideUrl).transition(withCrossFade()).override(width, height)
.into(this)
}
}
}
}
fun ImageView.loadLocalImage(file: File?, size: Int = 0) {
if (file?.exists() == true) {
tryWith {

View file

@ -117,9 +117,10 @@ class NovelReadFragment : Fragment(),
context ?: currContext()!!,
MediaType.NOVEL,
false,
media.mainName(),
novel.name
)
val file = directory?.findFile(novel.name)
val file = directory?.findFile("0.epub")
if (file?.exists() == false) return false
val fileUri = file?.uri ?: return false
val intent = Intent(context, NovelReaderActivity::class.java).apply {

View file

@ -8,6 +8,7 @@ import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import ani.dantotsu.R
import ani.dantotsu.databinding.ItemNovelResponseBinding
import ani.dantotsu.loadImage
import ani.dantotsu.parsers.ShowResponse
import ani.dantotsu.setAnimation
import ani.dantotsu.snackString
@ -37,10 +38,7 @@ class NovelResponseAdapter(
val binding = holder.binding
val novel = list[position]
setAnimation(fragment.requireContext(), holder.binding.root)
val cover = GlideUrl(novel.coverUrl.url) { novel.coverUrl.headers }
Glide.with(binding.itemEpisodeImage).load(cover).override(400, 0)
.into(binding.itemEpisodeImage)
binding.itemEpisodeImage.loadImage(novel.coverUrl, 400, 0)
val typedValue = TypedValue()
fragment.requireContext().theme?.resolveAttribute(

View file

@ -73,7 +73,7 @@ class OfflineNovelParser : NovelParser() {
}
val cover = directory?.findFile("cover.jpg")?.uri.toString()
names.forEach {
returnList.add(ShowResponse(it, it, cover))
returnList.add(ShowResponse(it, query, cover))
}
}
return returnList