mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-13 07:44:11 +01:00
restrict multiselection to maxVotes
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
a4c48b11d6
commit
782d74bfb9
@ -28,6 +28,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.CheckBox
|
import android.widget.CheckBox
|
||||||
import android.widget.RadioButton
|
import android.widget.RadioButton
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import autodagger.AutoInjector
|
import autodagger.AutoInjector
|
||||||
@ -127,7 +128,12 @@ class PollVoteFragment(
|
|||||||
checkBox.isChecked = viewModel.selectedOptions.contains(index) == true
|
checkBox.isChecked = viewModel.selectedOptions.contains(index) == true
|
||||||
checkBox.setOnCheckedChangeListener { buttonView, isChecked ->
|
checkBox.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
viewModel.selectOption(index, false)
|
if (poll.maxVotes == UNLIMITED_VOTES || viewModel.selectedOptions.size < poll.maxVotes) {
|
||||||
|
viewModel.selectOption(index, false)
|
||||||
|
} else {
|
||||||
|
checkBox.isChecked = false
|
||||||
|
Toast.makeText(context, "max votes reached", Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
viewModel.deSelectOption(index)
|
viewModel.deSelectOption(index)
|
||||||
}
|
}
|
||||||
@ -154,5 +160,6 @@ class PollVoteFragment(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = PollVoteFragment::class.java.simpleName
|
private val TAG = PollVoteFragment::class.java.simpleName
|
||||||
|
private const val UNLIMITED_VOTES = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user