From fe55d8816592067c79f74c656c00e80973a1438d Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:08:45 -0400 Subject: Continue optimizing class structures in PostRecyclerViewAdapter. --- .../adapters/PostRecyclerViewAdapter.java | 106 ++++++--------------- 1 file changed, 28 insertions(+), 78 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 be869dbf..fc30b293 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -2641,8 +2641,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + int position = getBindingAdapterPosition(); + if (position >= 0 && canStartActivity) { + Post post = getItem(position); + if (post != null) { + markPostRead(post, true); + + openViewPostDetailActivity(post, getBindingAdapterPosition()); + } + } + }); + + itemView.setOnTouchListener((v, event) -> { + if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) { + if (mFragment.isRecyclerViewItemSwipeable(this)) { + mActivity.unlockSwipeRightToGoBack(); + } + } else { + if (mFragment.isRecyclerViewItemSwipeable(this)) { + mActivity.lockSwipeRightToGoBack(); + } + } + return false; + }); + upvoteButton.setOnClickListener(view -> { int position = getBindingAdapterPosition(); if (position < 0) { @@ -3373,7 +3397,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - int position = getBindingAdapterPosition(); - if (position >= 0 && canStartActivity) { - Post post = getItem(position); - if (post != null) { - markPostRead(post, true); - - openViewPostDetailActivity(post, getBindingAdapterPosition()); - } - } - }); - itemView.setOnLongClickListener(v -> { Post post = getItem(getBindingAdapterPosition()); if (post == null) { @@ -3496,19 +3509,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) { - if (mFragment.isRecyclerViewItemSwipeable(PostBaseViewHolder.this)) { - mActivity.unlockSwipeRightToGoBack(); - } - } else { - if (mFragment.isRecyclerViewItemSwipeable(PostBaseViewHolder.this)) { - mActivity.lockSwipeRightToGoBack(); - } - } - return false; - }); } void setBaseView(AspectRatioGifImageView iconGifImageView, @@ -4380,18 +4380,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - int position = getBindingAdapterPosition(); - if (position < 0) { - return; - } - Post post = getItem(position); - if (post != null && canStartActivity) { - markPostRead(post, true); - openViewPostDetailActivity(post, getBindingAdapterPosition()); - } - }); - itemView.setOnLongClickListener(view -> { if (mLongPressToHideToolbarInCompactLayout) { if (bottomConstraintLayout.getLayoutParams().height == 0) { @@ -4409,19 +4397,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) { - if (mFragment.isRecyclerViewItemSwipeable(PostCompactBaseViewHolder.this)) { - mActivity.unlockSwipeRightToGoBack(); - } - } else { - if (mFragment.isRecyclerViewItemSwipeable(PostCompactBaseViewHolder.this)) { - mActivity.lockSwipeRightToGoBack(); - } - } - return false; - }); - imageView.setOnClickListener(view -> { int position = getBindingAdapterPosition(); if (position < 0) { @@ -5106,31 +5081,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - int position = getBindingAdapterPosition(); - if (position >= 0 && canStartActivity) { - Post post = getItem(position); - if (post != null) { - markPostRead(post, true); - - openViewPostDetailActivity(post, getBindingAdapterPosition()); - } - } - }); - - itemView.setOnTouchListener((v, event) -> { - if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) { - if (mFragment.isRecyclerViewItemSwipeable(PostMaterial3CardBaseViewHolder.this)) { - mActivity.unlockSwipeRightToGoBack(); - } - } else { - if (mFragment.isRecyclerViewItemSwipeable(PostMaterial3CardBaseViewHolder.this)) { - mActivity.lockSwipeRightToGoBack(); - } - } - return false; - }); } @Override -- cgit v1.2.3