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); holder.errorTooManySelected.setVisibility(View.GONE);
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);
checkBox.setMovementMethod(LinkMovementMethod.getInstance()); TextView label = new TextView(context);
label.setMovementMethod(LinkMovementMethod.getInstance());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 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 { } else {
//noinspection deprecation //noinspection deprecation
checkBox.setText(Html.fromHtml(entry.getEntryName())); label.setText(Html.fromHtml(entry.getEntryName()));
} }
checkBox.setTextColor(context.getResources().getColor(R.color.primary_text)); 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.voteChart.setVisibility(View.GONE);
holder.optionsLayout.setVisibility(View.VISIBLE); holder.optionsLayout.setVisibility(View.VISIBLE);
@ -215,7 +220,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
data.setColor(context.getResources().getColor(R.color.accent)); data.setColor(context.getResources().getColor(R.color.accent));
YAxis yAxisLeft = holder.voteChart.getAxisLeft(); YAxis yAxisLeft = holder.voteChart.getAxisLeft();
yAxisLeft.setGranularity(1f); yAxisLeft.setGranularity(1);
yAxisLeft.setTextColor(context.getResources().getColor(R.color.primary_text)); yAxisLeft.setTextColor(context.getResources().getColor(R.color.primary_text));
yAxisLeft.setAxisMinimum(0); yAxisLeft.setAxisMinimum(0);
YAxis yAxisRight = holder.voteChart.getAxisRight(); 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.setValueFormatter((value, axis) -> Html.fromHtml(entries[(int) value].getEntryName()).toString());
xAxis.setTextColor(context.getResources().getColor(R.color.primary_text)); xAxis.setTextColor(context.getResources().getColor(R.color.primary_text));
xAxis.setGranularity(1f); xAxis.setGranularity(1f);
xAxis.setLabelCount(entries.length, true);
xAxis.setDrawGridLines(false); xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false); xAxis.setDrawAxisLine(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); 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()); votes.add(optionsRadioGroup.getCheckedRadioButtonId());
} else if (optionsLayout.getChildAt(0) instanceof CheckBox) { } else if (optionsLayout.getChildAt(0) instanceof CheckBox) {
for (int i = 0; i < optionsLayout.getChildCount(); i++) { 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); votes.add(i);
} }
} }

Loading…
Cancel
Save