From 0ff66afda738991571265788adcb62536b94613b Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Sun, 7 Oct 2018 17:47:16 +0300 Subject: [PATCH] fix error when selecting too many vote options --- .../java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java | 3 ++- .../main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 07b2d111..18cab71c 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -263,7 +263,8 @@ class TopicAdapter extends RecyclerView.Adapter { holder.submitButton.setOnClickListener(v -> { if (!viewModel.submitVote(holder.optionsLayout)) { holder.errorTooManySelected.setText(context.getResources() - .getQuantityText(R.plurals.error_too_many_checked, poll.getAvailableVoteCount())); + .getQuantityString(R.plurals.error_too_many_checked, poll.getAvailableVoteCount(), + poll.getAvailableVoteCount())); holder.errorTooManySelected.setVisibility(View.VISIBLE); } }); diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index 34aa4972..ec875274 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java @@ -10,6 +10,8 @@ import android.widget.LinearLayout; import android.widget.RadioGroup; import java.util.ArrayList; +import java.util.Arrays; +import java.util.TimerTask; import gr.thmmy.mthmmy.activities.settings.SettingsActivity; import gr.thmmy.mthmmy.activities.topic.tasks.EditTask; @@ -144,7 +146,7 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa if (optionsLayout.getChildAt(0) instanceof RadioGroup) { RadioGroup optionsRadioGroup = (RadioGroup) optionsLayout.getChildAt(0); votes.add(optionsRadioGroup.getCheckedRadioButtonId()); - } else if (optionsLayout.getChildAt(0) instanceof CheckBox) { + } else if (optionsLayout.getChildAt(0) instanceof LinearLayout) { for (int i = 0; i < optionsLayout.getChildCount(); i++) { LinearLayout container = (LinearLayout) optionsLayout.getChildAt(i); if (((CheckBox) container.getChildAt(0)).isChecked())