kopia lustrzana https://github.com/TeamNewPipe/NewPipe
Use TextView.doOnTextChanged() extension.
rodzic
293e2ff5e3
commit
03d99887c5
|
@ -3,9 +3,7 @@ package org.schabi.newpipe.local.subscription.dialog
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.text.Editable
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.text.TextWatcher
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -15,6 +13,7 @@ import androidx.core.content.getSystemService
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.widget.doOnTextChanged
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
@ -194,16 +193,11 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||||
}
|
}
|
||||||
|
|
||||||
group_name_input_container.error = null
|
group_name_input_container.error = null
|
||||||
group_name_input.addTextChangedListener(object : TextWatcher {
|
group_name_input.doOnTextChanged { text, _, _, _ ->
|
||||||
override fun afterTextChanged(s: Editable?) {}
|
if (group_name_input_container.isErrorEnabled && !text.isNullOrBlank()) {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
group_name_input_container.error = null
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
|
||||||
if (group_name_input_container.isErrorEnabled && !s.isNullOrBlank()) {
|
|
||||||
group_name_input_container.error = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
confirm_button.setOnClickListener { handlePositiveButton() }
|
confirm_button.setOnClickListener { handlePositiveButton() }
|
||||||
|
|
||||||
|
@ -245,15 +239,11 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar_search_edit_text.addTextChangedListener(object : TextWatcher {
|
toolbar_search_edit_text.doOnTextChanged { _, _, _, _ ->
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) = Unit
|
val newQuery: String = toolbar_search_edit_text.text.toString()
|
||||||
override fun afterTextChanged(s: Editable) = Unit
|
subscriptionsCurrentSearchQuery = newQuery
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
viewModel.filterSubscriptionsBy(newQuery)
|
||||||
val newQuery: String = toolbar_search_edit_text.text.toString()
|
}
|
||||||
subscriptionsCurrentSearchQuery = newQuery
|
|
||||||
viewModel.filterSubscriptionsBy(newQuery)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
subscriptionGroupAdapter.setOnItemClickListener(subscriptionPickerItemListener)
|
subscriptionGroupAdapter.setOnItemClickListener(subscriptionPickerItemListener)
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue