Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tom5079 committed Sep 10, 2020
1 parent fd29852 commit 62eb28a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ android {
minSdkVersion 16
targetSdkVersion 30
versionCode 58
versionName "5.0"
versionName "5.0-hotfix1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down
2 changes: 1 addition & 1 deletion app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"filters": [],
"properties": [],
"versionCode": 58,
"versionName": "5.0",
"versionName": "5.0-hotfix1",
"enabled": true,
"outputFile": "app-release.apk"
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/xyz/quaver/pupil/Pupil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

package xyz.quaver.pupil

import android.app.Application
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.*
import android.content.Context
import android.content.Intent
import android.net.Uri
Expand All @@ -43,6 +40,7 @@ import okhttp3.Response
import xyz.quaver.io.FileX
import xyz.quaver.pupil.types.Tag
import xyz.quaver.pupil.util.*
import xyz.quaver.pupil.util.downloader.DownloadManager
import xyz.quaver.setClient
import java.io.File
import java.util.*
Expand Down Expand Up @@ -115,6 +113,8 @@ class Pupil : Application() {
Preferences.remove("download_folder")
}

DownloadManager.getInstance(this).migrate()

histories = SavedSet(File(ContextCompat.getDataDir(this), "histories.json"), 0)
favorites = SavedSet(File(ContextCompat.getDataDir(this), "favorites.json"), 0)
favoriteTags = SavedSet(File(ContextCompat.getDataDir(this), "favorites_tags.json"), Tag.parse(""))
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/xyz/quaver/pupil/adapters/ReaderAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import xyz.quaver.hitomi.getReferer
import xyz.quaver.hitomi.imageUrlFromImage
import xyz.quaver.hiyobi.createImgList
import xyz.quaver.io.util.readBytes
import xyz.quaver.pupil.BuildConfig
import xyz.quaver.pupil.R
import xyz.quaver.pupil.services.DownloadService
import xyz.quaver.pupil.ui.ReaderActivity
Expand Down Expand Up @@ -123,6 +124,10 @@ class ReaderAdapter(private val activity: ReaderActivity,
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(false)
.fitCenter()
.apply {
if (BuildConfig.CENSOR)
override(5, 8)
}
.error(R.drawable.image_broken_variant)
.into(holder.view.image)
}
Expand All @@ -139,6 +144,10 @@ class ReaderAdapter(private val activity: ReaderActivity,
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.fitCenter()
.apply {
if (BuildConfig.CENSOR)
override(5, 8)
}
.error(R.drawable.image_broken_variant)
.listener(object: RequestListener<Drawable> {
override fun onLoadFailed(
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/xyz/quaver/pupil/util/update.kt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
job?.cancel()
job = CoroutineScope(Dispatchers.IO).launch {
val downloadFolders = downloadFolder.listFiles { folder ->
(folder as? FileX)?.isDirectory == true && !downloadFolderMap.values.contains(folder.name)
folder.isDirectory && !downloadFolderMap.values.contains(folder.name)
}?.map {
if (it !is FileX)
FileX(this@migrate, it)
else
it
}

if (downloadFolders.isNullOrEmpty()) return@launch
Expand All @@ -270,8 +275,6 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
notificationManager.notify(R.id.notification_id_import, notification.build())

kotlin.runCatching {
if (folder !is FileX) return@runCatching

val metadata = kotlin.runCatching {
folder.getChild(".metadata").readText()?.let { Json.parseToJsonElement(it).jsonObject }
}.getOrNull()
Expand Down

0 comments on commit 62eb28a

Please sign in to comment.