From 7678446ba6b34b043b1ad2784ed6b32df43eb48c Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Wed, 4 Nov 2020 13:46:49 -0500 Subject: [PATCH] fix story linked post, video post, and clicking back button too early on pvv2 --- .../awais/instagrabber/asyncs/PostFetcher.java | 3 +++ .../fragments/PostViewV2Fragment.java | 15 +++++++++------ .../instagrabber/webservices/StoriesService.java | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java b/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java index 04543061..b2fbfdc3 100755 --- a/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java +++ b/app/src/main/java/awais/instagrabber/asyncs/PostFetcher.java @@ -117,6 +117,9 @@ public final class PostFetcher extends AsyncTask { .setPostId(media.getString(Constants.EXTRAS_ID)) .setDisplayUrl(isVideo ? media.getString("video_url") : ResponseBodyUtils.getHighQualityImage(media)) + .setThumbnailUrl(media.getString("display_url")) + .setImageHeight(media.getJSONObject("dimensions").getInt("height")) + .setImageWidth(media.getJSONObject("dimensions").getInt("width")) .setShortCode(shortCode) .setPostCaption(TextUtils.isEmpty(postCaption) ? null : postCaption) .setProfileModel(profileModel) diff --git a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java index 723705fb..d7ca2d65 100644 --- a/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/PostViewV2Fragment.java @@ -717,12 +717,15 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment { } private void setupCounts() { - final int commentsCount = (int) feedModel.getCommentsCount(); - final String commentsString = getResources().getQuantityString(R.plurals.comments_count, commentsCount, commentsCount); - binding.commentsCount.setText(commentsString); - final int likesCount = (int) feedModel.getLikesCount(); - final String likesString = getResources().getQuantityString(R.plurals.likes_count, likesCount, likesCount); - binding.likesCount.setText(likesString); + try { + final int commentsCount = (int) feedModel.getCommentsCount(); + final String commentsString = getResources().getQuantityString(R.plurals.comments_count, commentsCount, commentsCount); + binding.commentsCount.setText(commentsString); + final int likesCount = (int) feedModel.getLikesCount(); + final String likesString = getResources().getQuantityString(R.plurals.likes_count, likesCount, likesCount); + binding.likesCount.setText(likesString); + } + catch (IllegalStateException e) {} } private void setupPostTypeLayout() { diff --git a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java index 6eeb53af..ecc657d1 100644 --- a/app/src/main/java/awais/instagrabber/webservices/StoriesService.java +++ b/app/src/main/java/awais/instagrabber/webservices/StoriesService.java @@ -188,7 +188,7 @@ public class StoriesService extends BaseService { model.setVideoUrl(ResponseBodyUtils.getHighQualityPost(videoResources, true, true, false)); if (data.has("story_feed_media")) { - model.setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_id")); + model.setTappableShortCode(data.getJSONArray("story_feed_media").getJSONObject(0).optString("media_code")); } // TODO: this may not be limited to spotify