本文整理匯總了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);
}