Fixed image broken after download finishes
This commit is contained in:
@@ -32,8 +32,12 @@ import com.bumptech.glide.request.RequestListener
|
|||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import xyz.quaver.pupil.BuildConfig
|
import xyz.quaver.pupil.BuildConfig
|
||||||
import xyz.quaver.pupil.R
|
import xyz.quaver.pupil.R
|
||||||
|
import xyz.quaver.pupil.util.getCachedGallery
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class ReaderAdapter(private val glide: RequestManager, private val images: List<String>) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
class ReaderAdapter(private val glide: RequestManager,
|
||||||
|
private val galleryID: Int,
|
||||||
|
private val images: List<String>) : RecyclerView.Adapter<ReaderAdapter.ViewHolder>() {
|
||||||
|
|
||||||
var isFullScreen = false
|
var isFullScreen = false
|
||||||
private var prev : Drawable? = null
|
private var prev : Drawable? = null
|
||||||
@@ -52,7 +56,7 @@ class ReaderAdapter(private val glide: RequestManager, private val images: List<
|
|||||||
holder.view as ImageView
|
holder.view as ImageView
|
||||||
|
|
||||||
glide
|
glide
|
||||||
.load(images[position])
|
.load(File(getCachedGallery(holder.view.context, galleryID), images[position]))
|
||||||
.dontTransform()
|
.dontTransform()
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
.skipMemoryCache(true)
|
.skipMemoryCache(true)
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ class ReaderActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
with(reader_recyclerview) {
|
with(reader_recyclerview) {
|
||||||
adapter = ReaderAdapter(Glide.with(this@ReaderActivity), images)
|
adapter = ReaderAdapter(Glide.with(this@ReaderActivity), galleryID, images)
|
||||||
|
|
||||||
addOnScrollListener(object: RecyclerView.OnScrollListener() {
|
addOnScrollListener(object: RecyclerView.OnScrollListener() {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
|
|||||||
@@ -63,16 +63,17 @@ class GalleryDownloader(
|
|||||||
field = true
|
field = true
|
||||||
notificationManager.notify(galleryID, notificationBuilder.build())
|
notificationManager.notify(galleryID, notificationBuilder.build())
|
||||||
|
|
||||||
val data = File(getDownloadDirectory(this), galleryID.toString())
|
if (reader?.isActive == false && downloadJob?.isActive != true) {
|
||||||
val cache = File(cacheDir, "imageCache/$galleryID")
|
val data = File(getDownloadDirectory(this), galleryID.toString())
|
||||||
|
val cache = File(cacheDir, "imageCache/$galleryID")
|
||||||
|
|
||||||
if (File(cache, "images").exists() && !data.exists()) {
|
if (File(cache, "images").exists() && !data.exists()) {
|
||||||
cache.copyRecursively(data, true)
|
cache.copyRecursively(data, true)
|
||||||
cache.deleteRecursively()
|
cache.deleteRecursively()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader?.isActive == false && downloadJob?.isActive != true)
|
|
||||||
field = false
|
field = false
|
||||||
|
}
|
||||||
|
|
||||||
downloads.add(galleryID)
|
downloads.add(galleryID)
|
||||||
} else {
|
} else {
|
||||||
@@ -223,7 +224,7 @@ class GalleryDownloader(
|
|||||||
notificationManager.notify(galleryID, notificationBuilder.build())
|
notificationManager.notify(galleryID, notificationBuilder.build())
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.absolutePath
|
"images/$name.$ext"
|
||||||
}
|
}
|
||||||
}.forEach {
|
}.forEach {
|
||||||
list.add(it.await())
|
list.add(it.await())
|
||||||
|
|||||||
Reference in New Issue
Block a user