本文整理汇总了Java中com.android.launcher3.util.FlingAnimation类的典型用法代码示例。如果您正苦于以下问题:Java FlingAnimation类的具体用法?Java FlingAnimation怎么用?Java FlingAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlingAnimation类属于com.android.launcher3.util包,在下文中一共展示了FlingAnimation类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFlingToDelete
import com.android.launcher3.util.FlingAnimation; //导入依赖的package包/类
@Override
public void onFlingToDelete(final DragObject d, PointF vel) {
// Don't highlight the icon as it's animating
d.dragView.setColor(0);
final DragLayer dragLayer = mLauncher.getDragLayer();
FlingAnimation fling = new FlingAnimation(d, vel,
getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
mDrawable.getIntrinsicWidth(), mDrawable.getIntrinsicHeight()),
dragLayer);
final int duration = fling.getDuration();
final long startTime = AnimationUtils.currentAnimationTimeMillis();
// NOTE: Because it takes time for the first frame of animation to actually be
// called and we expect the animation to be a continuation of the fling, we have
// to account for the time that has elapsed since the fling finished. And since
// we don't have a startDelay, we will always get call to update when we call
// start() (which we want to ignore).
final TimeInterpolator tInterpolator = new TimeInterpolator() {
private int mCount = -1;
private float mOffset = 0f;
@Override
public float getInterpolation(float t) {
if (mCount < 0) {
mCount++;
} else if (mCount == 0) {
mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() -
startTime) / duration);
mCount++;
}
return Math.min(1f, mOffset + t);
}
};
Runnable onAnimationEndRunnable = new Runnable() {
@Override
public void run() {
mLauncher.exitSpringLoadedDragMode();
completeDrop(d);
mLauncher.getDragController().onDeferredEndFling(d);
}
};
dragLayer.animateView(d.dragView, fling, duration, tInterpolator, onAnimationEndRunnable,
DragLayer.ANIMATION_END_DISAPPEAR, null);
}
示例2: onFlingToDelete
import com.android.launcher3.util.FlingAnimation; //导入依赖的package包/类
@Override
public void onFlingToDelete(final DragObject d, PointF vel) {
// Don't highlight the icon as it's animating
d.dragView.setColor(0);
d.dragView.updateInitialScaleToCurrentScale();
final DragLayer dragLayer = mLauncher.getDragLayer();
FlingAnimation fling = new FlingAnimation(d, vel,
getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
mDrawable.getIntrinsicWidth(), mDrawable.getIntrinsicHeight()),
dragLayer);
final int duration = fling.getDuration();
final long startTime = AnimationUtils.currentAnimationTimeMillis();
// NOTE: Because it takes time for the first frame of animation to actually be
// called and we expect the animation to be a continuation of the fling, we have
// to account for the time that has elapsed since the fling finished. And since
// we don't have a startDelay, we will always get call to update when we call
// start() (which we want to ignore).
final TimeInterpolator tInterpolator = new TimeInterpolator() {
private int mCount = -1;
private float mOffset = 0f;
@Override
public float getInterpolation(float t) {
if (mCount < 0) {
mCount++;
} else if (mCount == 0) {
mOffset = Math.min(0.5f, (float) (AnimationUtils.currentAnimationTimeMillis() -
startTime) / duration);
mCount++;
}
return Math.min(1f, mOffset + t);
}
};
Runnable onAnimationEndRunnable = new Runnable() {
@Override
public void run() {
mLauncher.exitSpringLoadedDragMode();
completeDrop(d);
mLauncher.getDragController().onDeferredEndFling(d);
}
};
dragLayer.animateView(d.dragView, fling, duration, tInterpolator, onAnimationEndRunnable,
DragLayer.ANIMATION_END_DISAPPEAR, null);
}