fix: novel loading
This commit is contained in:
parent
513b937e59
commit
4ffe9d7505
4 changed files with 22 additions and 6 deletions
|
@ -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) {
|
fun ImageView.loadLocalImage(file: File?, size: Int = 0) {
|
||||||
if (file?.exists() == true) {
|
if (file?.exists() == true) {
|
||||||
tryWith {
|
tryWith {
|
||||||
|
|
|
@ -117,9 +117,10 @@ class NovelReadFragment : Fragment(),
|
||||||
context ?: currContext()!!,
|
context ?: currContext()!!,
|
||||||
MediaType.NOVEL,
|
MediaType.NOVEL,
|
||||||
false,
|
false,
|
||||||
|
media.mainName(),
|
||||||
novel.name
|
novel.name
|
||||||
)
|
)
|
||||||
val file = directory?.findFile(novel.name)
|
val file = directory?.findFile("0.epub")
|
||||||
if (file?.exists() == false) return false
|
if (file?.exists() == false) return false
|
||||||
val fileUri = file?.uri ?: return false
|
val fileUri = file?.uri ?: return false
|
||||||
val intent = Intent(context, NovelReaderActivity::class.java).apply {
|
val intent = Intent(context, NovelReaderActivity::class.java).apply {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import ani.dantotsu.R
|
import ani.dantotsu.R
|
||||||
import ani.dantotsu.databinding.ItemNovelResponseBinding
|
import ani.dantotsu.databinding.ItemNovelResponseBinding
|
||||||
|
import ani.dantotsu.loadImage
|
||||||
import ani.dantotsu.parsers.ShowResponse
|
import ani.dantotsu.parsers.ShowResponse
|
||||||
import ani.dantotsu.setAnimation
|
import ani.dantotsu.setAnimation
|
||||||
import ani.dantotsu.snackString
|
import ani.dantotsu.snackString
|
||||||
|
@ -37,10 +38,7 @@ class NovelResponseAdapter(
|
||||||
val binding = holder.binding
|
val binding = holder.binding
|
||||||
val novel = list[position]
|
val novel = list[position]
|
||||||
setAnimation(fragment.requireContext(), holder.binding.root)
|
setAnimation(fragment.requireContext(), holder.binding.root)
|
||||||
|
binding.itemEpisodeImage.loadImage(novel.coverUrl, 400, 0)
|
||||||
val cover = GlideUrl(novel.coverUrl.url) { novel.coverUrl.headers }
|
|
||||||
Glide.with(binding.itemEpisodeImage).load(cover).override(400, 0)
|
|
||||||
.into(binding.itemEpisodeImage)
|
|
||||||
|
|
||||||
val typedValue = TypedValue()
|
val typedValue = TypedValue()
|
||||||
fragment.requireContext().theme?.resolveAttribute(
|
fragment.requireContext().theme?.resolveAttribute(
|
||||||
|
|
|
@ -73,7 +73,7 @@ class OfflineNovelParser : NovelParser() {
|
||||||
}
|
}
|
||||||
val cover = directory?.findFile("cover.jpg")?.uri.toString()
|
val cover = directory?.findFile("cover.jpg")?.uri.toString()
|
||||||
names.forEach {
|
names.forEach {
|
||||||
returnList.add(ShowResponse(it, it, cover))
|
returnList.add(ShowResponse(it, query, cover))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnList
|
return returnList
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue