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) { if (poll.getAvailableVoteCount() > 1) {
for (Poll.Entry entry : entries) { for (Poll.Entry entry : entries) {
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.HORIZONTAL);
CheckBox checkBox = new CheckBox(context); CheckBox checkBox = new CheckBox(context);
TextView label = new TextView(context); checkBox.setTextColor(primaryTextColor);
label.setTextColor(primaryTextColor); checkBox.setMovementMethod(LinkMovementMethod.getInstance());
label.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 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 { } else {
//noinspection deprecation //noinspection deprecation
label.setText(Html.fromHtml(entry.getEntryName())); checkBox.setText(Html.fromHtml(entry.getEntryName()));
} }
label.setText(ThmmyParser.html2span(context, entry.getEntryName()));
checkBox.setTextColor(primaryTextColor); checkBox.setTextColor(primaryTextColor);
container.addView(checkBox); holder.optionsLayout.addView(checkBox);
container.addView(label);
holder.optionsLayout.addView(container);
} }
holder.voteChart.setVisibility(View.GONE); holder.voteChart.setVisibility(View.GONE);
holder.optionsLayout.setVisibility(View.VISIBLE); 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) { if (optionsLayout.getChildAt(0) instanceof RadioGroup) {
RadioGroup optionsRadioGroup = (RadioGroup) optionsLayout.getChildAt(0); RadioGroup optionsRadioGroup = (RadioGroup) optionsLayout.getChildAt(0);
votes.add(optionsRadioGroup.getCheckedRadioButtonId()); 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++) { for (int i = 0; i < optionsLayout.getChildCount(); i++) {
LinearLayout container = (LinearLayout) optionsLayout.getChildAt(i); CheckBox checkBox = (CheckBox) optionsLayout.getChildAt(i);
if (((CheckBox) container.getChildAt(0)).isChecked()) if (checkBox.isChecked())
votes.add(i); votes.add(i);
} }
} }

Loading…
Cancel
Save