Dependency update
Fixed duplicated download file Better download progress update handling TODO: Add group name to GalleryBlock
This commit is contained in:
@@ -126,7 +126,7 @@ dependencies {
|
||||
|
||||
implementation "xyz.quaver:libpupil:1.7.2"
|
||||
implementation "xyz.quaver:documentfilex:0.2.15"
|
||||
implementation "xyz.quaver:floatingsearchview:1.0.5"
|
||||
implementation "xyz.quaver:floatingsearchview:1.0.7"
|
||||
|
||||
testImplementation "junit:junit:4.13"
|
||||
androidTestImplementation "androidx.test.ext:junit:1.1.2"
|
||||
|
||||
@@ -57,11 +57,11 @@ class GalleryBlockAdapter(private val galleries: List<Int>) : RecyclerSwipeAdapt
|
||||
PREV
|
||||
}
|
||||
|
||||
var update = true
|
||||
var updateAll = true
|
||||
var thin: Boolean = Preferences["thin"]
|
||||
|
||||
inner class GalleryViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
|
||||
var updateJob: Job? = null
|
||||
var update = true
|
||||
|
||||
private fun updateProgress(context: Context, galleryID: Int) {
|
||||
val cache = Cache.getInstance(context, galleryID)
|
||||
@@ -162,13 +162,12 @@ class GalleryBlockAdapter(private val galleries: List<Int>) : RecyclerSwipeAdapt
|
||||
}
|
||||
}
|
||||
|
||||
if (updateJob == null)
|
||||
updateJob = CoroutineScope(Dispatchers.Main).launch {
|
||||
while (update) {
|
||||
updateProgress(context, galleryID)
|
||||
delay(1000)
|
||||
}
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
while (updateAll && update) {
|
||||
updateProgress(context, galleryID)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
|
||||
galleryblock_title.text = galleryBlock.title
|
||||
with(galleryblock_artist) {
|
||||
@@ -361,10 +360,8 @@ class GalleryBlockAdapter(private val galleries: List<Int>) : RecyclerSwipeAdapt
|
||||
override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewDetachedFromWindow(holder)
|
||||
|
||||
if (holder is GalleryViewHolder) {
|
||||
holder.updateJob?.cancel()
|
||||
holder.updateJob = null
|
||||
}
|
||||
if (holder is GalleryViewHolder)
|
||||
holder.update = false
|
||||
}
|
||||
|
||||
override fun getItemCount() =
|
||||
|
||||
@@ -146,7 +146,7 @@ class MainActivity :
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
(main_recyclerview?.adapter as? GalleryBlockAdapter)?.update = false
|
||||
(main_recyclerview?.adapter as? GalleryBlockAdapter)?.updateAll = false
|
||||
}
|
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
|
||||
@@ -192,7 +192,8 @@ class Cache private constructor(context: Context, val galleryID: Int) : ContextW
|
||||
fun putImage(index: Int, fileName: String, data: ByteArray) {
|
||||
val file = cacheFolder.getChild(fileName)
|
||||
|
||||
file.createNewFile()
|
||||
if (!file.exists())
|
||||
file.createNewFile()
|
||||
file.writeBytes(data)
|
||||
setMetadata { metadata -> metadata.imageList!![index] = fileName }
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
<string name="reader_imageview_description" translatable="false">Content ImageView</string>
|
||||
<string name="page_indicator_placeholder" translatable="false">-/-</string>
|
||||
|
||||
<string name="galleryblock_artist_with_group" translatable="false">%s (%s)</string>
|
||||
|
||||
<!-- Translate needed down here -->
|
||||
|
||||
<string name="warning">Warning</string>
|
||||
|
||||
Reference in New Issue
Block a user