From 2a944f5e0a95afade1597391709fa4919dc7e764 Mon Sep 17 00:00:00 2001 From: seven332 Date: Tue, 5 Mar 2019 14:20:18 +0800 Subject: [PATCH] Adjust the center of circular reveal in gallery detail scene --- .../ehviewer/ui/scene/GalleryDetailScene.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java index 8a3210b6f..5535a5d4f 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java @@ -720,8 +720,19 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene int w = mColorBg.getWidth(); int h = mColorBg.getHeight(); if (ViewCompat.isAttachedToWindow(mColorBg) && w != 0 && h != 0) { - ViewAnimationUtils.createCircularReveal(mColorBg, w / 2, h / 2, 0, - (float) Math.hypot(w / 2, h / 2)).setDuration(300).start(); + Resources resources = getContext2().getResources(); + int keylineMargin = resources.getDimensionPixelSize(R.dimen.keyline_margin); + int thumbWidth = resources.getDimensionPixelSize(R.dimen.gallery_detail_thumb_width); + int thumbHeight = resources.getDimensionPixelSize(R.dimen.gallery_detail_thumb_height); + + int x = thumbWidth / 2 + keylineMargin; + int y = thumbHeight / 2 + keylineMargin; + + int radiusX = Math.max(Math.abs(x), Math.abs(w - x)); + int radiusY = Math.max(Math.abs(y), Math.abs(h - y)); + float radius = (float) Math.hypot(radiusX, radiusY); + + ViewAnimationUtils.createCircularReveal(mColorBg, x, y, 0, radius).setDuration(300).start(); return true; } else { return false; @@ -767,12 +778,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene if ((oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) && (state == STATE_NORMAL || state == STATE_REFRESH_HEADER) && AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme)) { if (!createCircularReveal()) { - SimpleHandler.getInstance().post(new Runnable() { - @Override - public void run() { - createCircularReveal(); - } - }); + SimpleHandler.getInstance().post(this::createCircularReveal); } } }