mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-27 19:38:22 +01:00
Swipe to see images in gallery in gallery layout.
This commit is contained in:
parent
c44fecb3f2
commit
8520c0c8ad
@ -67,6 +67,17 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
}
|
||||
((ImageViewHolder) holder).binding.errorTextViewItemGalleryImageInPostFeed.setVisibility(View.GONE);
|
||||
((ImageViewHolder) holder).binding.progressBarItemGalleryImageInPostFeed.setVisibility(View.VISIBLE);
|
||||
|
||||
((ImageViewHolder) holder).binding.imageViewItemGalleryImageInPostFeed.setRatio(ratio);
|
||||
|
||||
((ImageViewHolder) holder).binding.imageViewItemGalleryImageInPostFeed.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((ImageViewHolder) holder).binding.imageViewItemGalleryImageInPostFeed.removeOnLayoutChangeListener(this);
|
||||
loadImage(((ImageViewHolder) holder));
|
||||
}
|
||||
});
|
||||
|
||||
loadImage((ImageViewHolder) holder);
|
||||
}
|
||||
}
|
||||
@ -82,7 +93,6 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
|
||||
}
|
||||
|
||||
private void loadImage(ImageViewHolder holder) {
|
||||
holder.binding.imageViewItemGalleryImageInPostFeed.setRatio(ratio);
|
||||
RequestBuilder<Drawable> imageRequestBuilder = glide.load(galleryImages.get(holder.getBindingAdapterPosition()).url).listener(new RequestListener<>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
|
@ -11,7 +11,6 @@ import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@ -88,6 +87,7 @@ import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
|
||||
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
|
||||
import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding;
|
||||
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryGalleryTypeBinding;
|
||||
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding;
|
||||
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostDetailFragment;
|
||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||
@ -119,10 +119,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
private static final int VIEW_TYPE_POST_CARD_TEXT_TYPE = 4;
|
||||
private static final int VIEW_TYPE_POST_COMPACT = 5;
|
||||
private static final int VIEW_TYPE_POST_GALLERY = 6;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_VIDEO_AUTOPLAY_TYPE = 7;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE = 8;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_GALLERY_TYPE = 9;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_TEXT_TYPE = 10;
|
||||
private static final int VIEW_TYPE_POST_GALLERY_GALLERY_TYPE = 7;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_VIDEO_AUTOPLAY_TYPE = 8;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE = 9;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_GALLERY_TYPE = 10;
|
||||
private static final int VIEW_TYPE_POST_CARD_2_TEXT_TYPE = 11;
|
||||
|
||||
private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() {
|
||||
@Override
|
||||
@ -416,7 +417,16 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
return VIEW_TYPE_POST_COMPACT;
|
||||
} else if (mPostLayout == SharedPreferencesUtils.POST_LAYOUT_GALLERY) {
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
if (post.getPostType() == Post.GALLERY_TYPE) {
|
||||
return VIEW_TYPE_POST_GALLERY_GALLERY_TYPE;
|
||||
} else {
|
||||
return VIEW_TYPE_POST_GALLERY;
|
||||
}
|
||||
} else {
|
||||
return VIEW_TYPE_POST_GALLERY;
|
||||
}
|
||||
} else {
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
@ -475,6 +485,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
} else if (viewType == VIEW_TYPE_POST_GALLERY) {
|
||||
return new PostGalleryViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_gallery, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_GALLERY_GALLERY_TYPE) {
|
||||
return new PostGalleryGalleryTypeViewHolder(ItemPostGalleryGalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_2_VIDEO_AUTOPLAY_TYPE) {
|
||||
if (mDataSavingMode) {
|
||||
return new PostCard2WithPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_with_preview, parent, false));
|
||||
@ -1398,6 +1410,21 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
|
||||
}
|
||||
|
||||
if (mDataSavingMode && (mDisableImagePreview ||
|
||||
((post.getPostType() == Post.VIDEO_TYPE || post.getPostType() == Post.GIF_TYPE) && mOnlyDisablePreviewInVideoAndGifPosts))) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
} else if (post.getPostType() == Post.IMAGE_TYPE || post.getPostType() == Post.GIF_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
} else if (post.getPostType() == Post.LINK_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
|
||||
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
}
|
||||
} else {
|
||||
switch (post.getPostType()) {
|
||||
case Post.IMAGE_TYPE: {
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
@ -1423,16 +1450,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
});
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
} else if (post.getPostType() == Post.IMAGE_TYPE || post.getPostType() == Post.GIF_TYPE) {
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
} else if (post.getPostType() == Post.LINK_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
|
||||
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
}
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
}
|
||||
break;
|
||||
@ -1542,36 +1559,39 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).titleTextView.setText(post.getTitle());
|
||||
break;
|
||||
}
|
||||
case Post.GALLERY_TYPE: {
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
((PostGalleryViewHolder) holder).preview = preview;
|
||||
if (preview != null) {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_gallery_24dp));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (holder instanceof PostGalleryBaseGalleryTypeViewHolder) {
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).post = post;
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).currentPosition = position;
|
||||
if (post.isRead()) {
|
||||
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
|
||||
}
|
||||
|
||||
if (mDataSavingMode && mDisableImagePreview) {
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
} else {
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).preview = preview;
|
||||
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).frameLayout.setVisibility(View.VISIBLE);
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).imageIndexTextView.setText(mActivity.getString(R.string.image_index_in_gallery, 1, post.getGallery().size()));
|
||||
if (preview != null) {
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
}
|
||||
break;
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
|
||||
}
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setGalleryImages(post.getGallery());
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setBlurImage(
|
||||
(post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (post.isSpoiler() && mNeedBlurSpoiler));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1990,6 +2010,17 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).errorTextView.setVisibility(View.GONE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.GONE);
|
||||
} else if (holder instanceof PostGalleryBaseGalleryTypeViewHolder) {
|
||||
if (mMarkPostsAsReadOnScroll) {
|
||||
int position = ((PostGalleryBaseGalleryTypeViewHolder) holder).currentPosition;
|
||||
if (position < super.getItemCount() && position >= 0) {
|
||||
Post post = getItem(position);
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).markPostRead(post, false);
|
||||
}
|
||||
}
|
||||
holder.itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).frameLayout.setVisibility(View.GONE);
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).noPreviewImageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3179,6 +3210,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
imageIndexTextView.setBackgroundColor(mMediaIndicatorBackgroundColor);
|
||||
imageIndexTextView.setBorderColor(mMediaIndicatorBackgroundColor);
|
||||
|
||||
noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
|
||||
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
|
||||
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
|
||||
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
|
||||
galleryRecyclerView.setAdapter(adapter);
|
||||
@ -4236,6 +4270,199 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
}
|
||||
|
||||
class PostGalleryBaseGalleryTypeViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
FrameLayout frameLayout;
|
||||
RecyclerView recyclerView;
|
||||
CustomTextView imageIndexTextView;
|
||||
ImageView noPreviewImageView;
|
||||
|
||||
PostGalleryTypeImageRecyclerViewAdapter adapter;
|
||||
private boolean swipeLocked;
|
||||
|
||||
Post post;
|
||||
Post.Preview preview;
|
||||
|
||||
int currentPosition;
|
||||
|
||||
public PostGalleryBaseGalleryTypeViewHolder(@NonNull View itemView,
|
||||
FrameLayout frameLayout,
|
||||
RecyclerView recyclerView,
|
||||
CustomTextView imageIndexTextView,
|
||||
ImageView noPreviewImageView) {
|
||||
super(itemView);
|
||||
|
||||
this.frameLayout = frameLayout;
|
||||
this.recyclerView = recyclerView;
|
||||
this.imageIndexTextView = imageIndexTextView;
|
||||
this.noPreviewImageView = noPreviewImageView;
|
||||
|
||||
if (mActivity.typeface != null) {
|
||||
imageIndexTextView.setTypeface(mActivity.typeface);
|
||||
}
|
||||
|
||||
itemView.setBackgroundTintList(ColorStateList.valueOf(mCardViewBackgroundColor));
|
||||
noPreviewImageView.setBackgroundColor(mNoPreviewPostTypeBackgroundColor);
|
||||
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
|
||||
imageIndexTextView.setTextColor(mMediaIndicatorIconTint);
|
||||
imageIndexTextView.setBackgroundColor(mMediaIndicatorBackgroundColor);
|
||||
imageIndexTextView.setBorderColor(mMediaIndicatorBackgroundColor);
|
||||
|
||||
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
|
||||
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
|
||||
recyclerView.setAdapter(adapter);
|
||||
new PagerSnapHelper().attachToRecyclerView(recyclerView);
|
||||
recyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
|
||||
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);
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
imageIndexTextView.setText(mActivity.getString(R.string.image_index_in_gallery, layoutManager.findFirstVisibleItemPosition() + 1, post.getGallery().size()));
|
||||
}
|
||||
});
|
||||
recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
|
||||
private float downX;
|
||||
private float downY;
|
||||
private boolean dragged;
|
||||
private long downTime;
|
||||
private final int minTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
|
||||
private final int longClickThreshold = ViewConfiguration.getLongPressTimeout();
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
||||
int action = e.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
downX = e.getRawX();
|
||||
downY = e.getRawY();
|
||||
downTime = System.currentTimeMillis();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if(Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
|
||||
dragged = true;
|
||||
}
|
||||
if (!dragged) {
|
||||
if (System.currentTimeMillis() - downTime >= longClickThreshold) {
|
||||
onLongClick();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (!dragged) {
|
||||
if (System.currentTimeMillis() - downTime < longClickThreshold) {
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
downX = 0;
|
||||
downY = 0;
|
||||
dragged = false;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
noPreviewImageView.setOnClickListener(view -> {
|
||||
onClick();
|
||||
});
|
||||
|
||||
noPreviewImageView.setOnLongClickListener(view -> onLongClick());
|
||||
}
|
||||
|
||||
void onClick() {
|
||||
int position = getBindingAdapterPosition();
|
||||
if (position >= 0 && canStartActivity) {
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
markPostRead(post, true);
|
||||
|
||||
if (post.getPostType() == Post.TEXT_TYPE || !mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
|
||||
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
||||
} else {
|
||||
openMedia(post);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean onLongClick() {
|
||||
int position = getBindingAdapterPosition();
|
||||
if (position >= 0 && canStartActivity) {
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
markPostRead(post, true);
|
||||
|
||||
if (post.getPostType() == Post.TEXT_TYPE || mSharedPreferences.getBoolean(SharedPreferencesUtils.CLICK_TO_SHOW_MEDIA_IN_GALLERY_LAYOUT, false)) {
|
||||
openViewPostDetailActivity(post, getBindingAdapterPosition());
|
||||
} else {
|
||||
openMedia(post);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void markPostRead(Post post, boolean changePostItemColor) {
|
||||
if (mAccessToken != null && !post.isRead() && mMarkPostsAsRead) {
|
||||
post.markAsRead(true);
|
||||
if (changePostItemColor) {
|
||||
itemView.setBackgroundTintList(ColorStateList.valueOf(mReadPostCardViewBackgroundColor));
|
||||
}
|
||||
if (mActivity != null && mActivity instanceof MarkPostAsReadInterface) {
|
||||
((MarkPostAsReadInterface) mActivity).markPostAsRead(post);
|
||||
mFragment.markPostAsRead(post);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PostGalleryGalleryTypeViewHolder extends PostGalleryBaseGalleryTypeViewHolder {
|
||||
|
||||
public PostGalleryGalleryTypeViewHolder(@NonNull ItemPostGalleryGalleryTypeBinding binding) {
|
||||
super(binding.getRoot(), binding.galleryFrameLayoutItemPostGalleryGalleryType,
|
||||
binding.galleryRecyclerViewItemPostGalleryGalleryType, binding.imageIndexTextViewItemPostGalleryGalleryType,
|
||||
binding.imageViewNoPreviewItemPostGalleryGalleryType);
|
||||
}
|
||||
}
|
||||
|
||||
class PostCard2VideoAutoplayViewHolder extends PostBaseViewHolder implements ToroPlayer {
|
||||
@BindView(R.id.icon_gif_image_view_item_post_card_2_video_autoplay)
|
||||
AspectRatioGifImageView iconGifImageView;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/gallery_frame_layout_item_post_card_2_gallery_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
|
47
app/src/main/res/layout/item_post_gallery_gallery_type.xml
Normal file
47
app/src/main/res/layout/item_post_gallery_gallery_type.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:cardElevation="2dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
style="?attr/materialCardViewElevatedStyle">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/gallery_frame_layout_item_post_gallery_gallery_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gallery_recycler_view_item_post_gallery_gallery_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/image_index_text_view_item_post_gallery_gallery_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:textSize="?attr/font_12"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="4dp"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_no_preview_item_post_gallery_gallery_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:scaleType="center"
|
||||
android:background="@drawable/thumbnail_compact_layout_rounded_edge"
|
||||
android:visibility="gone" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
@ -198,7 +198,7 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/gallery_frame_layout_item_post_gallery_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user