Use file hash for cover search
This commit is contained in:
1 parent
24431051ae
commit
c33248b1bf
2 files changed
+11
-15
No files matched your search
@@ -39,7 +39,7 @@ data class ListUrlBuilder(
|
||||
private var mJumpTo: String? = null,
|
||||
var category: Int = EhUtils.NONE,
|
||||
private var mKeyword: String? = null,
|
||||
private var mSHash: String? = null,
|
||||
var hash: String? = null,
|
||||
var advanceSearch: Int = -1,
|
||||
var minRating: Int = -1,
|
||||
var pageFrom: Int = -1,
|
||||
@@ -63,7 +63,7 @@ data class ListUrlBuilder(
|
||||
imagePath = null
|
||||
isUseSimilarityScan = false
|
||||
isOnlySearchCovers = false
|
||||
mSHash = null
|
||||
hash = null
|
||||
}
|
||||
|
||||
fun setIndex(index: String?, isNext: Boolean = true) {
|
||||
@@ -246,7 +246,7 @@ data class ListUrlBuilder(
|
||||
|
||||
"f_spf" -> pageFrom = NumberUtils.parseIntSafely(value, -1)
|
||||
"f_spt" -> pageTo = NumberUtils.parseIntSafely(value, -1)
|
||||
"f_shash" -> mSHash = value
|
||||
"f_shash" -> hash = value
|
||||
}
|
||||
}
|
||||
this.category = category
|
||||
@@ -282,7 +282,7 @@ data class ListUrlBuilder(
|
||||
if (this.category != EhUtils.NONE) {
|
||||
ub.addQuery("f_cats", category.inv() and EhUtils.ALL_CATEGORY)
|
||||
}
|
||||
mSHash?.let {
|
||||
hash?.let {
|
||||
ub.addQuery("f_shash", it)
|
||||
}
|
||||
mJumpTo?.let {
|
||||
@@ -296,10 +296,12 @@ data class ListUrlBuilder(
|
||||
}
|
||||
// Search key
|
||||
// the settings of ub:UrlBuilder may be overwritten by following Advance search
|
||||
StringUtils.split(mKeyword, '|')?.forEachIndexed { idx, keyword ->
|
||||
val keyword = keyword.trim { it <= ' ' }
|
||||
StringUtils.split(mKeyword, '|')?.forEachIndexed { idx, kwd ->
|
||||
val keyword = kwd.trim { it <= ' ' }
|
||||
when (idx) {
|
||||
0 -> keyword.takeIf { it.isNotEmpty() }?.let { ub.addQuery("f_search", encodeUTF8(it)) }
|
||||
0 -> keyword.takeIf { it.isNotEmpty() }
|
||||
?.let { ub.addQuery("f_search", encodeUTF8(it)) }
|
||||
|
||||
else -> keyword.indexOf(':').takeIf { it >= 0 }?.run {
|
||||
val key = keyword.substring(0, this).trim { it <= ' ' }
|
||||
val value = keyword.substring(this + 1).trim { it <= ' ' }
|
||||
|
||||
@@ -107,11 +107,9 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import arrow.core.partially1
|
||||
import coil.annotation.ExperimentalCoilApi
|
||||
import coil.imageLoader
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.hippo.ehviewer.EhApplication.Companion.galleryDetailCache
|
||||
import com.hippo.ehviewer.EhApplication.Companion.imageCache
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
@@ -135,7 +133,6 @@ import com.hippo.ehviewer.client.parser.ParserUtils
|
||||
import com.hippo.ehviewer.client.parser.TorrentResult
|
||||
import com.hippo.ehviewer.coil.imageRequest
|
||||
import com.hippo.ehviewer.coil.justDownload
|
||||
import com.hippo.ehviewer.coil.read
|
||||
import com.hippo.ehviewer.dao.DownloadInfo
|
||||
import com.hippo.ehviewer.dao.Filter
|
||||
import com.hippo.ehviewer.databinding.DialogArchiveListBinding
|
||||
@@ -1167,7 +1164,6 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoilApi::class)
|
||||
private fun showCoverGalleryList() {
|
||||
context ?: return
|
||||
val gid = gid
|
||||
@@ -1176,11 +1172,9 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
try {
|
||||
val key = composeBindingGI!!.thumbKey!!
|
||||
val path = imageCache.read(key) { data }
|
||||
val lub = ListUrlBuilder()
|
||||
lub.mode = ListUrlBuilder.MODE_IMAGE_SEARCH
|
||||
lub.imagePath = path.toString()
|
||||
lub.isUseSimilarityScan = true
|
||||
lub.mode = ListUrlBuilder.MODE_NORMAL
|
||||
lub.hash = key.substringAfterLast('/').substringBefore('-')
|
||||
navigate(R.id.galleryListScene, lub.toStartArgs(), true)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
|
||||
Reference in new issue
Block a user