Search in sources :

Example 1 with Poll

use of com.keylesspalace.tusky.entity.Poll in project Tusky by Vavassor.

the class NotificationHelper method bodyForType.

private static String bodyForType(Notification notification, Context context) {
    switch(notification.getType()) {
        case FOLLOW:
        case FOLLOW_REQUEST:
            return "@" + notification.getAccount().getUsername();
        case MENTION:
        case FAVOURITE:
        case REBLOG:
        case STATUS:
            if (!TextUtils.isEmpty(notification.getStatus().getSpoilerText())) {
                return notification.getStatus().getSpoilerText();
            } else {
                return notification.getStatus().getContent().toString();
            }
        case POLL:
            if (!TextUtils.isEmpty(notification.getStatus().getSpoilerText())) {
                return notification.getStatus().getSpoilerText();
            } else {
                StringBuilder builder = new StringBuilder(notification.getStatus().getContent());
                builder.append('\n');
                Poll poll = notification.getStatus().getPoll();
                List<PollOption> options = poll.getOptions();
                for (int i = 0; i < options.size(); ++i) {
                    PollOption option = options.get(i);
                    builder.append(buildDescription(option.getTitle(), PollViewDataKt.calculatePercent(option.getVotesCount(), poll.getVotersCount(), poll.getVotesCount()), poll.getOwnVotes() != null && poll.getOwnVotes().contains(i), context));
                    builder.append('\n');
                }
                return builder.toString();
            }
    }
    return null;
}
Also used : Poll(com.keylesspalace.tusky.entity.Poll) PollOption(com.keylesspalace.tusky.entity.PollOption)

Aggregations

Poll (com.keylesspalace.tusky.entity.Poll)1 PollOption (com.keylesspalace.tusky.entity.PollOption)1