|
@ -185,6 +185,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
if (!pollSupported) { |
|
|
if (!pollSupported) { |
|
|
holder.optionsLayout.setVisibility(View.GONE); |
|
|
holder.optionsLayout.setVisibility(View.GONE); |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
|
|
|
holder.selectedEntry.setVisibility(View.GONE); |
|
|
holder.removeVotesButton.setVisibility(View.GONE); |
|
|
holder.removeVotesButton.setVisibility(View.GONE); |
|
|
holder.showPollResultsButton.setVisibility(View.GONE); |
|
|
holder.showPollResultsButton.setVisibility(View.GONE); |
|
|
holder.hidePollResultsButton.setVisibility(View.GONE); |
|
|
holder.hidePollResultsButton.setVisibility(View.GONE); |
|
@ -222,6 +223,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
holder.optionsLayout.addView(checkBox); |
|
|
holder.optionsLayout.addView(checkBox); |
|
|
} |
|
|
} |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
|
|
|
holder.selectedEntry.setVisibility(View.GONE); |
|
|
holder.optionsLayout.setVisibility(View.VISIBLE); |
|
|
holder.optionsLayout.setVisibility(View.VISIBLE); |
|
|
} else if (poll.getAvailableVoteCount() == 1) { |
|
|
} else if (poll.getAvailableVoteCount() == 1) { |
|
|
// vote single option
|
|
|
// vote single option
|
|
@ -242,8 +244,9 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
} |
|
|
} |
|
|
holder.optionsLayout.addView(radioGroup); |
|
|
holder.optionsLayout.addView(radioGroup); |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
|
|
|
holder.selectedEntry.setVisibility(View.GONE); |
|
|
holder.optionsLayout.setVisibility(View.VISIBLE); |
|
|
holder.optionsLayout.setVisibility(View.VISIBLE); |
|
|
} else if (poll.getSelectedEntryIndex() != -1) { |
|
|
} else if (poll.isPollResultsHidden()) { |
|
|
// vote already submitted but results are hidden
|
|
|
// vote already submitted but results are hidden
|
|
|
Poll.Entry[] entries1 = poll.getEntries(); |
|
|
Poll.Entry[] entries1 = poll.getEntries(); |
|
|
for (int i = 0; i < entries1.length; i++) { |
|
|
for (int i = 0; i < entries1.length; i++) { |
|
@ -267,6 +270,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
holder.optionsLayout.addView(textView); |
|
|
holder.optionsLayout.addView(textView); |
|
|
} |
|
|
} |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
holder.voteChart.setVisibility(View.GONE); |
|
|
|
|
|
holder.selectedEntry.setVisibility(View.GONE); |
|
|
holder.optionsLayout.setVisibility(View.VISIBLE); |
|
|
holder.optionsLayout.setVisibility(View.VISIBLE); |
|
|
} else { |
|
|
} else { |
|
|
// Showing results
|
|
|
// Showing results
|
|
@ -316,6 +320,12 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
holder.voteChart.setMinimumHeight((int) (chartHeightDp * (metrics.densityDpi / 160f))); |
|
|
holder.voteChart.setMinimumHeight((int) (chartHeightDp * (metrics.densityDpi / 160f))); |
|
|
holder.voteChart.invalidate(); |
|
|
holder.voteChart.invalidate(); |
|
|
holder.voteChart.setVisibility(View.VISIBLE); |
|
|
holder.voteChart.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
|
|
|
|
if (poll.getSelectedEntryIndex() != -1) { |
|
|
|
|
|
holder.selectedEntry.setText("You voted \"" + |
|
|
|
|
|
poll.getEntries()[poll.getSelectedEntryIndex()].getEntryName() + "\""); |
|
|
|
|
|
holder.selectedEntry.setVisibility(View.VISIBLE); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (poll.getRemoveVoteUrl() != null) { |
|
|
if (poll.getRemoveVoteUrl() != null) { |
|
|
holder.removeVotesButton.setOnClickListener(v -> viewModel.removeVote()); |
|
|
holder.removeVotesButton.setOnClickListener(v -> viewModel.removeVote()); |
|
@ -899,7 +909,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static class PollViewHolder extends RecyclerView.ViewHolder { |
|
|
static class PollViewHolder extends RecyclerView.ViewHolder { |
|
|
final TextView question, errorTextview; |
|
|
final TextView question, errorTextview, selectedEntry; |
|
|
final LinearLayout optionsLayout; |
|
|
final LinearLayout optionsLayout; |
|
|
final AppCompatButton submitButton; |
|
|
final AppCompatButton submitButton; |
|
|
final AppCompatButton removeVotesButton, showPollResultsButton, hidePollResultsButton; |
|
|
final AppCompatButton removeVotesButton, showPollResultsButton, hidePollResultsButton; |
|
@ -916,6 +926,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|
|
hidePollResultsButton = itemView.findViewById(R.id.show_poll_options_button); |
|
|
hidePollResultsButton = itemView.findViewById(R.id.show_poll_options_button); |
|
|
errorTextview = itemView.findViewById(R.id.error_too_many_checked); |
|
|
errorTextview = itemView.findViewById(R.id.error_too_many_checked); |
|
|
voteChart = itemView.findViewById(R.id.vote_chart); |
|
|
voteChart = itemView.findViewById(R.id.vote_chart); |
|
|
|
|
|
selectedEntry = itemView.findViewById(R.id.selected_entry_textview); |
|
|
voteChart.setScaleYEnabled(false); |
|
|
voteChart.setScaleYEnabled(false); |
|
|
voteChart.setDoubleTapToZoomEnabled(false); |
|
|
voteChart.setDoubleTapToZoomEnabled(false); |
|
|
} |
|
|
} |
|
|