use of com.keylesspalace.tusky.viewdata.PollOptionViewData in project Tusky by Vavassor.
the class StatusBaseViewHolder method getPollDescription.
private CharSequence getPollDescription(@NonNull StatusViewData.Concrete status, Context context, StatusDisplayOptions statusDisplayOptions) {
PollViewData poll = PollViewDataKt.toViewData(status.getActionable().getPoll());
if (poll == null) {
return "";
} else {
Object[] args = new CharSequence[5];
List<PollOptionViewData> options = poll.getOptions();
for (int i = 0; i < args.length; i++) {
if (i < options.size()) {
int percent = PollViewDataKt.calculatePercent(options.get(i).getVotesCount(), poll.getVotersCount(), poll.getVotesCount());
args[i] = buildDescription(options.get(i).getTitle(), percent, options.get(i).getVoted(), context);
} else {
args[i] = "";
}
}
args[4] = getPollInfoText(System.currentTimeMillis(), poll, statusDisplayOptions, context);
return context.getString(R.string.description_poll, args);
}
}
Aggregations