Skip to content

Commit db09315

Browse files
Download the gallery image that's been swiped to in PostOptionsBottomSheetFragment.
1 parent aac0de2 commit db09315

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2836,7 +2836,13 @@ void setBaseView(AspectRatioGifImageView iconGifImageView,
28362836
return false;
28372837
}
28382838

2839-
PostOptionsBottomSheetFragment postOptionsBottomSheetFragment = PostOptionsBottomSheetFragment.newInstance(post);
2839+
PostOptionsBottomSheetFragment postOptionsBottomSheetFragment;
2840+
if (post.getPostType() == Post.GALLERY_TYPE && this instanceof PostBaseGalleryTypeViewHolder) {
2841+
postOptionsBottomSheetFragment = PostOptionsBottomSheetFragment.newInstance(post,
2842+
((LinearLayoutManagerBugFixed) ((PostBaseGalleryTypeViewHolder) this).galleryRecyclerView.getLayoutManager()).findFirstVisibleItemPosition());
2843+
} else {
2844+
postOptionsBottomSheetFragment = PostOptionsBottomSheetFragment.newInstance(post);
2845+
}
28402846
postOptionsBottomSheetFragment.show(mActivity.getSupportFragmentManager(), postOptionsBottomSheetFragment.getTag());
28412847
return true;
28422848
});

app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostOptionsBottomSheetFragment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ public PostOptionsBottomSheetFragment() {
5656
* @param post Post
5757
* @return A new instance of fragment PostOptionsBottomSheetFragment.
5858
*/
59+
public static PostOptionsBottomSheetFragment newInstance(Post post, int galleryIndex) {
60+
PostOptionsBottomSheetFragment fragment = new PostOptionsBottomSheetFragment();
61+
Bundle args = new Bundle();
62+
args.putParcelable(EXTRA_POST, post);
63+
args.putInt(EXTRA_GALLERY_INDEX, galleryIndex);
64+
fragment.setArguments(args);
65+
return fragment;
66+
}
67+
5968
public static PostOptionsBottomSheetFragment newInstance(Post post) {
6069
PostOptionsBottomSheetFragment fragment = new PostOptionsBottomSheetFragment();
6170
Bundle args = new Bundle();

0 commit comments

Comments
 (0)