diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-09-27 03:08:45 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-09-27 03:08:45 +0000 |
commit | fe55d8816592067c79f74c656c00e80973a1438d (patch) | |
tree | bb3f86471ceb3c83f48c2564489868c839085a12 | |
parent | cb0fcf77a7e12159570827366124445360e70aee (diff) | |
download | infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.tar infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.tar.gz infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.tar.bz2 infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.tar.lz infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.tar.xz infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.tar.zst infinity-for-reddit-fe55d8816592067c79f74c656c00e80973a1438d.zip |
Continue optimizing class structures in PostRecyclerViewAdapter.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java | 106 |
1 files 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<Post, RecyclerVie mActivity.startActivity(intent); }); - setOnClickListeners( - typeTextView, + setOnClickListeners(typeTextView, nsfwTextView, flairTextView, upvoteButton, @@ -2712,6 +2711,31 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie MaterialButton commentsCountButton, MaterialButton saveButton, MaterialButton shareButton) { + itemView.setOnClickListener(view -> { + 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<Post, RecyclerVie MaterialButton commentsCountButton, MaterialButton saveButton, MaterialButton shareButton) { - super.setBaseView(iconGifImageView, + super.setBaseView( + iconGifImageView, subredditTextView, userTextView, typeTextView, @@ -3468,18 +3493,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie saveButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); shareButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); - itemView.setOnClickListener(view -> { - 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<Post, RecyclerVie postOptionsBottomSheetFragment.show(mActivity.getSupportFragmentManager(), postOptionsBottomSheetFragment.getTag()); return true; }); - - itemView.setOnTouchListener((v, event) -> { - 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<Post, RecyclerVie imageView.setClipToOutline(true); noPreviewLinkImageFrameLayout.setClipToOutline(true); - itemView.setOnClickListener(view -> { - 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<Post, RecyclerVie return true; }); - itemView.setOnTouchListener((v, event) -> { - 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<Post, RecyclerVie commentsCountButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); saveButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); shareButton.setIconTint(ColorStateList.valueOf(mPostIconAndInfoColor)); - - itemView.setOnClickListener(view -> { - 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 |