always focus new empty poll option in poll create dialog

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-07-14 15:19:37 +02:00 committed by Andy Scherzinger (Rebase PR Action)
parent 40f20c56d6
commit a8afb61745
2 changed files with 13 additions and 2 deletions

View file

@ -38,7 +38,8 @@ class PollCreateOptionViewHolder(
fun bind(
pollCreateOptionItem: PollCreateOptionItem,
itemsListener: PollCreateOptionsItemListener,
position: Int
position: Int,
focus: Boolean
) {
textListener?.let {
@ -47,6 +48,10 @@ class PollCreateOptionViewHolder(
binding.pollOptionText.setText(pollCreateOptionItem.pollOption)
if (focus) {
binding.pollOptionText.requestFocus()
}
binding.pollOptionDelete.setOnClickListener {
itemsListener.onRemoveOptionsItemClick(pollCreateOptionItem, position)
}

View file

@ -39,7 +39,13 @@ class PollCreateOptionsAdapter(
override fun onBindViewHolder(holder: PollCreateOptionViewHolder, position: Int) {
val currentItem = list[position]
holder.bind(currentItem, clickListener, position)
var focus = false
if (list.size - 1 == position && currentItem.pollOption.isBlank()) {
focus = true
}
holder.bind(currentItem, clickListener, position, focus)
}
override fun getItemCount(): Int {