Removing setting the smart bg in the httppageloader

This relates to #759 and should potentially fix it, but we'll see
This commit is contained in:
Jays2Kings 2021-04-22 21:25:18 -04:00
parent 421f42cd78
commit 85ae4ed2e2
2 changed files with 14 additions and 18 deletions

View File

@ -1,15 +1,12 @@
package eu.kanade.tachiyomi.ui.reader.loader package eu.kanade.tachiyomi.ui.reader.loader
import android.graphics.BitmapFactory
import eu.kanade.tachiyomi.data.cache.ChapterCache import eu.kanade.tachiyomi.data.cache.ChapterCache
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerPageHolder
import eu.kanade.tachiyomi.util.lang.plusAssign import eu.kanade.tachiyomi.util.lang.plusAssign
import eu.kanade.tachiyomi.util.system.ImageUtil
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -240,18 +237,6 @@ class HttpPageLoader(
} }
} }
.doOnNext { .doOnNext {
val readerTheme = preferences.readerTheme().get()
if (readerTheme >= 2) {
val stream = chapterCache.getImageFile(imageUrl).inputStream()
val image = BitmapFactory.decodeStream(stream)
page.bg = ImageUtil.autoSetBackground(
image,
readerTheme == 2,
preferences.context
)
page.bgType = PagerPageHolder.getBGType(readerTheme, preferences.context)
stream.close()
}
page.stream = { chapterCache.getImageFile(imageUrl).inputStream() } page.stream = { chapterCache.getImageFile(imageUrl).inputStream() }
page.status = Page.READY page.status = Page.READY
} }

View File

@ -6,6 +6,7 @@ import android.content.Intent
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Color import android.graphics.Color
import android.graphics.PointF import android.graphics.PointF
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.view.GestureDetector import android.view.GestureDetector
import android.view.Gravity import android.view.Gravity
@ -50,6 +51,7 @@ import rx.Observable
import rx.Subscription import rx.Subscription
import rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers import rx.schedulers.Schedulers
import timber.log.Timber
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.InputStream import java.io.InputStream
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -374,9 +376,18 @@ class PagerPageHolder(
bytesStream.close() bytesStream.close()
launchUI { launchUI {
try {
imageView.background = setBG(bytesArray) imageView.background = setBG(bytesArray)
} catch (e: Exception) {
Timber.e(e.localizedMessage)
imageView.background = ColorDrawable(Color.WHITE)
} finally {
page.bg = imageView.background page.bg = imageView.background
page.bgType = getBGType(viewer.config.readerTheme, context) + item.hashCode() page.bgType = getBGType(
viewer.config.readerTheme,
context
) + item.hashCode()
}
} }
} }
} else { } else {