mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
a78ad09034
commit
b5670d8339
@ -99,7 +99,7 @@ class ReadBookActivity : BaseReadBookActivity(),
|
|||||||
private val searchContentActivity = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
private val searchContentActivity = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
it ?: return@registerForActivityResult
|
it ?: return@registerForActivityResult
|
||||||
it.data?.let { data ->
|
it.data?.let { data ->
|
||||||
data.getIntExtra("chapterIndex", ReadBook.durChapterIndex).let { _ ->
|
data.getIntExtra("chapterIndex", ReadBook.durChapterIndex).let {
|
||||||
viewModel.searchContentQuery = data.getStringExtra("query") ?: ""
|
viewModel.searchContentQuery = data.getStringExtra("query") ?: ""
|
||||||
val searchResultIndex = data.getIntExtra("searchResultIndex", 0)
|
val searchResultIndex = data.getIntExtra("searchResultIndex", 0)
|
||||||
isShowingSearchResult = true
|
isShowingSearchResult = true
|
||||||
|
@ -29,12 +29,15 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
private val callBack: CallBack get() = activity as CallBack
|
private val callBack: CallBack get() = activity as CallBack
|
||||||
private val binding = ViewSearchMenuBinding.inflate(LayoutInflater.from(context), this, true)
|
private val binding = ViewSearchMenuBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
|
|
||||||
private val menuBottomIn: Animation = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in)
|
private val menuBottomIn: Animation =
|
||||||
private val menuBottomOut: Animation = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in)
|
||||||
|
private val menuBottomOut: Animation =
|
||||||
|
AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
||||||
private val bgColor: Int = context.bottomBackground
|
private val bgColor: Int = context.bottomBackground
|
||||||
private val textColor: Int = context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor))
|
private val textColor: Int = context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor))
|
||||||
private val bottomBackgroundList: ColorStateList =
|
private val bottomBackgroundList: ColorStateList =
|
||||||
Selector.colorBuild().setDefaultColor(bgColor).setPressedColor(ColorUtils.darkenColor(bgColor)).create()
|
Selector.colorBuild().setDefaultColor(bgColor)
|
||||||
|
.setPressedColor(ColorUtils.darkenColor(bgColor)).create()
|
||||||
private var onMenuOutEnd: (() -> Unit)? = null
|
private var onMenuOutEnd: (() -> Unit)? = null
|
||||||
|
|
||||||
private val searchResultList: MutableList<SearchResult> = mutableListOf()
|
private val searchResultList: MutableList<SearchResult> = mutableListOf()
|
||||||
@ -104,9 +107,11 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
fun updateSearchInfo() {
|
fun updateSearchInfo() {
|
||||||
ReadBook.curTextChapter?.let {
|
ReadBook.curTextChapter?.let {
|
||||||
binding.tvCurrentSearchInfo.text = context.getString(R.string.search_content_size) + ": ${searchResultList.size} / 当前章节: ${it.title}"
|
binding.tvCurrentSearchInfo.text =
|
||||||
|
"""${context.getString(R.string.search_content_size)}: ${searchResultList.size} / 当前章节: ${it.title}"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,13 +148,6 @@ class SearchMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置
|
|
||||||
// llSetting.setOnClickListener {
|
|
||||||
// runMenuOut {
|
|
||||||
// callBack.showSearchSetting()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
fabLeft.setOnClickListener {
|
fabLeft.setOnClickListener {
|
||||||
updateSearchResultIndex(currentSearchResultIndex - 1)
|
updateSearchResultIndex(currentSearchResultIndex - 1)
|
||||||
callBack.navigateToSearch(searchResultList[currentSearchResultIndex])
|
callBack.navigateToSearch(searchResultList[currentSearchResultIndex])
|
||||||
|
@ -14,7 +14,6 @@ import io.legado.app.utils.hexString
|
|||||||
class SearchContentAdapter(context: Context, val callback: Callback) :
|
class SearchContentAdapter(context: Context, val callback: Callback) :
|
||||||
RecyclerAdapter<SearchResult, ItemSearchListBinding>(context) {
|
RecyclerAdapter<SearchResult, ItemSearchListBinding>(context) {
|
||||||
|
|
||||||
val cacheFileNames = hashSetOf<String>()
|
|
||||||
val textColor = context.getCompatColor(R.color.primaryText).hexString.substring(2)
|
val textColor = context.getCompatColor(R.color.primaryText).hexString.substring(2)
|
||||||
val accentColor = context.accentColor.hexString.substring(2)
|
val accentColor = context.accentColor.hexString.substring(2)
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ class SearchContentViewModel(application: Application) : BaseViewModel(applicati
|
|||||||
var searchResultCounts = 0
|
var searchResultCounts = 0
|
||||||
val cacheChapterNames = hashSetOf<String>()
|
val cacheChapterNames = hashSetOf<String>()
|
||||||
val searchResultList: MutableList<SearchResult> = mutableListOf()
|
val searchResultList: MutableList<SearchResult> = mutableListOf()
|
||||||
var selectedIndex = 0
|
|
||||||
|
|
||||||
fun initBook(bookUrl: String, success: () -> Unit) {
|
fun initBook(bookUrl: String, success: () -> Unit) {
|
||||||
this.bookUrl = bookUrl
|
this.bookUrl = bookUrl
|
||||||
|
Loading…
Reference in New Issue
Block a user