From f62bb59a3e3a2d0bc3bf12068c09022624d774a1 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Sun, 7 Oct 2018 13:20:57 +0300 Subject: [PATCH] poll fixes --- .../mthmmy/activities/topic/TopicAdapter.java | 16 +++++++++++----- .../thmmy/mthmmy/viewmodel/TopicViewModel.java | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index bbd8f85d..07b2d111 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -173,16 +173,21 @@ class TopicAdapter extends RecyclerView.Adapter { 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 { 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 { 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); diff --git a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java b/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java index 0e5997e0..34aa4972 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/viewmodel/TopicViewModel.java +++ b/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); } }