use of org.wordpress.android.ui.reader.actions.ReaderActions.UpdateResultListener in project WordPress-Android by wordpress-mobile.
the class ReaderCommentService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent == null) {
return START_NOT_STICKY;
}
EventBus.getDefault().post(new ReaderEvents.UpdateCommentsStarted());
final long blogId = intent.getLongExtra(ARG_BLOG_ID, 0);
final long postId = intent.getLongExtra(ARG_POST_ID, 0);
final long commentId = intent.getLongExtra(ARG_COMMENT_ID, 0);
boolean requestNextPage = intent.getBooleanExtra(ARG_NEXT_PAGE, false);
if (requestNextPage) {
int prevPage = ReaderCommentTable.getLastPageNumberForPost(blogId, postId);
mCurrentPage = prevPage + 1;
} else {
mCurrentPage = 1;
}
updateCommentsForPost(blogId, postId, mCurrentPage, new UpdateResultListener() {
@Override
public void onUpdateResult(UpdateResult result) {
if (commentId > 0) {
if (ReaderCommentTable.commentExists(blogId, postId, commentId) || !result.isNewOrChanged()) {
EventBus.getDefault().post(new ReaderEvents.UpdateCommentsEnded(result));
stopSelf();
} else {
// Comment not found yet, request the next page
mCurrentPage++;
updateCommentsForPost(blogId, postId, mCurrentPage, this);
}
} else {
EventBus.getDefault().post(new ReaderEvents.UpdateCommentsEnded(result));
stopSelf();
}
}
});
return START_NOT_STICKY;
}
use of org.wordpress.android.ui.reader.actions.ReaderActions.UpdateResultListener in project WordPress-Android by wordpress-mobile.
the class ReaderPostService method updatePostsInBlog.
private void updatePostsInBlog(long blogId, final UpdateAction action) {
UpdateResultListener listener = new UpdateResultListener() {
@Override
public void onUpdateResult(UpdateResult result) {
EventBus.getDefault().post(new ReaderEvents.UpdatePostsEnded(result, action));
stopSelf();
}
};
requestPostsForBlog(blogId, action, listener);
}
use of org.wordpress.android.ui.reader.actions.ReaderActions.UpdateResultListener in project WordPress-Android by wordpress-mobile.
the class ReaderPostService method updatePostsInFeed.
private void updatePostsInFeed(long feedId, final UpdateAction action) {
UpdateResultListener listener = new UpdateResultListener() {
@Override
public void onUpdateResult(UpdateResult result) {
EventBus.getDefault().post(new ReaderEvents.UpdatePostsEnded(result, action));
stopSelf();
}
};
requestPostsForFeed(feedId, action, listener);
}
Aggregations