float velocityY) {
// 返回当前正在显示的子视图的索引
displayedChildIndex = myViewFlipper.getDisplayedChild();
final ImageView iv = (ImageView) myViewFlipper.getChildAt(
displayedChildIndex).findViewById(R.id.view_image);
if (e2.getX() - e1.getX() >= 100 && e1.getY() - e2.getY() >= 100) {
AnimationSet outAnim = (AnimationSet) AnimationUtils.loadAnimation(
this, R.anim.collect_treasure);
iv.startAnimation(outAnim);
outAnim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
showNextView();
AnimationSet downAnim = (AnimationSet) AnimationUtils
.loadAnimation(MainActivity.this, R.anim.up_or_down);
treasure_btn.setAnimation(downAnim);
iv.clearAnimation();
}
});
} else if (e1.getX() - e2.getX() >= 100 && e2.getY() - e1.getY() >= 100) {
AnimationSet outAnim = (AnimationSet) AnimationUtils.loadAnimation(
this, R.anim.throw_garbage);
iv.startAnimation(outAnim);
outAnim.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
showNextView();
AnimationSet leftAnim = (AnimationSet) AnimationUtils
.loadAnimation(MainActivity.this,
R.anim.left_or_right);
garbage_btn.setAnimation(leftAnim);
iv.clearAnimation();
}
});
} else if (e1.getX() - e2.getX() >= 100) {
showNextView();