mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-06 18:57:26 +01:00
Show the current image index in gallery in PostFragment.
This commit is contained in:
parent
03a2784fb8
commit
b85ed3c867
@ -1,7 +1,6 @@
|
||||
package ml.docilealligator.infinityforreddit;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
@ -11,9 +11,7 @@ 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;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
@ -863,7 +861,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryTypeViewHolder) holder).binding.noPreviewImageViewItemPostGalleryType.setVisibility(View.VISIBLE);
|
||||
((PostGalleryTypeViewHolder) holder).binding.noPreviewImageViewItemPostGalleryType.setImageResource(R.drawable.ic_gallery_24dp);
|
||||
} else {
|
||||
((PostGalleryTypeViewHolder) holder).binding.galleryRecyclerViewItemPostGalleryType.setVisibility(View.VISIBLE);
|
||||
((PostGalleryTypeViewHolder) holder).binding.galleryFrameLayoutItemPostGalleryType.setVisibility(View.VISIBLE);
|
||||
((PostGalleryTypeViewHolder) holder).binding.imageIndexTextViewItemPostGalleryType.setText(mActivity.getString(R.string.image_index_in_gallery, 1, post.getGallery().size()));
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (preview != null) {
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
@ -1890,7 +1889,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
|
||||
((PostWithPreviewTypeViewHolder) holder).linkTextView.setVisibility(View.GONE);
|
||||
} else if (holder instanceof PostGalleryTypeViewHolder) {
|
||||
((PostGalleryTypeViewHolder) holder).binding.galleryRecyclerViewItemPostGalleryType.setVisibility(View.GONE);
|
||||
((PostGalleryTypeViewHolder) holder).binding.galleryFrameLayoutItemPostGalleryType.setVisibility(View.GONE);
|
||||
((PostGalleryTypeViewHolder) holder).binding.noPreviewImageViewItemPostGalleryType.setVisibility(View.GONE);
|
||||
} else if (holder instanceof PostTextTypeViewHolder) {
|
||||
((PostTextTypeViewHolder) holder).contentTextView.setText("");
|
||||
@ -3134,6 +3133,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
binding.saveButtonItemPostGalleryType,
|
||||
binding.shareButtonItemPostGalleryType);
|
||||
|
||||
binding.imageIndexTextViewItemPostGalleryType.setTextColor(mMediaIndicatorIconTint);
|
||||
binding.imageIndexTextViewItemPostGalleryType.setBackgroundColor(mMediaIndicatorBackgroundColor);
|
||||
binding.imageIndexTextViewItemPostGalleryType.setBorderColor(mMediaIndicatorBackgroundColor);
|
||||
|
||||
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
|
||||
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
|
||||
galleryItemIndex -> {
|
||||
@ -3149,7 +3152,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
binding.galleryRecyclerViewItemPostGalleryType.setAdapter(adapter);
|
||||
new PagerSnapHelper().attachToRecyclerView(binding.galleryRecyclerViewItemPostGalleryType);
|
||||
binding.galleryRecyclerViewItemPostGalleryType.setRecycledViewPool(mGalleryRecycledViewPool);
|
||||
binding.galleryRecyclerViewItemPostGalleryType.setLayoutManager(new SwipeLockLinearLayoutManager(
|
||||
SwipeLockLinearLayoutManager layoutManager = new SwipeLockLinearLayoutManager(
|
||||
mActivity, RecyclerView.HORIZONTAL, false, new SwipeLockInterface() {
|
||||
@Override
|
||||
public void lockSwipe() {
|
||||
@ -3167,17 +3170,28 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
public void setSwipeLocked(boolean swipeLocked) {
|
||||
PostGalleryTypeViewHolder.this.swipeLocked = swipeLocked;
|
||||
}
|
||||
}));
|
||||
});
|
||||
binding.galleryRecyclerViewItemPostGalleryType.setLayoutManager(layoutManager);
|
||||
binding.galleryRecyclerViewItemPostGalleryType.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);
|
||||
binding.imageIndexTextViewItemPostGalleryType.setText(mActivity.getString(R.string.image_index_in_gallery, layoutManager.findFirstVisibleItemPosition() + 1, post.getGallery().size()));
|
||||
}
|
||||
});
|
||||
|
||||
binding.getRoot().setOnTouchListener((view, motionEvent) -> {
|
||||
swipeLocked = false;
|
||||
return false;
|
||||
});
|
||||
binding.bottomConstraintLayoutItemPostGalleryType.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
swipeLocked = false;
|
||||
return false;
|
||||
}
|
||||
binding.bottomConstraintLayoutItemPostGalleryType.setOnTouchListener((view, motionEvent) -> {
|
||||
swipeLocked = false;
|
||||
return false;
|
||||
});
|
||||
|
||||
binding.noPreviewImageViewItemPostGalleryType.setOnClickListener(view -> {
|
||||
|
@ -38,7 +38,7 @@ public class SwipeLockFrameLayout extends FrameLayout implements SwipeLockView {
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
updateSwipeLock(ev);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility") // we are just listening to touch events
|
||||
|
@ -196,11 +196,31 @@
|
||||
|
||||
</com.nex3z.flowlayout.FlowLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gallery_recycler_view_item_post_gallery_type"
|
||||
android:layout_width="match_parent"
|
||||
<FrameLayout
|
||||
android:id="@+id/gallery_frame_layout_item_post_gallery_type"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
android:visibility="gone">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/gallery_recycler_view_item_post_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_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_gallery_type"
|
||||
|
@ -25,12 +25,12 @@
|
||||
<string name="edit_multi_reddit_activity_label">Edit Multireddit</string>
|
||||
<string name="selected_subeddits_activity_label">Selected Subreddits</string>
|
||||
<string name="report_activity_label">Report</string>
|
||||
<string name="view_imgur_media_activity_image_label">Image %1$,d/%2$d</string>
|
||||
<string name="view_imgur_media_activity_video_label">Video %1$,d/%2$d</string>
|
||||
<string name="view_imgur_media_activity_image_label">Image %1$d/%2$d</string>
|
||||
<string name="view_imgur_media_activity_video_label">Video %1$d/%2$d</string>
|
||||
<string name="send_private_message_activity_label">Send PM</string>
|
||||
<string name="view_reddit_gallery_activity_image_label">Image %1$,d/%2$d</string>
|
||||
<string name="view_reddit_gallery_activity_gif_label">Gif %1$,d/%2$d</string>
|
||||
<string name="view_reddit_gallery_activity_video_label">Video %1$,d/%2$d</string>
|
||||
<string name="view_reddit_gallery_activity_image_label">Image %1$d/%2$d</string>
|
||||
<string name="view_reddit_gallery_activity_gif_label">Gif %1$d/%2$d</string>
|
||||
<string name="view_reddit_gallery_activity_video_label">Video %1$d/%2$d</string>
|
||||
<string name="submit_crosspost_activity_label">Crosspost</string>
|
||||
<string name="give_award_activity_label">Give Award</string>
|
||||
<string name="subreddit_filter_popular_and_all_activity_label">r/all and r/popular</string>
|
||||
@ -201,7 +201,7 @@
|
||||
<string name="title_required">The post needs a good title</string>
|
||||
<string name="link_required">Hey where is the link?</string>
|
||||
<string name="select_an_image">Please select an image first</string>
|
||||
<string name="voting_length">Voting length: %1$,d days</string>
|
||||
<string name="voting_length">Voting length: %1$d days</string>
|
||||
<string name="posting">Posting</string>
|
||||
<string name="post_failed">Could not post it</string>
|
||||
<string name="error_processing_image">Error processing image</string>
|
||||
@ -358,7 +358,7 @@
|
||||
<string name="notification_summary_message">New Message</string>
|
||||
<string name="notification_summary_subreddit">Subreddit</string>
|
||||
<string name="notification_summary_award">Award</string>
|
||||
<string name="notification_new_messages">%1$,d New Messages</string>
|
||||
<string name="notification_new_messages">%1$d New Messages</string>
|
||||
|
||||
<string name="label_account">Account</string>
|
||||
<string name="label_reddit">Reddit</string>
|
||||
@ -382,9 +382,9 @@
|
||||
<string name="settings_mute_autoplaying_videos_title">Mute Autoplaying Videos</string>
|
||||
<string name="settings_autoplay_nsfw_videos_title">Autoplay NSFW Videos</string>
|
||||
<string name="settings_start_autoplay_visible_area_offset_portrait_title">Autoplay Videos Visible Area Offset (Portrait)</string>
|
||||
<string name="settings_start_autoplay_visible_area_offset_portrait_summary">Start autoplaying videos when %1$,d%% of them are visible</string>
|
||||
<string name="settings_start_autoplay_visible_area_offset_portrait_summary">Start autoplaying videos when %1$d%% of them are visible</string>
|
||||
<string name="settings_start_autoplay_visible_area_offset_landscape_title">Autoplay Videos Visible Area Offset (Landscape)</string>
|
||||
<string name="settings_start_autoplay_visible_area_offset_landscape_summary">Start autoplaying videos when %1$,d%% of them are visible</string>
|
||||
<string name="settings_start_autoplay_visible_area_offset_landscape_summary">Start autoplaying videos when %1$d%% of them are visible</string>
|
||||
<string name="settings_immersive_interface_title">Immersive Interface</string>
|
||||
<string name="settings_immersive_interface_summary">Does Not Apply to All Pages</string>
|
||||
<string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string>
|
||||
@ -636,7 +636,7 @@
|
||||
<string name="settings_hide_text_post_content">Hide Text Post Content</string>
|
||||
<string name="settings_hide_comment_awards_title">Hide Comment Awards</string>
|
||||
<string name="settings_show_fewer_toolbar_options_threshold_title">Show Fewer Toolbar Options Starting From</string>
|
||||
<string name="settings_show_fewer_toolbar_options_threshold_summary">Level %1$,d</string>
|
||||
<string name="settings_show_fewer_toolbar_options_threshold_summary">Level %1$d</string>
|
||||
<string name="settings_show_author_avatar_title">Show Author Avatar</string>
|
||||
<string name="settings_reddit_user_agreement_title">Reddit User Agreement</string>
|
||||
<string name="settings_always_show_child_comment_count_title">Always Show the Number of Child Comments</string>
|
||||
@ -688,15 +688,15 @@
|
||||
|
||||
<string name="elapsed_time_just_now">Just Now</string>
|
||||
<string name="elapsed_time_a_minute_ago">1 Minute</string>
|
||||
<string name="elapsed_time_minutes_ago">%1$,d Minutes</string>
|
||||
<string name="elapsed_time_minutes_ago">%1$d Minutes</string>
|
||||
<string name="elapsed_time_an_hour_ago">1 Hour</string>
|
||||
<string name="elapsed_time_hours_ago">%1$,d Hours</string>
|
||||
<string name="elapsed_time_hours_ago">%1$d Hours</string>
|
||||
<string name="elapsed_time_yesterday">Yesterday</string>
|
||||
<string name="elapsed_time_days_ago">%1$,d Days</string>
|
||||
<string name="elapsed_time_days_ago">%1$d Days</string>
|
||||
<string name="elapsed_time_a_month_ago">1 Month</string>
|
||||
<string name="elapsed_time_months_ago">%1$,d Months</string>
|
||||
<string name="elapsed_time_months_ago">%1$d Months</string>
|
||||
<string name="elapsed_time_a_year_ago">1 Year</string>
|
||||
<string name="elapsed_time_years_ago">%1$,d Years</string>
|
||||
<string name="elapsed_time_years_ago">%1$d Years</string>
|
||||
|
||||
<string name="error_getting_multi_reddit_data">Error getting multireddit data</string>
|
||||
<string name="error_loading_multi_reddit_list">Cannot sync multireddits</string>
|
||||
@ -1077,7 +1077,7 @@
|
||||
|
||||
<string name="give_award_dialog_title">Give Award?</string>
|
||||
<string name="anonymous">Anonymous</string>
|
||||
<string name="give_award_error_message">Code: %1$,d/\n Message: %2$s</string>
|
||||
<string name="give_award_error_message">Code: %1$d/\n Message: %2$s</string>
|
||||
<string name="give_award_success">Award given</string>
|
||||
<string name="give_award_failed">Failed</string>
|
||||
|
||||
@ -1315,4 +1315,6 @@
|
||||
<string name="load_more_posts_failed">Failed to load more posts.\nTap to retry.</string>
|
||||
<string name="no_more_posts">No more posts</string>
|
||||
|
||||
<string name="image_index_in_gallery">%1$d/%2$d</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user