Replace DefaultTextWatcher with extensions in core-ktx (#3401)
* Replace DefaultTextWatcher with extensions in core-ktx * Fix positiveButton.isEnabled * editable!! for highlightSpans * Fix style * Put noteWatcher back
This commit is contained in:
parent
f1d46766eb
commit
43ea59ab2f
7 changed files with 26 additions and 75 deletions
|
|
@ -16,11 +16,8 @@
|
|||
|
||||
package com.keylesspalace.tusky.util
|
||||
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
|
||||
|
|
@ -36,37 +33,6 @@ fun View.visible(visible: Boolean, or: Int = View.GONE) {
|
|||
this.visibility = if (visible) View.VISIBLE else or
|
||||
}
|
||||
|
||||
open class DefaultTextWatcher : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun EditText.onTextChanged(
|
||||
crossinline callback: (s: CharSequence, start: Int, before: Int, count: Int) -> Unit
|
||||
) {
|
||||
addTextChangedListener(object : DefaultTextWatcher() {
|
||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||
callback(s, start, before, count)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
inline fun EditText.afterTextChanged(
|
||||
crossinline callback: (s: Editable) -> Unit
|
||||
) {
|
||||
addTextChangedListener(object : DefaultTextWatcher() {
|
||||
override fun afterTextChanged(s: Editable) {
|
||||
callback(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce ViewPager2's sensitivity to horizontal swipes.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue