Feature/reader full post refresh related posts#4626
Conversation
…ss-Android into feature/reader-full-post-refresh-related-posts
…hub.com/wordpress-mobile/WordPress-Android into feature/reader-full-post-refresh-related-posts
…hub.com/wordpress-mobile/WordPress-Android into feature/reader-full-post-refresh-related-posts
hypest
left a comment
There was a problem hiding this comment.
Noticed that the images on the related posts are vertically stressed. I could attach a screenshot if you want but, the issue is visible on the shot on the PR description as well.
hypest
left a comment
There was a problem hiding this comment.
On my network connection, Related posts take a few seconds to load and there is nothing to indicate that there's a background attempt in loading them.
May I suggest making the headers ("MORE IN ..." and "MORE ON WORDPRESS.COM" always visible and add some form of indicator that filling in those sections is still undergoing (e.g. a progress indicator)? Thanks!
Bah, you're right and I meant to mention that. If it's okay with you, I'd like to open a separate issue for this. The fix is likely a bit convoluted and this PR is already fairly large. |
I don't think we want the headers visible since there are cases when one (or, rarely, both) won't have related posts. So we only want to show them when we know they have related posts, which doesn't happen until after the call completes. I'm ambivalent about the progress indicator. I don't think it's really needed but it's simple enough to add. Just let me know if you feel that would necessary. |
@nbradbury sure, WFM! |
I see. I can see that needing a bit of effort that could be delivered with a subsequent PR so, I'd say let's just make this a ticket instead. Besides, the same happens with the "Liked by" section (invisible until response arrives) so, perhaps we can include that section as well in the same ticket. |
hypest
left a comment
There was a problem hiding this comment.
Hey @nbradbury , I've left some more comments, most of which are non-blocking. I'd like to hear your opinion on them though before moving on. Thanks!
| ReaderRelatedPost post = new ReaderRelatedPost(); | ||
|
|
||
| post.mPostId = json.optLong("ID"); | ||
| post.mSiteId = json.optLong("site_ID"); |
There was a problem hiding this comment.
Hmm, are ID and site_ID really optional on the server side?
If not, I would prefer us to use getLong and handle the errors instead.
There was a problem hiding this comment.
I've favored using the various optXxx methods throughout the reader, but I'm certainly open to alternatives. How would you suggest I handle the errors?
There was a problem hiding this comment.
In this case, I'd say to drop the specific related post json and return null. Caller will need to check for the null accordingly. WDYT?
| } | ||
|
|
||
| ReaderRelatedPostList posts = new ReaderRelatedPostList(); | ||
| JSONArray jsonPosts = json.optJSONArray("posts"); |
There was a problem hiding this comment.
This made me pause a bit, wondering why would we need to dive deeper into the json object to get the data we need for this function.
May I suggest removing the need for this knowledge (of where the list is contained into the json structure) and pass the JSONArray directly as the function parameter? The caller (handleRelatedPostsResponse, which is a network response handler in this case) can validate the json and offer the list directly. Let me know what you think!
|
|
||
| private void initView(Context context) { | ||
| inflate(context, R.layout.reader_related_posts_view, this); | ||
| mFeaturedImageWidth = DisplayUtils.dpToPx(getContext(), getResources().getDimensionPixelSize(R.dimen.reader_related_post_image_width)); |
There was a problem hiding this comment.
Can we reconcile the 2 Contexts used in these lines? I mean, there is one passed as a parameter and one got via getContext() so, can we instead use only one or the other? Thanks!
| mClickListener = listener; | ||
| } | ||
|
|
||
| public void showRelatedPosts(ReaderRelatedPostList posts, String siteName, boolean isGlobal) { |
There was a problem hiding this comment.
Function seems to expect posts being not null so, we might as well denote it with an annotation like in other places in the PR, what do you think?
|
|
||
| public void showRelatedPosts(ReaderRelatedPostList posts, String siteName, boolean isGlobal) { | ||
| mRelatedPostList = posts; | ||
| if (mRelatedPostList.size() == 0) return; |
There was a problem hiding this comment.
Interesting exit from the function.
I'm wondering, for completeness sake's would it be better to clean up any elements that might already be in the View's layout? Like, if showRelatedPosts() is called again basically but with an empty list. What do you think?
|
|
||
| <LinearLayout | ||
| <RelativeLayout | ||
| android:id="@+id/layout_related_post_site_header" |
There was a problem hiding this comment.
This is more like a comment just to put it out there: It seems that the header click acts as a click on the related post itself and opens the post. It felt counter-intuitive the first couple of times I tried it. I was expecting it to go to the site (in Reader) instead. Apart from the smaller size overall, the header looks like the relevant headers elsewhere, and there the click opens the site.
This is not a blocking comment though.
There was a problem hiding this comment.
I wrestled with this one. I agree it would be more consistent to show the site when the header is clicked, but at the same time it's very easy to tap the header when you intended to tap the post (something that actually happens to me already in the list view, but that's another story!). So in the end I decided not to make the header tappable.
There was a problem hiding this comment.
I see. I think this is a good comment (augmented by your hands-on feedback as well) that we prolly should raise it at the design review phase as well. This is, again, a case where the design for the web (where a mouse will be used to accurately click on the various sections) is not suitable for the mobile where (big) fingers demand ample spacing.
|
Another small note, not a blocking one as well: the Follow button doesn't provide any hints of its function. It is familiar from the rest of the app but still. On Calypso web, the button has a tooltip appearing on mouse-over which of course is not directly translatable to the mobile. |
Yes, that bothered me as well. I originally had the follow/following text on that button, but again it complicated the tap target. It was easy to tap the follow text when you meant to tap the post, especially on smaller screens, so I dropped the follow text (which matches the mobile web design, too). I think the purpose of that button is obvious enough, though, since as you mention it's shown in so many other places. |
|
Thanks for reviewing this one @hypest - ready for round two! |
…hub.com/wordpress-mobile/WordPress-Android into feature/reader-full-post-refresh-related-posts
hypest
left a comment
There was a problem hiding this comment.
Hey @nbradbury , thanks for the extra commits! I've left some new comments that probably require changes so, have a look. Thanks!
|
|
||
| private void initView(Context context) { | ||
| inflate(context, R.layout.reader_related_posts_view, this); | ||
| mFeaturedImageWidth = DisplayUtils.dpToPx(context, getResources().getDimensionPixelSize(R.dimen.reader_related_post_image_width)); |
There was a problem hiding this comment.
I the same vein as the previous comment in this function, perhaps we better use the provided context to retrieve the Resources. So, something like context.getResources(). WDYT?
| ReaderRelatedPost post = new ReaderRelatedPost(); | ||
|
|
||
| post.mPostId = json.optLong("ID"); | ||
| post.mSiteId = json.optLong("site_ID"); |
There was a problem hiding this comment.
In this case, I'd say to drop the specific related post json and return null. Caller will need to check for the null accordingly. WDYT?
| public static ReaderRelatedPostList fromJsonPosts(@NonNull JSONArray jsonPosts) { | ||
| ReaderRelatedPostList posts = new ReaderRelatedPostList(); | ||
| for (int i = 0; i < jsonPosts.length(); i++) { | ||
| posts.add(ReaderRelatedPost.fromJson(jsonPosts.optJSONObject(i))); |
There was a problem hiding this comment.
Didn't notice that on my first pass but, it seems ReaderRelatedPost.fromJson() is not expecting null as a parameter but jsonPosts.optJSONObject can return one. We prolly need to null check the parameter first, or change the function to accept null, right?
There was a problem hiding this comment.
I don't think it's possible for optJSONObject() to return null here, since we're looping through the array of objects. But for future use null-checking makes sense - added in 69c0909.
There was a problem hiding this comment.
AFAICT, optJSONObject() can return null if the array item is not a JSONObject and JSONArray can indeed hold a mix of any kind of json types. The null check you added will do the job so, 👍
Hopefully we can bring this up at the design review phase as well. Thanks! |
Addressed in 419aa41. Ready for round 3! |
|
LGTM @nbradbury , thanks for the changes! I'll merge this as soon as Travis has its pass. Thanks! |
This is the third in a slew of PRs which tackles the full post refresh (#4581). This PR deals with upgrading the related posts shown below every wp.com post in the reader post detail.
Previously we showed a single "related reading" section, now we show two related posts from the same site as the current post ("local" related posts), followed by two related posts from across wp.com ("global" related posts).
The before & after pics below illustrate the changes.
