From 238b5124d59164eb0e45db98f565e690d8a1cd8f Mon Sep 17 00:00:00 2001 From: tehcneko <7764726+tehcneko@users.noreply.github.com> Date: Sat, 20 Mar 2021 12:44:16 +0800 Subject: [PATCH] Add some fake paddings to gallery preview --- .../com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java | 4 +--- .../hippo/widget/recyclerview/AutoGridLayoutManager.java | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java index 1eceb48d4..84ed0ea93 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryPreviewsScene.java @@ -61,8 +61,6 @@ import com.hippo.yorozuya.ViewUtils; import java.util.ArrayList; import java.util.Locale; -import rikka.recyclerview.RecyclerViewKt; - public class GalleryPreviewsScene extends ToolbarScene { public static final String KEY_GALLERY_INFO = "gallery_info"; @@ -148,7 +146,7 @@ public class GalleryPreviewsScene extends ToolbarScene { mAdapter = new GalleryPreviewAdapter(); mRecyclerView.setAdapter(mAdapter); int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId()); - AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth); + AutoGridLayoutManager layoutManager = new AutoGridLayoutManager(context, columnWidth, LayoutUtils.dp2pix(context, 16)); layoutManager.setStrategy(AutoGridLayoutManager.STRATEGY_SUITABLE_SIZE); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setClipToPadding(false); diff --git a/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.java b/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.java index a7bfaaf49..f080f8891 100644 --- a/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.java +++ b/app/src/main/java/com/hippo/widget/recyclerview/AutoGridLayoutManager.java @@ -32,11 +32,13 @@ public class AutoGridLayoutManager extends GridLayoutManager { private int mColumnSize = -1; private boolean mColumnSizeChanged = true; private int mStrategy; + private int fakePadding; private List mListeners; - public AutoGridLayoutManager(Context context, int columnSize) { + public AutoGridLayoutManager(Context context, int columnSize, int fakePadding) { super(context, 1); + this.fakePadding = fakePadding; setColumnSize(columnSize); } @@ -81,9 +83,9 @@ public class AutoGridLayoutManager extends GridLayoutManager { if (mColumnSizeChanged && mColumnSize > 0) { int totalSpace; if (getOrientation() == RecyclerView.VERTICAL) { - totalSpace = getWidth() - getPaddingRight() - getPaddingLeft(); + totalSpace = getWidth() - getPaddingRight() - getPaddingLeft() - fakePadding; } else { - totalSpace = getHeight() - getPaddingTop() - getPaddingBottom(); + totalSpace = getHeight() - getPaddingTop() - getPaddingBottom() - fakePadding; } int spanCount;