Prevent OOM when cache is disabled

This commit is contained in:
tom5079
2020-06-21 23:03:10 +09:00
parent 9f363d8900
commit 1edb95f0c5
7 changed files with 12 additions and 47 deletions

View File

@@ -27,6 +27,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.RequestManager
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.model.LazyHeaders
import com.google.android.material.snackbar.Snackbar
import com.google.firebase.crashlytics.FirebaseCrashlytics
import kotlinx.android.synthetic.main.activity_reader.view.*
@@ -102,23 +103,19 @@ class ReaderAdapter(private val glide: RequestManager,
val lowQuality = preferences.getBoolean("low_quality", false)
val url = when (reader!!.code) {
Code.HITOMI -> {
Code.HITOMI ->
GlideUrl(
imageUrlFromImage(
galleryID,
reader!!.galleryInfo.files[position],
!lowQuality
)
).apply {
headers["Referer"] = getReferer(galleryID)
}
}
Code.HIYOBI -> {
GlideUrl(createImgList(galleryID, reader!!, lowQuality)[position].path).apply {
headers["User-Agent"] = user_agent
headers["Cookie"] = cookie
}
}
, LazyHeaders.Builder().addHeader("Referer", getReferer(galleryID)).build())
Code.HIYOBI ->
GlideUrl(createImgList(galleryID, reader!!, lowQuality)[position].path, LazyHeaders.Builder()
.addHeader("User-Agent", user_agent)
.addHeader("Cookie", cookie)
.build())
else -> null
}
holder.view.image.post {

View File

@@ -144,30 +144,6 @@ class MainActivity : AppCompatActivity() {
preference.edit().putBoolean("https_block_alert", true).apply()
}
if (!preference.getBoolean("apcjsa_option", false)) {
android.app.AlertDialog.Builder(this).apply {
setTitle(R.string.apcjsa_option_title)
setMessage(R.string.apcjsa_option_message)
setPositiveButton(android.R.string.yes) { _, _ ->
val tags = Tags.parse(
preference.getString("default_query", "") ?: ""
)
tags.add("-female:loli")
tags.add("-male:shota")
preference.edit()
.putString("default_query", tags.toString())
.putBoolean("cache_disable", true)
.putBoolean("apcjsa_option", true)
.apply()
}
setNegativeButton(android.R.string.no) { _, _ -> }
}.show()
preference.edit().putBoolean("apcjsa_option", true).apply()
}
}
with(application as Pupil) {