mirror of
https://github.com/melihaksoy/Android-Kotlin-Modulerized-CleanArchitecture.git
synced 2026-03-24 10:21:44 +01:00
Test
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
package com.melih.core.extensions
|
||||
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import com.melih.core.utils.ClearFocusQueryTextListener
|
||||
|
||||
/**
|
||||
* Shorthand for [contains] with ignoreCase set [true]
|
||||
*/
|
||||
fun CharSequence.containsIgnoreCase(other: CharSequence) = contains(other, true)
|
||||
|
||||
fun SearchView.setOnQueryChangedListener(block: (String?) -> Unit) = setOnQueryTextListener(ClearFocusQueryTextListener(this, block))
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.melih.core.utils
|
||||
|
||||
import androidx.appcompat.widget.SearchView
|
||||
|
||||
|
||||
/**
|
||||
* Simplifying [OnQueryTextListener][android.widget.SearchView.OnQueryTextListener]
|
||||
*/
|
||||
class ClearFocusQueryTextListener(
|
||||
private val view: SearchView,
|
||||
private val onQueryChangeBlock: (String?) -> Unit
|
||||
) : SearchView.OnQueryTextListener {
|
||||
|
||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||
view.clearFocus()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onQueryTextChange(newText: String?): Boolean {
|
||||
onQueryChangeBlock(newText)
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user