fix poll validation (#1459)
This commit is contained in:
parent
b703097d17
commit
44163d8720
2 changed files with 4 additions and 3 deletions
|
@ -30,7 +30,7 @@ import com.keylesspalace.tusky.util.visible
|
||||||
class AddPollOptionsAdapter(
|
class AddPollOptionsAdapter(
|
||||||
private var options: MutableList<String>,
|
private var options: MutableList<String>,
|
||||||
private val maxOptionLength: Int,
|
private val maxOptionLength: Int,
|
||||||
private val onOptionRemoved: () -> Unit,
|
private val onOptionRemoved: (Boolean) -> Unit,
|
||||||
private val onOptionChanged: (Boolean) -> Unit
|
private val onOptionChanged: (Boolean) -> Unit
|
||||||
): RecyclerView.Adapter<ViewHolder>() {
|
): RecyclerView.Adapter<ViewHolder>() {
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class AddPollOptionsAdapter(
|
||||||
holder.editText.clearFocus()
|
holder.editText.clearFocus()
|
||||||
options.removeAt(holder.adapterPosition)
|
options.removeAt(holder.adapterPosition)
|
||||||
notifyItemRemoved(holder.adapterPosition)
|
notifyItemRemoved(holder.adapterPosition)
|
||||||
onOptionRemoved()
|
onOptionRemoved(validateInput())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,9 @@ fun showAddPollDialog(
|
||||||
val adapter = AddPollOptionsAdapter(
|
val adapter = AddPollOptionsAdapter(
|
||||||
options = poll?.options?.toMutableList() ?: mutableListOf("", ""),
|
options = poll?.options?.toMutableList() ?: mutableListOf("", ""),
|
||||||
maxOptionLength = maxOptionLength ?: DEFAULT_MAX_OPTION_LENGTH,
|
maxOptionLength = maxOptionLength ?: DEFAULT_MAX_OPTION_LENGTH,
|
||||||
onOptionRemoved = {
|
onOptionRemoved = { valid ->
|
||||||
view.addChoiceButton.isEnabled = true
|
view.addChoiceButton.isEnabled = true
|
||||||
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = valid
|
||||||
},
|
},
|
||||||
onOptionChanged = { valid ->
|
onOptionChanged = { valid ->
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = valid
|
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = valid
|
||||||
|
|
Loading…
Reference in a new issue