Browse Source

fix error when selecting too many vote options

pull/61/merge
Thodoris1999 6 years ago
parent
commit
0ff66afda7
  1. 3
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  2. 4
      app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java

3
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -263,7 +263,8 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
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);
}
});

4
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())

Loading…
Cancel
Save