Bug fix
This commit is contained in:
@@ -20,7 +20,7 @@ android {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 43
|
||||
versionName "4.7-beta2"
|
||||
versionName "4.7"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":43,"versionName":"4.7-beta2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":43,"versionName":"4.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||
@@ -19,6 +19,7 @@
|
||||
package xyz.quaver.pupil.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -122,12 +123,23 @@ class ReaderAdapter(private val context: Context,
|
||||
val progress = DownloadWorker.getInstance(context).progress[galleryID]?.get(position)
|
||||
|
||||
if (progress?.isInfinite() == true && images != null) {
|
||||
holder.view.reader_item_progressbar.visibility = View.GONE
|
||||
holder.view.reader_item_progressbar.visibility = View.INVISIBLE
|
||||
holder.view.container.apply {
|
||||
val options = BitmapFactory.Options().apply {
|
||||
inJustDecodeBounds = true
|
||||
}
|
||||
|
||||
BitmapFactory.decodeFile(images.canonicalPath, options)
|
||||
|
||||
maxWidth = options.outWidth
|
||||
maxHeight = options.outHeight
|
||||
}
|
||||
|
||||
glide
|
||||
.load(images)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.dontTransform()
|
||||
.error(R.drawable.image_broken_variant)
|
||||
.apply {
|
||||
if (BuildConfig.CENSOR)
|
||||
@@ -135,6 +147,12 @@ class ReaderAdapter(private val context: Context,
|
||||
}
|
||||
.into(holder.view.image)
|
||||
} else {
|
||||
holder.view.reader_item_progressbar.visibility = View.VISIBLE
|
||||
holder.view.container.apply {
|
||||
maxWidth = Integer.MAX_VALUE
|
||||
maxHeight = Integer.MAX_VALUE
|
||||
}
|
||||
|
||||
if (progress?.isNaN() == true) {
|
||||
if (Fabric.isInitialized())
|
||||
Crashlytics.logException(DownloadWorker.getInstance(context).exception[galleryID]?.get(position))
|
||||
|
||||
@@ -333,7 +333,26 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
||||
|
||||
Log.i("PUPILD", "SUCCESS ${call.request().tag()}")
|
||||
} catch (e: Exception) {
|
||||
|
||||
progress[galleryID]?.set(i, Float.NaN)
|
||||
exception[galleryID]?.set(i, e)
|
||||
|
||||
notify(galleryID)
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (isCompleted(galleryID) && clients.indexOfKey(galleryID) >= 0) {
|
||||
clients.remove(galleryID)
|
||||
with(Cache(this@DownloadWorker)) {
|
||||
if (isDownloading(galleryID)) {
|
||||
moveToDownload(galleryID)
|
||||
setDownloading(galleryID, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File(Cache(this@DownloadWorker).getCachedGallery(galleryID), "%05d.$ext".format(i)).delete()
|
||||
|
||||
Log.i("PUPILD", "FAIL ON OK ${call.request().tag()} (${e.message})")
|
||||
}
|
||||
}
|
||||
@@ -352,13 +371,17 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
||||
val max = progress[galleryID]?.size ?: 0
|
||||
val progress = progress[galleryID]?.count { !it.isFinite() } ?: 0
|
||||
|
||||
if (isCompleted(galleryID))
|
||||
Log.i("PUPILD", "NOTIFY $galleryID ${isCompleted(galleryID)} $progress/$max")
|
||||
|
||||
if (isCompleted(galleryID)) {
|
||||
notification[galleryID]
|
||||
?.setContentText(getString(R.string.reader_notification_complete))
|
||||
?.setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
?.setProgress(0, 0, false)
|
||||
?.setOngoing(false)
|
||||
else
|
||||
|
||||
notificationManager.cancel(galleryID)
|
||||
} else
|
||||
notification[galleryID]
|
||||
?.setProgress(max, progress, false)
|
||||
?.setContentText("$progress/$max")
|
||||
@@ -390,18 +413,27 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
||||
|
||||
private fun loop() = CoroutineScope(Dispatchers.Default).launch {
|
||||
while (true) {
|
||||
if (queue.isEmpty() || clients.size() >= preferences.getInt("max_download", 4))
|
||||
if (queue.isEmpty())
|
||||
continue
|
||||
|
||||
val galleryID = queue.poll() ?: continue
|
||||
val galleryID = queue.peek() ?: continue
|
||||
|
||||
if (clients.indexOfKey(galleryID) >= 0) // Gallery already downloading!
|
||||
continue
|
||||
|
||||
initNotification(galleryID)
|
||||
if (notification[galleryID] == null)
|
||||
initNotification(galleryID)
|
||||
|
||||
if (Cache(this@DownloadWorker).isDownloading(galleryID))
|
||||
notificationManager.notify(galleryID, notification[galleryID].build())
|
||||
|
||||
if (clients.size() >= preferences.getInt("max_download", 4))
|
||||
continue
|
||||
|
||||
Log.i("PUPILD", "QUEUED $galleryID #${clients.size()+1}")
|
||||
|
||||
worker.put(galleryID, download(galleryID))
|
||||
queue.poll()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:maxHeight="5000dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
|
||||
Reference in New Issue
Block a user