use of com.winsonchiu.reader.data.reddit.Votable in project Reader by TheKeeperOfPie.
the class EventListenerBase method onVote.
public <T extends Votable> Observable<T> onVote(T votable, Likes vote) {
Likes voteOld = votable.getLikes();
if (vote == voteOld) {
vote = Likes.NONE;
}
votable.setLikes(vote);
return reddit.voteLink(votable, vote).flatMap(s -> Observable.<T>empty()).onErrorResumeNext(throwable -> {
votable.setLikes(voteOld);
return Observable.just(votable).concatWith(Observable.error(throwable));
}).startWith(votable);
}
Aggregations