fix: search history not clickable
This commit is contained in:
parent
17a87aa8c8
commit
aa1830f12c
1 changed files with 10 additions and 5 deletions
|
@ -38,12 +38,14 @@ class SearchHistoryAdapter(private val type: String, private val searchClicked:
|
||||||
fun remove(item: String) {
|
fun remove(item: String) {
|
||||||
searchHistory?.remove(item)
|
searchHistory?.remove(item)
|
||||||
PrefManager.setVal(historyType, searchHistory)
|
PrefManager.setVal(historyType, searchHistory)
|
||||||
|
submitList(searchHistory?.toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(item: String) {
|
fun add(item: String) {
|
||||||
if (searchHistory?.contains(item) == true || item.isBlank()) return
|
if (searchHistory?.contains(item) == true || item.isBlank()) return
|
||||||
if (PrefManager.getVal(PrefName.Incognito)) return
|
if (PrefManager.getVal(PrefName.Incognito)) return
|
||||||
searchHistory?.add(item)
|
searchHistory?.add(item)
|
||||||
|
submitList(searchHistory?.toList())
|
||||||
PrefManager.setVal(historyType, searchHistory)
|
PrefManager.setVal(historyType, searchHistory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,14 +62,17 @@ class SearchHistoryAdapter(private val type: String, private val searchClicked:
|
||||||
holder: SearchHistoryAdapter.SearchHistoryViewHolder,
|
holder: SearchHistoryAdapter.SearchHistoryViewHolder,
|
||||||
position: Int
|
position: Int
|
||||||
) {
|
) {
|
||||||
holder.binding.searchHistoryTextView.text = getItem(position)
|
val item = getItem(position)
|
||||||
|
holder.binding.searchHistoryTextView.text = item
|
||||||
holder.binding.closeTextView.setOnClickListener {
|
holder.binding.closeTextView.setOnClickListener {
|
||||||
if (position >= itemCount || position < 0) return@setOnClickListener
|
val currentPosition = holder.bindingAdapterPosition
|
||||||
remove(getItem(position))
|
if (currentPosition >= itemCount || currentPosition < 0) return@setOnClickListener
|
||||||
|
remove(getItem(currentPosition))
|
||||||
}
|
}
|
||||||
holder.binding.searchHistoryTextView.setOnClickListener {
|
holder.binding.searchHistoryTextView.setOnClickListener {
|
||||||
if (position >= itemCount || position < 0) return@setOnClickListener
|
val currentPosition = holder.bindingAdapterPosition
|
||||||
searchClicked(getItem(position))
|
if (currentPosition >= itemCount || currentPosition < 0) return@setOnClickListener
|
||||||
|
searchClicked(getItem(currentPosition))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue