當前位置: 首頁>>代碼示例>>Java>>正文


Java FlingAnimation類代碼示例

本文整理匯總了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);
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:49,代碼來源:DeleteDropTarget.java

示例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);
}
 
開發者ID:talentlo,項目名稱:Trebuchet,代碼行數:50,代碼來源:DeleteDropTarget.java


注:本文中的com.android.launcher3.util.FlingAnimation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。