Skip to content

Commit 3320dad

Browse files
modified, card overlay will update with alphaAnimation
1 parent c837977 commit 3320dad

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

cardstackview/src/main/java/com/yuyakaido/android/cardstackview/CardStackView.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,19 @@ public void performSwipe(Point point, final Animator.AnimatorListener listener)
261261
.start();
262262
}
263263

264-
public void performSwipe(SwipeDirection direction, AnimatorSet set, final Animator.AnimatorListener listener) {
264+
public void performSwipe(SwipeDirection direction, AnimatorSet set, AnimatorSet overlayAnimatorSet, final Animator.AnimatorListener listener) {
265265
if (direction == SwipeDirection.Left) {
266266
getTopView().showLeftOverlay();
267-
getTopView().setOverlayAlpha(1f);
267+
getTopView().setOverlayAlpha(overlayAnimatorSet);
268268
} else if (direction == SwipeDirection.Right) {
269269
getTopView().showRightOverlay();
270-
getTopView().setOverlayAlpha(1f);
270+
getTopView().setOverlayAlpha(overlayAnimatorSet);
271271
} else if (direction == SwipeDirection.Bottom){
272272
getTopView().showBottomOverlay();
273-
getTopView().setOverlayAlpha(1f);
273+
getTopView().setOverlayAlpha(overlayAnimatorSet);
274274
} else if (direction == SwipeDirection.Top){
275275
getTopView().showTopOverlay();
276-
getTopView().setOverlayAlpha(1f);
276+
getTopView().setOverlayAlpha(overlayAnimatorSet);
277277
}
278278
set.addListener(listener);
279279
set.setInterpolator(new TimeInterpolator() {
@@ -476,8 +476,12 @@ public void onAnimationEnd(Animator animator) {
476476
}
477477

478478
public void swipe(final SwipeDirection direction, AnimatorSet set) {
479+
swipe(direction, set, null);
480+
}
481+
482+
public void swipe(final SwipeDirection direction, AnimatorSet cardAnimatorSet, AnimatorSet overlayAnimatorSet) {
479483
executePreSwipeTask();
480-
performSwipe(direction, set, new AnimatorListenerAdapter() {
484+
performSwipe(direction, cardAnimatorSet, overlayAnimatorSet, new AnimatorListenerAdapter() {
481485
@Override
482486
public void onAnimationEnd(Animator animator) {
483487
executePostSwipeTask(new Point(0, -2000), direction);

cardstackview/src/main/java/com/yuyakaido/android/cardstackview/internal/CardContainerView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.yuyakaido.android.cardstackview.internal;
22

3+
import android.animation.AnimatorSet;
34
import android.content.Context;
45
import android.graphics.Point;
56
import android.support.v4.view.MotionEventCompat;
@@ -306,6 +307,12 @@ public void setOverlay(int left, int right, int bottom, int top) {
306307
}
307308
}
308309

310+
public void setOverlayAlpha(AnimatorSet overlayAnimatorSet) {
311+
if(overlayAnimatorSet != null) {
312+
overlayAnimatorSet.start();
313+
}
314+
}
315+
309316
public void setOverlayAlpha(float alpha) {
310317
ViewCompat.setAlpha(overlayContainer, alpha);
311318
}

0 commit comments

Comments
 (0)