diff options
author | Maxime Biais <maxime.biais@gmail.com> | 2014-07-29 19:21:04 +0200 |
---|---|---|
committer | Maxime Biais <maxime.biais@gmail.com> | 2014-07-29 19:21:04 +0200 |
commit | d6911576dca7d6eb3b6c98e9ca5ba981644f9066 (patch) | |
tree | 80335cbedb11c960e418fc2cba6a5ee7f37db3fe | |
parent | f44256337713c9e451ffea10647c1b12c779fe59 (diff) | |
parent | 60f80ae5ac4c724f70b3286b6a36ba8c2bed2d9f (diff) | |
download | gradle-perf-android-medium-d6911576dca7d6eb3b6c98e9ca5ba981644f9066.tar.gz |
Merge pull request #1666 from wordpress-mobile/issue/1659-reader-counts-dont-change
Issue/1659 reader counts dont change
4 files changed, 16 insertions, 38 deletions
diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java index 080ea9cf1..830377486 100644 --- a/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java +++ b/WordPress/src/main/java/org/wordpress/android/datasets/ReaderPostTable.java @@ -279,25 +279,6 @@ public class ReaderPostTable { args); } - /* - * updates the follow status of all posts in the passed list, returns true if any changed - */ - public static boolean checkFollowStatusOnPosts(ReaderPostList posts) { - if (posts == null || posts.size() == 0) { - return false; - } - - boolean isChanged = false; - for (ReaderPost post: posts) { - boolean isFollowed = isPostFollowed(post); - if (isFollowed != post.isFollowedByCurrentUser) { - post.isFollowedByCurrentUser = isFollowed; - isChanged = true; - } - } - return isChanged; - } - public static int deletePostsWithTag(final ReaderTag tag) { if (tag == null) { return 0; diff --git a/WordPress/src/main/java/org/wordpress/android/models/ReaderPostList.java b/WordPress/src/main/java/org/wordpress/android/models/ReaderPostList.java index 39f69a441..e006d6173 100644 --- a/WordPress/src/main/java/org/wordpress/android/models/ReaderPostList.java +++ b/WordPress/src/main/java/org/wordpress/android/models/ReaderPostList.java @@ -39,12 +39,23 @@ public class ReaderPostList extends ArrayList<ReaderPost> { * does passed list contain the same posts as this list? */ public boolean isSameList(ReaderPostList posts) { - if (posts==null || posts.size()!=this.size()) + if (posts == null || posts.size() != this.size()) { return false; + } for (ReaderPost post: posts) { - if (indexOfPost(post.blogId, post.postId) == -1) + int index = indexOfPost(post.blogId, post.postId); + if (index == -1) { return false; + } + ReaderPost thisPost = this.get(index); + if (thisPost.numLikes != post.numLikes + || thisPost.numReplies != post.numReplies + || thisPost.isFollowedByCurrentUser != post.isFollowedByCurrentUser + || thisPost.isLikedByCurrentUser != post.isLikedByCurrentUser + || thisPost.isRebloggedByCurrentUser != post.isRebloggedByCurrentUser) { + return false; + } } return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java index c08ae99d1..ee62f7aff 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java @@ -206,16 +206,12 @@ public class ReaderPostListFragment extends Fragment public void onResume() { super.onResume(); - // if the fragment is resuming from a paused state, refresh the adapter to make sure - // the follow status of all posts is accurate - this is necessary in case the user - // returned from an activity where the follow status may have been changed if (mWasPaused) { AppLog.d(T.READER, "reader post list > resumed from paused state"); mWasPaused = false; - if (hasPostAdapter()) { - getPostAdapter().checkFollowStatusForAllPosts(); - } - + // refresh the posts in case the user returned from an activity that + // changed one (or more) of the posts + refreshPosts(); // likewise for tags refreshTags(); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java index 2095a5288..b5e88ef52 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/adapters/ReaderPostAdapter.java @@ -186,16 +186,6 @@ public class ReaderPostAdapter extends BaseAdapter { } /* - * ensures that the follow status of each post in the list reflects what is currently - * stored in the reader post table - */ - public void checkFollowStatusForAllPosts() { - if (ReaderPostTable.checkFollowStatusOnPosts(mPosts)) { - notifyDataSetChanged(); - } - } - - /* * sets the follow status of each post in the passed blog */ void updateFollowStatusOnPostsForBlog(long blogId, String blogUrl, boolean followStatus) { |