mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Support swipe action in PostCompactBaseViewHolder.
This commit is contained in:
parent
38ce4db311
commit
366660a6d0
@ -1306,6 +1306,15 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
((PostBaseViewHolder) viewHolder).downvoteButton.performClick();
|
((PostBaseViewHolder) viewHolder).downvoteButton.performClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (viewHolder instanceof PostCompactBaseViewHolder) {
|
||||||
|
Post post = getItem(viewHolder.getAdapterPosition());
|
||||||
|
if (post != null) {
|
||||||
|
if (direction == ItemTouchHelper.LEFT || direction == ItemTouchHelper.START) {
|
||||||
|
((PostCompactBaseViewHolder) viewHolder).upvoteButton.performClick();
|
||||||
|
} else {
|
||||||
|
((PostCompactBaseViewHolder) viewHolder).downvoteButton.performClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1317,7 +1326,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
void currentlyBindItem(int position);
|
void currentlyBindItem(int position);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostBaseViewHolder extends RecyclerView.ViewHolder {
|
public class PostBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
MaterialCardView cardView;
|
MaterialCardView cardView;
|
||||||
AspectRatioGifImageView iconGifImageView;
|
AspectRatioGifImageView iconGifImageView;
|
||||||
TextView subredditTextView;
|
TextView subredditTextView;
|
||||||
@ -2658,7 +2667,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostCompactBaseViewHolder extends RecyclerView.ViewHolder {
|
public class PostCompactBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
AspectRatioGifImageView iconGifImageView;
|
AspectRatioGifImageView iconGifImageView;
|
||||||
TextView nameTextView;
|
TextView nameTextView;
|
||||||
ImageView stickiedPostImageView;
|
ImageView stickiedPostImageView;
|
||||||
@ -2760,7 +2769,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
constraintSet.applyTo(bottomConstraintLayout);
|
constraintSet.applyTo(bottomConstraintLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
|
itemView.setBackgroundColor(mCardViewBackgroundColor);
|
||||||
postTimeTextView.setTextColor(mSecondaryTextColor);
|
postTimeTextView.setTextColor(mSecondaryTextColor);
|
||||||
titleTextView.setTextColor(mPostTitleColor);
|
titleTextView.setTextColor(mPostTitleColor);
|
||||||
stickiedPostImageView.setColorFilter(mStickiedPostIconTint, PorterDuff.Mode.SRC_IN);
|
stickiedPostImageView.setColorFilter(mStickiedPostIconTint, PorterDuff.Mode.SRC_IN);
|
||||||
|
@ -645,6 +645,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||||
|
if (!(viewHolder instanceof PostRecyclerViewAdapter.PostBaseViewHolder) &&
|
||||||
|
!(viewHolder instanceof PostRecyclerViewAdapter.PostCompactBaseViewHolder)) {
|
||||||
|
return makeMovementFlags(0, 0);
|
||||||
|
}
|
||||||
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
|
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
|
||||||
return makeMovementFlags(0, swipeFlags);
|
return makeMovementFlags(0, swipeFlags);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user