Browse Source

poll fixes

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

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

@ -173,16 +173,21 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.errorTooManySelected.setVisibility(View.GONE);
if (poll.getAvailableVoteCount() > 1) {
for (Poll.Entry entry : entries) {
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.HORIZONTAL);
CheckBox checkBox = new CheckBox(context);
checkBox.setMovementMethod(LinkMovementMethod.getInstance());
TextView label = new TextView(context);
label.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
checkBox.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY));
label.setText(Html.fromHtml(entry.getEntryName(), Html.FROM_HTML_MODE_LEGACY));
} else {
//noinspection deprecation
checkBox.setText(Html.fromHtml(entry.getEntryName()));
label.setText(Html.fromHtml(entry.getEntryName()));
}
checkBox.setTextColor(context.getResources().getColor(R.color.primary_text));
holder.optionsLayout.addView(checkBox);
container.addView(checkBox);
container.addView(label);
holder.optionsLayout.addView(container);
}
holder.voteChart.setVisibility(View.GONE);
holder.optionsLayout.setVisibility(View.VISIBLE);
@ -215,7 +220,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
data.setColor(context.getResources().getColor(R.color.accent));
YAxis yAxisLeft = holder.voteChart.getAxisLeft();
yAxisLeft.setGranularity(1f);
yAxisLeft.setGranularity(1);
yAxisLeft.setTextColor(context.getResources().getColor(R.color.primary_text));
yAxisLeft.setAxisMinimum(0);
YAxis yAxisRight = holder.voteChart.getAxisRight();
@ -225,6 +230,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
xAxis.setValueFormatter((value, axis) -> Html.fromHtml(entries[(int) value].getEntryName()).toString());
xAxis.setTextColor(context.getResources().getColor(R.color.primary_text));
xAxis.setGranularity(1f);
xAxis.setLabelCount(entries.length, true);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);

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

@ -146,7 +146,8 @@ public class TopicViewModel extends BaseViewModel implements TopicTask.OnTopicTa
votes.add(optionsRadioGroup.getCheckedRadioButtonId());
} else if (optionsLayout.getChildAt(0) instanceof CheckBox) {
for (int i = 0; i < optionsLayout.getChildCount(); i++) {
if (((CheckBox) optionsLayout.getChildAt(i)).isChecked())
LinearLayout container = (LinearLayout) optionsLayout.getChildAt(i);
if (((CheckBox) container.getChildAt(0)).isChecked())
votes.add(i);
}
}

Loading…
Cancel
Save