Add reveal effect for gallery detail header on pre-L
This commit is contained in:
1 parent
2ddb234e72
commit
b8d5a7d80d
3 files changed
+83
-6
No files matched your search
@@ -36,6 +36,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.text.TextUtils;
|
||||
@@ -45,7 +46,6 @@ import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
@@ -79,6 +79,7 @@ import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.reveal.ViewAnimationUtils;
|
||||
import com.hippo.rippleold.RippleSalon;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
@@ -639,7 +640,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
setActionDrawable(mSimilar, similar);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private boolean createCircularReveal() {
|
||||
if (mColorBg == null) {
|
||||
return false;
|
||||
@@ -647,7 +647,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
int w = mColorBg.getWidth();
|
||||
int h = mColorBg.getHeight();
|
||||
if (mColorBg.isAttachedToWindow() && w != 0 && h != 0) {
|
||||
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();
|
||||
return true;
|
||||
@@ -692,8 +692,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
break;
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP &&
|
||||
(oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
|
||||
if ((oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
|
||||
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER)) {
|
||||
if (!createCircularReveal()) {
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.reveal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
public class RevealView extends View implements Reveal {
|
||||
|
||||
private final Path mRevealPath = new Path();
|
||||
private boolean mReveal;
|
||||
private int mCenterX;
|
||||
private int mCenterY;
|
||||
private float mRadius;
|
||||
|
||||
public RevealView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public RevealView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public RevealView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRevealEnable(boolean enable) {
|
||||
mReveal = enable;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReveal(int centerX, int centerY, float radius) {
|
||||
mCenterX = centerX;
|
||||
mCenterY = centerY;
|
||||
mRadius = radius;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
boolean reveal = mReveal;
|
||||
int saveCount = 0;
|
||||
|
||||
if (reveal) {
|
||||
saveCount = canvas.save();
|
||||
Path path = mRevealPath;
|
||||
path.reset();
|
||||
path.addCircle(mCenterX, mCenterY, mRadius, Path.Direction.CW);
|
||||
canvas.clipPath(path);
|
||||
}
|
||||
|
||||
super.draw(canvas);
|
||||
|
||||
if (reveal) {
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user