diff --git a/app/build.gradle b/app/build.gradle index ee89e59f..d97d70da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,7 +20,7 @@ android { minSdkVersion 16 targetSdkVersion 29 versionCode 42 - versionName "4.6-beta3" + versionName "4.6-beta4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true vectorDrawables.useSupportLibrary = true diff --git a/app/release/output.json b/app/release/output.json index 6d4690c1..7f8176d4 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":42,"versionName":"4.6-beta3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":42,"versionName":"4.6-beta4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/xyz/quaver/pupil/ui/MainActivity.kt b/app/src/main/java/xyz/quaver/pupil/ui/MainActivity.kt index 14f6c3a3..34ceca14 100644 --- a/app/src/main/java/xyz/quaver/pupil/ui/MainActivity.kt +++ b/app/src/main/java/xyz/quaver/pupil/ui/MainActivity.kt @@ -937,26 +937,26 @@ class MainActivity : AppCompatActivity() { when(sortMode) { SortMode.POPULAR -> getGalleryIDsFromNozomi(null, "popular", "all") else -> getGalleryIDsFromNozomi(null, "index", "all") - }.apply { - totalItems = size + }.also { + totalItems = it.size } } - else -> doSearch("$defaultQuery $query", sortMode == SortMode.POPULAR).apply { - totalItems = size + else -> doSearch("$defaultQuery $query", sortMode == SortMode.POPULAR).also { + totalItems = it.size } } } Mode.HISTORY -> { when { query.isEmpty() -> { - histories.toList().apply { - totalItems = size + histories.toList().also { + totalItems = it.size } } else -> { val result = doSearch(query).sorted() - histories.filter { result.binarySearch(it) >= 0 }.apply { - totalItems = size + histories.filter { result.binarySearch(it) >= 0 }.also { + totalItems = it.size } } } @@ -969,26 +969,26 @@ class MainActivity : AppCompatActivity() { } ?: emptyList() when { - query.isEmpty() -> downloads.apply { - totalItems = size + query.isEmpty() -> downloads.also { + totalItems = it.size } else -> { val result = doSearch(query).sorted() - downloads.filter { result.binarySearch(it) >= 0 }.apply { - totalItems = size + downloads.filter { result.binarySearch(it) >= 0 }.also { + totalItems = it.size } } } } Mode.FAVORITE -> { when { - query.isEmpty() -> favorites.toList().apply { - totalItems = size + query.isEmpty() -> favorites.toList().also { + totalItems = it.size } else -> { val result = doSearch(query).sorted() - favorites.filter { result.binarySearch(it) >= 0 }.apply { - totalItems = size + favorites.filter { result.binarySearch(it) >= 0 }.also { + totalItems = it.size } } } @@ -1003,10 +1003,13 @@ class MainActivity : AppCompatActivity() { loadingJob = CoroutineScope(Dispatchers.IO).launch { val galleryIDs = try { - galleryIDs!!.await() + galleryIDs!!.await().also { + if (it.isEmpty()) + throw Exception("No result") + } } catch (e: Exception) { - if (Fabric.isInitialized()) + if (Fabric.isInitialized() && e.message != "No result") Crashlytics.logException(e) withContext(Dispatchers.Main) { diff --git a/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt b/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt index d020205a..181dbc21 100644 --- a/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt +++ b/app/src/main/java/xyz/quaver/pupil/util/download/DownloadWorker.kt @@ -187,14 +187,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont queue.remove(galleryID) worker[galleryID]?.cancel() - clients[galleryID]?.dispatcher()?.queuedCalls() - ?.filter { - @Suppress("UNCHECKED_CAST") - (it.request().tag() as? Pair)?.first == galleryID - } - ?.forEach { - it.cancel() - } + clients[galleryID]?.dispatcher()?.cancelAll() clients.remove(galleryID) progress.remove(galleryID) @@ -283,7 +276,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont for (i in reader.galleryInfo.indices) { val callback = object : Callback { override fun onFailure(call: Call, e: IOException) { - if (Fabric.isInitialized()) + if (Fabric.isInitialized() && e.message != "Canceled") Crashlytics.logException(e) progress[galleryID]?.set(i, Float.NaN)