Browse Source

fix poll checkboxes

pull/61/merge
oogee 6 years ago
parent
commit
24386b121a
  1. 16
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  2. 6
      app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java

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

@ -205,23 +205,17 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (poll.getAvailableVoteCount() > 1) {
for (Poll.Entry entry : entries) {
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.HORIZONTAL);
CheckBox checkBox = new CheckBox(context);
TextView label = new TextView(context);
label.setTextColor(primaryTextColor);
label.setMovementMethod(LinkMovementMethod.getInstance());
checkBox.setTextColor(primaryTextColor);
checkBox.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
label.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY));
checkBox.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY));
} else {
//noinspection deprecation
label.setText(Html.fromHtml(entry.getEntryName()));
checkBox.setText(Html.fromHtml(entry.getEntryName()));
}
label.setText(ThmmyParser.html2span(context, entry.getEntryName()));
checkBox.setTextColor(primaryTextColor);
container.addView(checkBox);
container.addView(label);
holder.optionsLayout.addView(container);
holder.optionsLayout.addView(checkBox);
}
holder.voteChart.setVisibility(View.GONE);
holder.optionsLayout.setVisibility(View.VISIBLE);

6
app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java

@ -144,10 +144,10 @@ 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 LinearLayout) {
} else if (optionsLayout.getChildAt(0) instanceof CheckBox) {
for (int i = 0; i < optionsLayout.getChildCount(); i++) {
LinearLayout container = (LinearLayout) optionsLayout.getChildAt(i);
if (((CheckBox) container.getChildAt(0)).isChecked())
CheckBox checkBox = (CheckBox) optionsLayout.getChildAt(i);
if (checkBox.isChecked())
votes.add(i);
}
}

Loading…
Cancel
Save