Swipe to view images in a gallery in Card Layout 2.

This commit is contained in:
Docile-Alligator 2022-11-13 18:25:30 +11:00
parent 2eaf8a8a01
commit ef1b14cc6a
5 changed files with 474 additions and 68 deletions

View File

@ -243,11 +243,6 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
} }
} }
@Override
public void toggleViewPagerSwipeLock(boolean lock) {
binding.accountSavedThingViewPager2.setUserInputEnabled(!lock);
}
@Override @Override
public void postLayoutSelected(int postLayout) { public void postLayoutSelected(int postLayout) {
if (sectionsPagerAdapter != null) { if (sectionsPagerAdapter != null) {

View File

@ -400,8 +400,4 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
public void unlockSwipeRightToGoBack() { public void unlockSwipeRightToGoBack() {
} }
public void toggleViewPagerSwipeLock(boolean lock) {
}
} }

View File

@ -87,6 +87,7 @@ import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface; import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager; import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.databinding.ItemPostCard2GalleryTypeBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding; import ml.docilealligator.infinityforreddit.databinding.ItemPostGalleryTypeBinding;
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostDetailFragment; import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostDetailFragment;
import ml.docilealligator.infinityforreddit.fragments.PostFragment; import ml.docilealligator.infinityforreddit.fragments.PostFragment;
@ -120,7 +121,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private static final int VIEW_TYPE_POST_GALLERY = 6; 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_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_WITH_PREVIEW_TYPE = 8;
private static final int VIEW_TYPE_POST_CARD_2_TEXT_TYPE = 9; 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 DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() { private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() {
@Override @Override
@ -429,8 +431,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE; return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE;
case Post.GIF_TYPE: case Post.GIF_TYPE:
case Post.IMAGE_TYPE: case Post.IMAGE_TYPE:
case Post.GALLERY_TYPE:
return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE; return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE;
case Post.GALLERY_TYPE:
return VIEW_TYPE_POST_CARD_2_GALLERY_TYPE;
case Post.LINK_TYPE: case Post.LINK_TYPE:
case Post.NO_PREVIEW_LINK_TYPE: case Post.NO_PREVIEW_LINK_TYPE:
switch (mDefaultLinkPostLayout) { switch (mDefaultLinkPostLayout) {
@ -479,6 +482,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return new PostCard2VideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_card_2_video_autoplay_legacy_controller : R.layout.item_post_card_2_video_autoplay, parent, false)); return new PostCard2VideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_card_2_video_autoplay_legacy_controller : R.layout.item_post_card_2_video_autoplay, parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE) { } else if (viewType == VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE) {
return new PostCard2WithPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_with_preview, parent, false)); return new PostCard2WithPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_with_preview, parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_2_GALLERY_TYPE) {
return new PostCard2GalleryTypeViewHolder(ItemPostCard2GalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else { } else {
//VIEW_TYPE_POST_CARD_2_TEXT_TYPE //VIEW_TYPE_POST_CARD_2_TEXT_TYPE
return new PostCard2TextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_text, parent, false)); return new PostCard2TextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_text, parent, false));
@ -858,25 +863,25 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
} }
} }
} else if (holder instanceof PostGalleryTypeViewHolder) { } else if (holder instanceof PostBaseGalleryTypeViewHolder) {
if (mDataSavingMode && mDisableImagePreview) { if (mDataSavingMode && mDisableImagePreview) {
((PostGalleryTypeViewHolder) holder).binding.noPreviewImageViewItemPostGalleryType.setVisibility(View.VISIBLE); ((PostBaseGalleryTypeViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
((PostGalleryTypeViewHolder) holder).binding.noPreviewImageViewItemPostGalleryType.setImageResource(R.drawable.ic_gallery_24dp); ((PostBaseGalleryTypeViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_gallery_24dp);
} else { } else {
((PostGalleryTypeViewHolder) holder).binding.galleryFrameLayoutItemPostGalleryType.setVisibility(View.VISIBLE); ((PostBaseGalleryTypeViewHolder) holder).frameLayout.setVisibility(View.VISIBLE);
((PostGalleryTypeViewHolder) holder).binding.imageIndexTextViewItemPostGalleryType.setText(mActivity.getString(R.string.image_index_in_gallery, 1, post.getGallery().size())); ((PostBaseGalleryTypeViewHolder) holder).imageIndexTextView.setText(mActivity.getString(R.string.image_index_in_gallery, 1, post.getGallery().size()));
Post.Preview preview = getSuitablePreview(post.getPreviews()); Post.Preview preview = getSuitablePreview(post.getPreviews());
if (preview != null) { if (preview != null) {
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) { if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
((PostGalleryTypeViewHolder) holder).adapter.setRatio(-1); ((PostBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
} else { } else {
((PostGalleryTypeViewHolder) holder).adapter.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth()); ((PostBaseGalleryTypeViewHolder) holder).adapter.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
} }
} else { } else {
((PostGalleryTypeViewHolder) holder).adapter.setRatio(-1); ((PostBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
} }
((PostGalleryTypeViewHolder) holder).adapter.setGalleryImages(post.getGallery()); ((PostBaseGalleryTypeViewHolder) holder).adapter.setGalleryImages(post.getGallery());
((PostGalleryTypeViewHolder) holder).adapter.setBlurImage( ((PostBaseGalleryTypeViewHolder) holder).adapter.setBlurImage(
(post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (post.isSpoiler() && mNeedBlurSpoiler)); (post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())) || (post.isSpoiler() && mNeedBlurSpoiler));
} }
} else if (holder instanceof PostTextTypeViewHolder) { } else if (holder instanceof PostTextTypeViewHolder) {
@ -1890,9 +1895,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
((PostWithPreviewTypeViewHolder) holder).linkTextView.setVisibility(View.GONE); ((PostWithPreviewTypeViewHolder) holder).linkTextView.setVisibility(View.GONE);
} else if (holder instanceof PostGalleryTypeViewHolder) { } else if (holder instanceof PostBaseGalleryTypeViewHolder) {
((PostGalleryTypeViewHolder) holder).binding.galleryFrameLayoutItemPostGalleryType.setVisibility(View.GONE); ((PostBaseGalleryTypeViewHolder) holder).frameLayout.setVisibility(View.GONE);
((PostGalleryTypeViewHolder) holder).binding.noPreviewImageViewItemPostGalleryType.setVisibility(View.GONE); ((PostBaseGalleryTypeViewHolder) holder).noPreviewImageView.setVisibility(View.GONE);
} else if (holder instanceof PostTextTypeViewHolder) { } else if (holder instanceof PostTextTypeViewHolder) {
((PostTextTypeViewHolder) holder).contentTextView.setText(""); ((PostTextTypeViewHolder) holder).contentTextView.setText("");
((PostTextTypeViewHolder) holder).contentTextView.setTextColor(mPostContentColor); ((PostTextTypeViewHolder) holder).contentTextView.setTextColor(mPostContentColor);
@ -3104,46 +3109,81 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
} }
public class PostGalleryTypeViewHolder extends PostBaseViewHolder { public class PostBaseGalleryTypeViewHolder extends PostBaseViewHolder {
ItemPostGalleryTypeBinding binding; FrameLayout frameLayout;
RecyclerView galleryRecyclerView;
CustomTextView imageIndexTextView;
ImageView noPreviewImageView;
PostGalleryTypeImageRecyclerViewAdapter adapter; PostGalleryTypeImageRecyclerViewAdapter adapter;
private boolean swipeLocked; private boolean swipeLocked;
PostGalleryTypeViewHolder(ItemPostGalleryTypeBinding binding) { PostBaseGalleryTypeViewHolder(View rootView,
super(binding.getRoot()); AspectRatioGifImageView iconGifImageView,
this.binding = binding; TextView subredditTextView,
TextView userTextView,
ImageView stickiedPostImageView,
TextView postTimeTextView,
TextView titleTextView,
CustomTextView typeTextView,
ImageView archivedImageView,
ImageView lockedImageView,
ImageView crosspostImageView,
CustomTextView nsfwTextView,
CustomTextView spoilerTextView,
CustomTextView flairTextView,
CustomTextView awardsTextView,
FrameLayout frameLayout,
RecyclerView galleryRecyclerView,
CustomTextView imageIndexTextView,
ImageView noPreviewImageView,
ConstraintLayout bottomConstraintLayout,
ImageView upvoteButton,
TextView scoreTextView,
ImageView downvoteButton,
TextView commentsCountTextView,
ImageView saveButton,
ImageView shareButton,
boolean itemViewIsNotCardView) {
super(rootView);
setBaseView( setBaseView(
binding.iconGifImageViewItemPostGalleryType, iconGifImageView,
binding.subredditNameTextViewItemPostGalleryType, subredditTextView,
binding.userTextViewItemPostGalleryType, userTextView,
binding.stickiedPostImageViewItemPostGalleryType, stickiedPostImageView,
binding.postTimeTextViewItemPostGalleryType, postTimeTextView,
binding.titleTextViewItemPostGalleryType, titleTextView,
binding.typeTextViewItemPostGalleryType, typeTextView,
binding.archivedImageViewItemPostGalleryType, archivedImageView,
binding.lockedImageViewItemPostGalleryType, lockedImageView,
binding.crosspostImageViewItemPostGalleryType, crosspostImageView,
binding.nsfwTextViewItemPostGalleryType, nsfwTextView,
binding.spoilerTextViewItemPostGalleryType, spoilerTextView,
binding.flairTextViewItemPostGalleryType, flairTextView,
binding.awardsTextViewItemPostGalleryType, awardsTextView,
binding.bottomConstraintLayoutItemPostGalleryType, bottomConstraintLayout,
binding.upvoteButtonItemPostGalleryType, upvoteButton,
binding.scoreTextViewItemPostGalleryType, scoreTextView,
binding.downvoteButtonItemPostGalleryType, downvoteButton,
binding.commentsCountTextViewItemPostGalleryType, commentsCountTextView,
binding.saveButtonItemPostGalleryType, saveButton,
binding.shareButtonItemPostGalleryType); shareButton,
itemViewIsNotCardView);
binding.imageIndexTextViewItemPostGalleryType.setTextColor(mMediaIndicatorIconTint); this.frameLayout = frameLayout;
binding.imageIndexTextViewItemPostGalleryType.setBackgroundColor(mMediaIndicatorBackgroundColor); this.galleryRecyclerView = galleryRecyclerView;
binding.imageIndexTextViewItemPostGalleryType.setBorderColor(mMediaIndicatorBackgroundColor); this.imageIndexTextView = imageIndexTextView;
this.noPreviewImageView = noPreviewImageView;
imageIndexTextView.setTextColor(mMediaIndicatorIconTint);
imageIndexTextView.setBackgroundColor(mMediaIndicatorBackgroundColor);
imageIndexTextView.setBorderColor(mMediaIndicatorBackgroundColor);
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface, adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale); mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
binding.galleryRecyclerViewItemPostGalleryType.setAdapter(adapter); galleryRecyclerView.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(binding.galleryRecyclerViewItemPostGalleryType); new PagerSnapHelper().attachToRecyclerView(galleryRecyclerView);
binding.galleryRecyclerViewItemPostGalleryType.setRecycledViewPool(mGalleryRecycledViewPool); galleryRecyclerView.setRecycledViewPool(mGalleryRecycledViewPool);
SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager( SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager(
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() { mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() {
@Override @Override
@ -3160,12 +3200,11 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override @Override
public void setSwipeLocked(boolean swipeLocked) { public void setSwipeLocked(boolean swipeLocked) {
PostGalleryTypeViewHolder.this.swipeLocked = swipeLocked; PostBaseGalleryTypeViewHolder.this.swipeLocked = swipeLocked;
mActivity.toggleViewPagerSwipeLock(swipeLocked);
} }
}); });
binding.galleryRecyclerViewItemPostGalleryType.setLayoutManager(layoutManager); galleryRecyclerView.setLayoutManager(layoutManager);
binding.galleryRecyclerViewItemPostGalleryType.addOnScrollListener(new RecyclerView.OnScrollListener() { galleryRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState); super.onScrollStateChanged(recyclerView, newState);
@ -3174,10 +3213,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
@Override @Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
binding.imageIndexTextViewItemPostGalleryType.setText(mActivity.getString(R.string.image_index_in_gallery, layoutManager.findFirstVisibleItemPosition() + 1, post.getGallery().size())); imageIndexTextView.setText(mActivity.getString(R.string.image_index_in_gallery, layoutManager.findFirstVisibleItemPosition() + 1, post.getGallery().size()));
} }
}); });
binding.galleryRecyclerViewItemPostGalleryType.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() { galleryRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
private float downX; private float downX;
private float downY; private float downY;
private boolean dragged; private boolean dragged;
@ -3197,7 +3236,6 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (!dragged) { if (!dragged) {
int index = layoutManager.findFirstVisibleItemPosition(); int index = layoutManager.findFirstVisibleItemPosition();
int position = getBindingAdapterPosition(); int position = getBindingAdapterPosition();
@ -3227,16 +3265,16 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
}); });
binding.getRoot().setOnTouchListener((view, motionEvent) -> { rootView.setOnTouchListener((view, motionEvent) -> {
swipeLocked = false; swipeLocked = false;
return false; return false;
}); });
binding.bottomConstraintLayoutItemPostGalleryType.setOnTouchListener((view, motionEvent) -> { bottomConstraintLayout.setOnTouchListener((view, motionEvent) -> {
swipeLocked = false; swipeLocked = false;
return false; return false;
}); });
binding.noPreviewImageViewItemPostGalleryType.setOnClickListener(view -> { noPreviewImageView.setOnClickListener(view -> {
int position = getBindingAdapterPosition(); int position = getBindingAdapterPosition();
if (position < 0) { if (position < 0) {
return; return;
@ -3253,6 +3291,39 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
} }
public class PostGalleryTypeViewHolder extends PostBaseGalleryTypeViewHolder {
PostGalleryTypeViewHolder(ItemPostGalleryTypeBinding binding) {
super(binding.getRoot(),
binding.iconGifImageViewItemPostGalleryType,
binding.subredditNameTextViewItemPostGalleryType,
binding.userTextViewItemPostGalleryType,
binding.stickiedPostImageViewItemPostGalleryType,
binding.postTimeTextViewItemPostGalleryType,
binding.titleTextViewItemPostGalleryType,
binding.typeTextViewItemPostGalleryType,
binding.archivedImageViewItemPostGalleryType,
binding.lockedImageViewItemPostGalleryType,
binding.crosspostImageViewItemPostGalleryType,
binding.nsfwTextViewItemPostGalleryType,
binding.spoilerTextViewItemPostGalleryType,
binding.flairTextViewItemPostGalleryType,
binding.awardsTextViewItemPostGalleryType,
binding.galleryFrameLayoutItemPostGalleryType,
binding.galleryRecyclerViewItemPostGalleryType,
binding.imageIndexTextViewItemPostGalleryType,
binding.noPreviewImageViewItemPostGalleryType,
binding.bottomConstraintLayoutItemPostGalleryType,
binding.upvoteButtonItemPostGalleryType,
binding.scoreTextViewItemPostGalleryType,
binding.downvoteButtonItemPostGalleryType,
binding.commentsCountTextViewItemPostGalleryType,
binding.saveButtonItemPostGalleryType,
binding.shareButtonItemPostGalleryType,
false);
}
}
class PostTextTypeViewHolder extends PostBaseViewHolder { class PostTextTypeViewHolder extends PostBaseViewHolder {
@BindView(R.id.icon_gif_image_view_item_post_text_type) @BindView(R.id.icon_gif_image_view_item_post_text_type)
AspectRatioGifImageView iconGifImageView; AspectRatioGifImageView iconGifImageView;
@ -4571,6 +4642,41 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} }
} }
public class PostCard2GalleryTypeViewHolder extends PostBaseGalleryTypeViewHolder {
PostCard2GalleryTypeViewHolder(ItemPostCard2GalleryTypeBinding binding) {
super(binding.getRoot(),
binding.iconGifImageViewItemPostCard2GalleryType,
binding.subredditNameTextViewItemPostCard2GalleryType,
binding.userTextViewItemPostCard2GalleryType,
binding.stickiedPostImageViewItemPostCard2GalleryType,
binding.postTimeTextViewItemPostCard2GalleryType,
binding.titleTextViewItemPostCard2GalleryType,
binding.typeTextViewItemPostCard2GalleryType,
binding.archivedImageViewItemPostCard2GalleryType,
binding.lockedImageViewItemPostCard2GalleryType,
binding.crosspostImageViewItemPostCard2GalleryType,
binding.nsfwTextViewItemPostCard2GalleryType,
binding.spoilerCustomTextViewItemPostCard2GalleryType,
binding.flairCustomTextViewItemPostCard2GalleryType,
binding.awardsTextViewItemPostCard2GalleryType,
binding.galleryFrameLayoutItemPostCard2GalleryType,
binding.galleryRecyclerViewItemPostCard2GalleryType,
binding.imageIndexTextViewItemPostCard2GalleryType,
binding.noPreviewImageViewItemPostCard2GalleryType,
binding.bottomConstraintLayoutItemPostCard2GalleryType,
binding.upvoteButtonItemPostCard2GalleryType,
binding.scoreTextViewItemPostCard2GalleryType,
binding.downvoteButtonItemPostCard2GalleryType,
binding.commentsCountTextViewItemPostCard2GalleryType,
binding.saveButtonItemPostCard2GalleryType,
binding.shareButtonItemPostCard2GalleryType,
true);
binding.dividerItemPostCard2GalleryType.setBackgroundColor(mDividerColor);
}
}
class PostCard2TextTypeViewHolder extends PostBaseViewHolder { class PostCard2TextTypeViewHolder extends PostBaseViewHolder {
@BindView(R.id.icon_gif_image_view_item_post_card_2_text) @BindView(R.id.icon_gif_image_view_item_post_card_2_text)
AspectRatioGifImageView iconGifImageView; AspectRatioGifImageView iconGifImageView;

View File

@ -1058,8 +1058,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (!(viewHolder instanceof PostRecyclerViewAdapter.PostBaseViewHolder) && if (!(viewHolder instanceof PostRecyclerViewAdapter.PostBaseViewHolder) &&
!(viewHolder instanceof PostRecyclerViewAdapter.PostCompactBaseViewHolder)) { !(viewHolder instanceof PostRecyclerViewAdapter.PostCompactBaseViewHolder)) {
return makeMovementFlags(0, 0); return makeMovementFlags(0, 0);
} else if (viewHolder instanceof PostRecyclerViewAdapter.PostGalleryTypeViewHolder) { } else if (viewHolder instanceof PostRecyclerViewAdapter.PostBaseGalleryTypeViewHolder) {
if (((PostRecyclerViewAdapter.PostGalleryTypeViewHolder) viewHolder).isSwipeLocked()) { if (((PostRecyclerViewAdapter.PostBaseGalleryTypeViewHolder) viewHolder).isSwipeLocked()) {
return makeMovementFlags(0, 0); return makeMovementFlags(0, 0);
} }

View File

@ -0,0 +1,309 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:paddingTop="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:cardElevation="2dp"
app:cardCornerRadius="8dp"
style="?attr/materialCardViewElevatedStyle">
<FrameLayout
android:id="@+id/gallery_frame_layout_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/gallery_recycler_view_item_post_card_2_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_card_2_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/no_preview_image_view_item_post_card_2_gallery_type"
android:layout_width="match_parent"
android:layout_height="150dp"
android:scaleType="center"
android:visibility="gone" />
</com.google.android.material.card.MaterialCardView>
<TextView
android:id="@+id/title_text_view_item_post_card_2_gallery_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textSize="?attr/title_font_18"
android:fontFamily="?attr/title_font_family" />
<com.nex3z.flowlayout.FlowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:flRowVerticalGravity="center"
app:flChildSpacing="16dp"
app:flChildSpacingForLastRow="align"
app:flRowSpacing="8dp">
<com.libRG.CustomTextView
android:id="@+id/type_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="@string/gallery"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/spoiler"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="@string/nsfw"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/awards_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<ImageView
android:id="@+id/archived_image_view_item_post_card_2_gallery_type"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_archive_outline"
android:visibility="gone" />
<ImageView
android:id="@+id/locked_image_view_item_post_card_2_gallery_type"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ic_outline_lock_24dp"
android:visibility="gone" />
<ImageView
android:id="@+id/crosspost_image_view_item_post_card_2_gallery_type"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/crosspost"
android:visibility="gone" />
<ImageView
android:id="@+id/stickied_post_image_view_item_post_card_2_gallery_type"
android:layout_width="24dp"
android:layout_height="24dp"
android:visibility="gone"
tools:visibility="visible" />
<TextView
android:id="@+id/link_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone" />
<TextView
android:id="@+id/post_time_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</com.nex3z.flowlayout.FlowLayout>
<com.nex3z.flowlayout.FlowLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:flRowVerticalGravity="center"
app:flChildSpacing="16dp"
app:flChildSpacingForLastRow="align"
app:flRowSpacing="8dp">
<ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView
android:id="@+id/icon_gif_image_view_item_post_card_2_gallery_type"
android:layout_width="24dp"
android:layout_height="24dp" />
<TextView
android:id="@+id/subreddit_name_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
<TextView
android:id="@+id/user_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</com.nex3z.flowlayout.FlowLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bottom_constraint_layout_item_post_card_2_gallery_type"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/upvote_button_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:src="@drawable/ic_arrow_upward_grey_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/score_text_view_item_post_card_2_gallery_type"
android:layout_width="64dp"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="?attr/font_12"
android:textStyle="bold"
android:fontFamily="?attr/font_family"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/upvote_button_item_post_card_2_gallery_type" />
<ImageView
android:id="@+id/downvote_button_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:src="@drawable/ic_arrow_downward_grey_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_card_2_gallery_type" />
<TextView
android:id="@+id/comments_count_text_view_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:gravity="center_vertical"
android:textSize="?attr/font_12"
android:textStyle="bold"
android:fontFamily="?attr/font_family"
android:drawableStart="@drawable/ic_comment_grey_24dp"
android:drawablePadding="12dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/downvote_button_item_post_card_2_gallery_type" />
<ImageView
android:id="@+id/save_button_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/comments_count_text_view_item_post_card_2_gallery_type"
app:layout_constraintEnd_toStartOf="@id/share_button_item_post_card_2_gallery_type" />
<ImageView
android:id="@+id/share_button_item_post_card_2_gallery_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dp"
android:src="@drawable/ic_share_grey_24dp"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/divider_item_post_card_2_gallery_type"
android:layout_width="match_parent"
android:layout_height="1dp"
android:paddingBottom="8dp" />
</LinearLayout>