prevent empty hashtag in TabPreferenceActivity (#1160)
This commit is contained in:
parent
51a3e0ea5e
commit
29455d5ccd
|
@ -192,14 +192,19 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene
|
||||||
.create()
|
.create()
|
||||||
|
|
||||||
editText.onTextChanged { s, _, _, _ ->
|
editText.onTextChanged { s, _, _, _ ->
|
||||||
val input = s.trim()
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = validateHashtag(s)
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = input.isNotEmpty() && hashtagRegex.matcher(input).matches()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = validateHashtag(editText.text)
|
||||||
editText.requestFocus()
|
editText.requestFocus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun validateHashtag(input: CharSequence?): Boolean {
|
||||||
|
val trimmedInput = input?.trim() ?: ""
|
||||||
|
return trimmedInput.isNotEmpty() && hashtagRegex.matcher(trimmedInput).matches()
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateAvailableTabs() {
|
private fun updateAvailableTabs() {
|
||||||
val addableTabs: MutableList<TabData> = mutableListOf()
|
val addableTabs: MutableList<TabData> = mutableListOf()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue