diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-11-14 04:17:55 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-11-14 04:17:55 +0000 |
commit | 968b04a508405d2e450bc319b49fcb3e5a3351ba (patch) | |
tree | 9c1f89b0477f3cf39e83c9f21213479209d199cb /app | |
parent | 746ebc848c44daf7f9170cb37873eace99fb3faa (diff) | |
download | infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.tar infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.tar.gz infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.tar.bz2 infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.tar.lz infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.tar.xz infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.tar.zst infinity-for-reddit-968b04a508405d2e450bc319b49fcb3e5a3351ba.zip |
Send correct image index when opening the image in gallery posts.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index 182204e5..c39560fa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -3271,12 +3271,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie break; case MotionEvent.ACTION_UP: if (!dragged) { - int index = layoutManager.findFirstVisibleItemPosition(); int position = getBindingAdapterPosition(); if (position >= 0) { if (post != null) { markPostRead(post, true); - openMedia(post, index); + openMedia(post, layoutManager.findFirstVisibleItemPosition()); } } } @@ -4278,7 +4277,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie ImageView noPreviewImageView; PostGalleryTypeImageRecyclerViewAdapter adapter; - private boolean swipeLocked; + private SwipeLockLinearLayoutManager layoutManager; Post post; Post.Preview preview; @@ -4314,23 +4313,16 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie recyclerView.setAdapter(adapter); new PagerSnapHelper().attachToRecyclerView(recyclerView); recyclerView.setRecycledViewPool(mGalleryRecycledViewPool); - SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager( + layoutManager = new SwipeLockLinearLayoutManager( mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() { @Override public void lockSwipe() { mActivity.lockSwipeRightToGoBack(); - swipeLocked = true; } @Override public void unlockSwipe() { mActivity.unlockSwipeRightToGoBack(); - swipeLocked = false; - } - - @Override - public void setSwipeLocked(boolean swipeLocked) { - PostGalleryBaseGalleryTypeViewHolder.this.swipeLocked = swipeLocked; } }); recyclerView.setLayoutManager(layoutManager); @@ -4416,7 +4408,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie if (post.getPostType() == Post.TEXT_TYPE || !mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) { openViewPostDetailActivity(post, getBindingAdapterPosition()); } else { - openMedia(post); + openMedia(post, layoutManager.findFirstVisibleItemPosition()); } } } @@ -4432,7 +4424,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie if (post.getPostType() == Post.TEXT_TYPE || mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) { openViewPostDetailActivity(post, getBindingAdapterPosition()); } else { - openMedia(post); + openMedia(post, layoutManager.findFirstVisibleItemPosition()); } } } |