Allow preload thumbs aggressively
This commit is contained in:
1 parent
946e76c3cc
commit
6d8208d7f4
7 files changed
+60
-2
No files matched your search
@@ -204,6 +204,8 @@ object Settings {
|
||||
private const val KEY_ARCHIVE_PASSWDS = "archive_passwds"
|
||||
private const val KEY_QS_SAVE_PROGRESS = "qs_save_progress"
|
||||
private const val DEFAULT_QS_SAVE_PROGRESS = true
|
||||
private const val KEY_PRELOAD_THUMB_AGGRESIVELY = "preload_thumb_aggressively"
|
||||
private const val DEFAULT_PRELOAD_THUMB_AGGRESIVELY = false
|
||||
var LIST_THUMB_SIZE_INITED = false
|
||||
private lateinit var sSettingsPre: SharedPreferences
|
||||
private var LIST_THUMB_SIZE = 40
|
||||
@@ -644,4 +646,7 @@ object Settings {
|
||||
fun putNotificationRequired() {
|
||||
putBoolean(KEY_NOTIFICATION_REQUIRED, true)
|
||||
}
|
||||
|
||||
val preloadThumbAggressively: Boolean
|
||||
get() = getBoolean(KEY_PRELOAD_THUMB_AGGRESIVELY, DEFAULT_PRELOAD_THUMB_AGGRESIVELY)
|
||||
}
|
||||
@@ -107,6 +107,8 @@ import androidx.navigation.fragment.findNavController
|
||||
import arrow.core.partially1
|
||||
import coil.Coil.imageLoader
|
||||
import coil.annotation.ExperimentalCoilApi
|
||||
import coil.imageLoader
|
||||
import coil.request.ImageRequest
|
||||
import com.google.accompanist.themeadapter.material3.Mdc3Theme
|
||||
import com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -141,6 +143,7 @@ import com.hippo.ehviewer.client.parser.ParserUtils
|
||||
import com.hippo.ehviewer.client.parser.RateGalleryParser
|
||||
import com.hippo.ehviewer.client.parser.TorrentParser
|
||||
import com.hippo.ehviewer.client.parser.VoteTagParser
|
||||
import com.hippo.ehviewer.coil.ehUrl
|
||||
import com.hippo.ehviewer.dao.DownloadInfo
|
||||
import com.hippo.ehviewer.dao.Filter
|
||||
import com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener
|
||||
@@ -835,6 +838,17 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}.onSuccess {
|
||||
galleryDetailCache.put(it.gid, it)
|
||||
EhDB.putHistoryInfo(it)
|
||||
if (Settings.preloadThumbAggressively) {
|
||||
lifecycleScope.launchIO {
|
||||
it.previewList.forEach {
|
||||
it.imageUrl.run {
|
||||
context?.imageLoader?.enqueue(
|
||||
ImageRequest.Builder(requireContext()).ehUrl(this).build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
composeBindingGD = it
|
||||
composeBindingGI = it
|
||||
updateDownloadState()
|
||||
|
||||
@@ -49,6 +49,8 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.imageLoader
|
||||
import coil.request.ImageRequest
|
||||
import com.google.android.material.datepicker.CalendarConstraints
|
||||
import com.google.android.material.datepicker.CalendarConstraints.DateValidator
|
||||
import com.google.android.material.datepicker.CompositeDateValidator
|
||||
@@ -61,7 +63,6 @@ import com.hippo.app.EditTextDialogBuilder
|
||||
import com.hippo.drawable.AddDeleteDrawable
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView
|
||||
import com.hippo.easyrecyclerview.FastScroller.OnDragHandlerListener
|
||||
import com.hippo.ehviewer.download.DownloadManager as downloadManager
|
||||
import com.hippo.ehviewer.EhApplication.Companion.favouriteStatusRouter
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.FavouriteStatusRouter
|
||||
@@ -82,6 +83,7 @@ import com.hippo.ehviewer.client.exception.EhException
|
||||
import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser
|
||||
import com.hippo.ehviewer.client.parser.GalleryListParser
|
||||
import com.hippo.ehviewer.client.parser.GalleryPageUrlParser
|
||||
import com.hippo.ehviewer.coil.ehUrl
|
||||
import com.hippo.ehviewer.dao.DownloadInfo
|
||||
import com.hippo.ehviewer.dao.QuickSearch
|
||||
import com.hippo.ehviewer.databinding.DrawerListRvBinding
|
||||
@@ -113,6 +115,7 @@ import java.io.File
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZoneOffset
|
||||
import com.hippo.ehviewer.download.DownloadManager as downloadManager
|
||||
|
||||
class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.Helper,
|
||||
OnClickFabListener, OnExpandListener {
|
||||
@@ -1035,6 +1038,17 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
}
|
||||
|
||||
private fun onGetGalleryListSuccess(result: GalleryListParser.Result, taskId: Int) {
|
||||
if (Settings.preloadThumbAggressively) {
|
||||
lifecycleScope.launchIO {
|
||||
result.galleryInfoList.forEach {
|
||||
it.thumb?.run {
|
||||
context?.imageLoader?.enqueue(
|
||||
ImageRequest.Builder(requireContext()).ehUrl(this).build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mHelper != null && mHelper!!.isCurrentTask(taskId)) {
|
||||
val emptyString =
|
||||
getString(if (mUrlBuilder.mode == MODE_SUBSCRIPTION && result.noWatchedTags) R.string.gallery_list_empty_hit_subscription else R.string.gallery_list_empty_hit)
|
||||
@@ -1113,7 +1127,8 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
|
||||
override fun onCancel() {}
|
||||
}
|
||||
|
||||
private class QsDrawerHolder(val binding: ItemDrawerListBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
private class QsDrawerHolder(val binding: ItemDrawerListBinding) :
|
||||
RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
private inner class MoveDialogHelper(
|
||||
private val mLabels: Array<String>,
|
||||
|
||||
@@ -21,6 +21,9 @@ import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import coil.imageLoader
|
||||
import coil.request.ImageRequest
|
||||
import com.hippo.app.BaseDialogBuilder
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration
|
||||
import com.hippo.ehviewer.R
|
||||
@@ -31,6 +34,7 @@ import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail
|
||||
import com.hippo.ehviewer.client.data.GalleryPreview
|
||||
import com.hippo.ehviewer.client.exception.EhException
|
||||
import com.hippo.ehviewer.coil.ehUrl
|
||||
import com.hippo.ehviewer.databinding.DialogGoToBinding
|
||||
import com.hippo.ehviewer.databinding.SceneGalleryPreviewsBinding
|
||||
import com.hippo.util.getParcelableCompat
|
||||
@@ -38,6 +42,7 @@ import com.hippo.widget.ContentLayout.ContentHelper
|
||||
import com.hippo.widget.recyclerview.AutoGridLayoutManager
|
||||
import com.hippo.widget.recyclerview.STRATEGY_SUITABLE_SIZE
|
||||
import com.hippo.yorozuya.LayoutUtils
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import java.util.Locale
|
||||
|
||||
class GalleryPreviewsScene : BaseToolbarScene() {
|
||||
@@ -162,6 +167,17 @@ class GalleryPreviewsScene : BaseToolbarScene() {
|
||||
|
||||
private fun onGetPreviewListSuccess(result: Pair<List<GalleryPreview>, Int>, taskId: Int) {
|
||||
if (null != mHelper && mHelper!!.isCurrentTask(taskId) && null != mGalleryDetail) {
|
||||
if (Settings.preloadThumbAggressively) {
|
||||
lifecycleScope.launchIO {
|
||||
result.first.forEach {
|
||||
it.imageUrl.run {
|
||||
context?.imageLoader?.enqueue(
|
||||
ImageRequest.Builder(requireContext()).ehUrl(this).build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mHelper!!.onGetPageData(taskId, result.second, 0, null, null, result.first)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,6 +538,7 @@
|
||||
<string name="passwd_cannot_be_empty">密码不能为空</string>
|
||||
<string name="list_tile_thumb_size">详情模式下缩略图大小</string>
|
||||
<string name="account_name">账户</string>
|
||||
<string name="preload_thumb_aggressively">激进地预载缩略图</string>
|
||||
<!-- Tachiyomi Reader Start-->
|
||||
<string name="action_settings">设置</string>
|
||||
<string name="action_retry">重试</string>
|
||||
|
||||
@@ -601,6 +601,7 @@
|
||||
<string name="passwd_cannot_be_empty">Password can\'t be empty</string>
|
||||
<string name="list_tile_thumb_size">Thumb size in thumb mode</string>
|
||||
<string name="account_name">Account</string>
|
||||
<string name="preload_thumb_aggressively">Preload thumbs aggressively</string>
|
||||
<!-- Tachiyomi Reader Start-->
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="pref_rotation_type">Default rotation type</string>
|
||||
|
||||
@@ -87,6 +87,12 @@
|
||||
android:title="@string/settings_advanced_bypass_vpn_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<rikka.material.preference.MaterialSwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="preload_thumb_aggressively"
|
||||
android:title="@string/preload_thumb_aggressively"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<Preference
|
||||
android:key="export_data"
|
||||
android:summary="@string/settings_advanced_export_data_summary"
|
||||
|
||||
Reference in new issue
Block a user