parent
e237639adc
commit
8e2e815b84
2 changed files with 13 additions and 4 deletions
|
@ -37,18 +37,21 @@ class PollAdapter: RecyclerView.Adapter<PollViewHolder>() {
|
||||||
private var votersCount: Int? = null
|
private var votersCount: Int? = null
|
||||||
private var mode = RESULT
|
private var mode = RESULT
|
||||||
private var emojis: List<Emoji> = emptyList()
|
private var emojis: List<Emoji> = emptyList()
|
||||||
|
private var resultClickListener: View.OnClickListener? = null
|
||||||
|
|
||||||
fun setup(
|
fun setup(
|
||||||
options: List<PollOptionViewData>,
|
options: List<PollOptionViewData>,
|
||||||
voteCount: Int,
|
voteCount: Int,
|
||||||
votersCount: Int?,
|
votersCount: Int?,
|
||||||
emojis: List<Emoji>,
|
emojis: List<Emoji>,
|
||||||
mode: Int) {
|
mode: Int,
|
||||||
|
resultClickListener: View.OnClickListener?) {
|
||||||
this.pollOptions = options
|
this.pollOptions = options
|
||||||
this.voteCount = voteCount
|
this.voteCount = voteCount
|
||||||
this.votersCount = votersCount
|
this.votersCount = votersCount
|
||||||
this.emojis = emojis
|
this.emojis = emojis
|
||||||
this.mode = mode
|
this.mode = mode
|
||||||
|
this.resultClickListener = resultClickListener
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ class PollAdapter: RecyclerView.Adapter<PollViewHolder>() {
|
||||||
val level = percent * 100
|
val level = percent * 100
|
||||||
|
|
||||||
holder.resultTextView.background.level = level
|
holder.resultTextView.background.level = level
|
||||||
|
holder.resultTextView.setOnClickListener(resultClickListener)
|
||||||
}
|
}
|
||||||
SINGLE -> {
|
SINGLE -> {
|
||||||
val emojifiedPollOptionText = option.title.emojify(emojis, holder.radioButton)
|
val emojifiedPollOptionText = option.title.emojify(emojis, holder.radioButton)
|
||||||
|
|
|
@ -915,12 +915,18 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
if (expired || poll.getVoted()) {
|
if (expired || poll.getVoted()) {
|
||||||
// no voting possible
|
// no voting possible
|
||||||
pollAdapter.setup(poll.getOptions(), poll.getVotesCount(), poll.getVotersCount(), emojis, PollAdapter.RESULT);
|
View.OnClickListener viewThreadListener = v -> {
|
||||||
|
int position = getAdapterPosition();
|
||||||
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
|
listener.onViewThread(position);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
pollAdapter.setup(poll.getOptions(), poll.getVotesCount(), poll.getVotersCount(), emojis, PollAdapter.RESULT, viewThreadListener);
|
||||||
|
|
||||||
pollButton.setVisibility(View.GONE);
|
pollButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
// voting possible
|
// voting possible
|
||||||
pollAdapter.setup(poll.getOptions(), poll.getVotesCount(), poll.getVotersCount(), emojis, poll.getMultiple() ? PollAdapter.MULTIPLE : PollAdapter.SINGLE);
|
pollAdapter.setup(poll.getOptions(), poll.getVotesCount(), poll.getVotersCount(), emojis, poll.getMultiple() ? PollAdapter.MULTIPLE : PollAdapter.SINGLE, null);
|
||||||
|
|
||||||
pollButton.setVisibility(View.VISIBLE);
|
pollButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue