use of POGOProtos.Networking.Responses.MarkReadNewsArticleResponseOuterClass.MarkReadNewsArticleResponse in project PokeGOAPI-Java by Grover-c13.
the class News method markUnreadNews.
/**
* Mark Unread News to read
*/
public void markUnreadNews() {
if (currentNews == null || currentNews.getNewsArticlesCount() <= 0) {
// do nothing
return;
}
// Stored enabled and un-read article
List<String> unReadNewsList = new ArrayList<>();
for (NewsArticle newsArticle : currentNews.getNewsArticlesList()) {
if (newsArticle.getEnabled() && !newsArticle.getArticleRead())
unReadNewsList.add(newsArticle.getId());
}
Log.i(TAG, "markUnreadNews total Article count:" + unReadNewsList.size());
if (unReadNewsList.size() > 0) {
MarkReadNewsArticleMessage msg = MarkReadNewsArticleMessage.newBuilder().addAllNewsIds(unReadNewsList).build();
ServerRequest request = new ServerRequest(RequestTypeOuterClass.RequestType.MARK_READ_NEWS_ARTICLE, msg);
ServerRequestEnvelope envelope = ServerRequestEnvelope.create(request);
try {
api.requestHandler.sendServerRequests(envelope);
MarkReadNewsArticleResponse response = MarkReadNewsArticleResponse.parseFrom(request.getData());
if (response.getResult() == MarkReadNewsArticleResponse.Result.SUCCESS) {
Log.i(TAG, "Mark News Article -> success");
} else {
Log.w(TAG, "Mark News Article -> !success");
}
} catch (RequestFailedException e) {
e.printStackTrace();
Log.e(TAG, "RequestFailedException: cause:" + e.getCause() + " message:" + e.getMessage());
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
Log.e(TAG, "InvalidProtocolBufferException: cause:" + e.getCause() + " message:" + e.getMessage());
}
} else {
Log.i(TAG, "no unmarked news found -> skipped");
}
}
Aggregations