Skip to content

Commit

Permalink
intercepter
Browse files Browse the repository at this point in the history
  • Loading branch information
wujingchao committed Apr 13, 2015
1 parent bb8458b commit 67821d1
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
Expand Down Expand Up @@ -68,7 +69,7 @@ public MultiCardMenu(Context context, AttributeSet attrs) {

private boolean isDisplaying = false;

private Interpolator interpolator = new DecelerateInterpolator();
private Interpolator interpolator = new AccelerateInterpolator();

private float mMoveDistanceToTrigger;

Expand Down Expand Up @@ -128,7 +129,7 @@ private void handleActionDown(MotionEvent event) {
}
}
}else if(isDisplaying && downY > (getMeasuredHeight() - (mChildCount - 1) * mTitleBarHeightOnFold)) {
Log.d(TAG,"click bottom card");
hideCard(mDisplayingCard);
}else if(isDisplaying && downY > mMarginTop && downY < getChildAt(mDisplayingCard).getMeasuredHeight() + mMarginTop) {
whichCardOnTouch = mDisplayingCard;
isTouchOnCard = true;
Expand All @@ -141,9 +142,11 @@ private void handleActionDown(MotionEvent event) {
private void handleActionMove(MotionEvent event) {
if(whichCardOnTouch == -1 || !isTouchOnCard)return;
View touchingChildView = getChildAt(whichCardOnTouch);
deltaY = (event.getY() - downY);
deltaY = event.getY() - downY;
downY = event.getY();
touchingChildView.offsetTopAndBottom((int) deltaY);
// deltaY += event.getY() - downY; //bug???
// ViewHelper.setTranslationY(touchingChildView,deltaY);
}

private void handleActionUp(MotionEvent event) {
Expand Down Expand Up @@ -183,11 +186,8 @@ private void displayCard(int which) {
j ++;
}
}
// for(ObjectAnimator o:animators) {
// o.setInterpolator(interpolator);
// o.start();
// }
AnimatorSet set = new AnimatorSet();
set.setInterpolator(interpolator);
set.playTogether(animators);
set.start();
isDisplaying = true;
Expand All @@ -209,12 +209,9 @@ private void hideCard(int which) {
}
}
AnimatorSet set = new AnimatorSet();
set.setInterpolator(interpolator);
set.playTogether(animators);
set.start();
// for(ObjectAnimator o :animators) {
// o.setInterpolator(interpolator);
// o.start();
// }
isDisplaying = false;
mDisplayingCard = -1;
}
Expand Down

0 comments on commit 67821d1

Please sign in to comment.