Эх сурвалжийг харах

always focus new empty poll option in poll create dialog

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
Marcel Hibbe 3 жил өмнө
parent
commit
a8afb61745

+ 6 - 1
app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionViewHolder.kt

@@ -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)
         }

+ 7 - 1
app/src/main/java/com/nextcloud/talk/polls/adapters/PollCreateOptionsAdapter.kt

@@ -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 {