diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryPageView.java b/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryPageView.java index 08e014d32..931d1d317 100644 --- a/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryPageView.java +++ b/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryPageView.java @@ -38,6 +38,7 @@ public class GalleryPageView extends GLFrameLayout { private static final int INFO_INTERVAL = 24; public static final float PROGRESS_GONE = -1.0f; public static final float PROGRESS_INDETERMINATE = -2.0f; + private static final int PAGE_MIN_HEIGHT = 256; private final ImageView mImage; private final GLLinearLayout mInfo; @@ -45,6 +46,8 @@ public class GalleryPageView extends GLFrameLayout { private final GLTextureView mError; private final GLProgressView mProgress; + private final int mPageMinHeight; + private int mIndex = INVALID_INDEX; public GalleryPageView(Context context, MovableTextTexture pageTextTexture, @@ -89,6 +92,20 @@ public class GalleryPageView extends GLFrameLayout { LayoutParams.WRAP_CONTENT); lp.gravity = Gravity.CENTER_HORIZONTAL; mInfo.addComponent(mProgress, lp); + + mPageMinHeight = LayoutUtils.dp2pix(context, PAGE_MIN_HEIGHT); + } + + @Override + protected int getSuggestedMinimumHeight() { + // The height of the actual image may be smaller than mPageMinHeight. + // Set min height as 0 when the image is visible. + // For PageLayoutManager, min height is useless. + if (mImage.getVisibility() == VISIBLE) { + return 0; + } else { + return mPageMinHeight; + } } int getIndex() { diff --git a/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryView.java b/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryView.java index 290f18a8c..a05b48a5f 100644 --- a/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryView.java +++ b/app/src/main/java/com/hippo/ehviewer/gallery/gl/GalleryView.java @@ -55,7 +55,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener { public static final int BACKGROUND_COLOR = 0xff212121; private static final int PROGRESS_SIZE_IN_DP = 48; - private static final int PAGE_MIN_HEIGHT_IN_DP = 256; public static final int LAYOUT_MODE_LEFT_TO_RIGHT = 0; public static final int LAYOUT_MODE_RIGHT_TO_LEFT = 1; @@ -105,7 +104,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener { private final int mProgressSize; private final float mErrorSize; private final int mErrorColor; - private final int mPageMinHeight; private boolean mEnableRequestFill = true; private boolean mRequestFill = false; @@ -158,7 +156,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener { mProgressSize = LayoutUtils.dp2pix(context, PROGRESS_SIZE_IN_DP); mErrorSize = context.getResources().getDimension(R.dimen.text_large); mErrorColor = context.getResources().getColor(R.color.red_500); - mPageMinHeight = LayoutUtils.dp2pix(context, PAGE_MIN_HEIGHT_IN_DP); mDefaultErrorStr = context.getResources().getString(R.string.error_unknown); mEmptyStr = context.getResources().getString(R.string.error_empty); @@ -777,7 +774,6 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener { GalleryPageView page = mGalleryPageViewPool.pop(); if (page == null) { page = new GalleryPageView(mContext, mPageTextTexture, mProgressColor, mProgressSize); - page.setMinimumHeight(mPageMinHeight); } return page; }