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


Java ValueAnimator.addListener方法代碼示例

本文整理匯總了Java中android.animation.ValueAnimator.addListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueAnimator.addListener方法的具體用法?Java ValueAnimator.addListener怎麽用?Java ValueAnimator.addListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.animation.ValueAnimator的用法示例。


在下文中一共展示了ValueAnimator.addListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startTwoLevel

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public RefreshKernel startTwoLevel(boolean open) {
    if (open) {
        AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                SmartRefreshLayout.this.notifyStateChanged(RefreshState.TwoLevel);
            }
        };
        ValueAnimator animator = SmartRefreshLayout.this.animSpinner(SmartRefreshLayout.this.getMeasuredHeight());
        if (animator != null && animator == SmartRefreshLayout.this.reboundAnimator) {
            animator.setDuration(SmartRefreshLayout.this.mFloorDuration);
            animator.addListener(listener);
        } else {
            listener.onAnimationEnd(null);
        }
    } else {
        if (animSpinner(0) == null) {
            SmartRefreshLayout.this.notifyStateChanged(RefreshState.None);
        }
    }
    return this;
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:24,代碼來源:SmartRefreshLayout.java

示例2: setStateLoding

import android.animation.ValueAnimator; //導入方法依賴的package包/類
protected void setStateLoding() {
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            setStateDirectLoading();
        }
    };
    notifyStateChanged(RefreshState.LoadReleased);
    ValueAnimator animator = animSpinner(-mFooterHeight);
    if (animator != null) {
        animator.addListener(listener);
    }
    if (mRefreshFooter != null) {
        //onLoadmoreReleased 的執行順序定在 animSpinner 之後 onAnimationEnd 之前
        // 這樣 onLoadmoreReleased 內部 可以做出 對 前麵 animSpinner 的覆蓋 操作
        mRefreshFooter.onLoadmoreReleased(this, mFooterHeight, mFooterExtendHeight);
    }
    if (mOnMultiPurposeListener != null) {
        //同 mRefreshFooter.onLoadmoreReleased 一致
        mOnMultiPurposeListener.onFooterReleased(mRefreshFooter, mFooterHeight, mFooterExtendHeight);
    }
    if (animator == null) {
        //onAnimationEnd 會改變狀態為 loading 必須在 onLoadmoreReleased 之後調用
        listener.onAnimationEnd(null);
    }
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:27,代碼來源:SmartRefreshLayout.java

示例3: createExpandValueAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private ValueAnimator createExpandValueAnimator() {
    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
    animator.setDuration(DEFAULT_ANIMATION_DURATION_EXPAND);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mExpandedScaleFactor[0] = (float) valueAnimator.getAnimatedValue();
            invalidateSelf();
        }
    });
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            notifyExpanded();
        }
    });
    return animator;
}
 
開發者ID:dewarder,項目名稱:HoldingButton,代碼行數:20,代碼來源:HoldingDrawable.java

示例4: createAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public Animator createAnimator(ViewGroup sceneRoot,
                               TransitionValues startValues,
                               TransitionValues endValues) {
    if (animatable == null || endValues == null
            || !(endValues.view instanceof ImageView)) return null;

    ImageView iv = (ImageView) endValues.view;
    iv.setImageDrawable((Drawable) animatable);

    // need to return a non-null Animator even though we just want to listen for the start
    ValueAnimator transition = ValueAnimator.ofInt(0, 1);
    transition.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            animatable.start();
        }
    });
    return transition;
}
 
開發者ID:vpaliyX,項目名稱:Melophile,代碼行數:21,代碼來源:StartAnimatable.java

示例5: endAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
    super.endAnimation(dynamicWeatherView, listener);
    ValueAnimator animator = ValueAnimator.ofFloat(1, -1);
    animator.setDuration(1000);
    animator.setRepeatCount(0);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            hillTransFactor = (float) animation.getAnimatedValue();
        }
    });
    if (listener != null) {
        animator.addListener(listener);
    }
    animator.start();
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:19,代碼來源:OvercastType.java

示例6: endAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
    super.endAnimation(dynamicWeatherView, listener);
    dynamicWeatherView.removeCallbacks(flashRunnable);
    ValueAnimator animator = ValueAnimator.ofFloat(getWidth() - bitmap.getWidth() * 0.2f, getWidth());
    animator.setDuration(1000);
    animator.setRepeatCount(0);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            transFactor = (float) animation.getAnimatedValue();
        }
    });
    if (listener != null) {
        animator.addListener(listener);
    }
    animator.start();
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:20,代碼來源:RainType.java

示例7: animLayoutByTime

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public void animLayoutByTime(int start, int end, long time, AnimatorUpdateListener listener, AnimatorListener animatorListener) {
    ValueAnimator va = ValueAnimator.ofInt(start, end);
    va.setInterpolator(new DecelerateInterpolator());
    va.addUpdateListener(listener);
    va.addListener(animatorListener);
    va.setDuration(time);
    va.start();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:AnimProcessor.java

示例8: createSettlingAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private ValueAnimator createSettlingAnimation(float curFraction) {
    ValueAnimator animator;
    DIRECTION direction;
    if(curFraction < SCROLL_SETTLING_THRESHOLD_LEFT) {
        // settling to current position -1
        animator = ValueAnimator.ofFloat(curFraction, ANIMATION_LEFT_VALUE);
        direction = DIRECTION.LEFT;
    } else if(curFraction >= SCROLL_SETTLING_THRESHOLD_LEFT
            && curFraction <= SCROLL_SETTLING_THRESHOLD_RIGHT) {
        // settling to current position
        animator = ValueAnimator.ofFloat(curFraction, ANIMATION_MIDDLE_VALUE);
        direction = DIRECTION.MIDDLE;
    } else {
        // settling to current position +1
        animator = ValueAnimator.ofFloat(curFraction, ANIMATION_RIGHT_VALUE);
        direction = DIRECTION.RIGHT;
    }

    animator.setDuration(ANIMATION_DURATION_HALF);
    animator.setInterpolator(ANIMATION_INTERPOLATOR);
    animator.addUpdateListener(animatorUpdateListener);
    ImageAnimationListener listener = new ImageAnimationListener(direction);
    animator.addListener(listener);
    if(keys != null) {
        // pre load the image if it did not load by auto scroll
        String key = keys[getNextPosition(direction)];
        if(imageLoader != null && !imageLoader.isImageLoaded(key)) {
            imageLoader.preLoadImage(key);
        }
    }
    return animator;
}
 
開發者ID:f3401pal,項目名稱:ImageCarouselView,代碼行數:33,代碼來源:ImageCarouselView.java

示例9: animateAlphaAtIndex

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * Returns an animator which changes the alpha at the index {@param index}
 * to {@param finalAlpha}. Alphas at other index are not affected.
 */
public Animator animateAlphaAtIndex(float finalAlpha, final int index) {
    final ValueAnimator anim;

    if (Float.compare(finalAlpha, mAlphas[index]) == 0) {
        // Return a dummy animator to avoid null checks.
        anim = ValueAnimator.ofFloat(0, 0);
    } else {
        ValueAnimator animator = ValueAnimator.ofFloat(mAlphas[index], finalAlpha);
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float value = (Float) valueAnimator.getAnimatedValue();
                setAlphaAtIndex(value, index);
            }
        });
        anim = animator;
    }

    if (Float.compare(finalAlpha, 0f) == 0) {
        // In case when any channel is animating to 0, and the current alpha is also 0, do not
        // update alpha of the target view while the animation is running.
        // We special case '0' because if any channel is set to 0, values of other
        // channels do not matter.
        anim.addListener(new ZeroAlphaAnimatorListener());
    }
    return anim;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:32,代碼來源:MultiStateAlphaController.java

示例10: drawBezierLine

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * 繪製水平路徑
 * **/
private void drawBezierLine() {

    PointF pointControl = new PointF(0, endYThree);
    PointF pointStart = new PointF(endXTwo, endYTwo);
    PointF pointEnd = new PointF(endXThree, endYThree);

    BezierEvaluator bezierEvaluator = new BezierEvaluator(pointControl);
    ValueAnimator valueLine = ValueAnimator.ofObject(bezierEvaluator, pointStart, pointEnd);
    valueLine.setDuration(1000);
    valueLine.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {

            PointF currentPoint = (PointF) valueAnimator.getAnimatedValue();

            setLT((int) (currentPoint.x - planeHeight / 2),
                    (int) (currentPoint.y - planeHeight / 2 - skyHeight));

            float angle = (float) Math.atan2((currentPoint.y
                    - mOldPoint.y),(currentPoint.x - mOldPoint.x));

            setRotation((float) (angle * 180 / Math.PI));
            mOldPoint = currentPoint;
        }
    });
    valueLine.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            //動畫執行結束
            ANIMATION_END=true;
        }
    });
    valueLine.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorLine=valueLine;
}
 
開發者ID:RuanXiaoHui,項目名稱:PlainFly,代碼行數:39,代碼來源:PlaneLayout.java

示例11: startAnim

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * 執行文字編輯區域動畫
 */
private void startAnim(float start, float end, AnimatorListenerAdapter listenerAdapter){

    ValueAnimator va = ValueAnimator.ofFloat(start, end).setDuration(200);
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            rl_edit_text.setY(value);
        }
    });
    if(listenerAdapter != null) va.addListener(listenerAdapter);
    va.start();
}
 
開發者ID:Zhaoss,項目名稱:WeiXinRecordedDemo,代碼行數:17,代碼來源:EditVideoActivity.java

示例12: animateSuccessfulSet

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * Change card color. This method wraps the Property Animation API mentioned here
 * https://stackoverflow.com/a/14467625/7009268
 */
public void animateSuccessfulSet(final AnimationEndCallback callback) {
    int colorFrom = ContextCompat.getColor(getContext(), R.color.card_background_normal);
    int colorTo = ContextCompat.getColor(getContext(), R.color.fbutton_color_nephritis);
    final SetGameCardView card = this;

    int duration = getContext().getResources().getInteger(R.integer.card_success_animation_duration);

    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(duration); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            card.setCardBackgroundColor((int) animator.getAnimatedValue());
        }
    });

    colorAnimation.start();

    colorAnimation.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            card.setChecked(false, true);
            // Notify our calling method that the animation is over
            if (callback != null) {
                callback.onAnimationFinish();
            }
        }
    });
}
 
開發者ID:jaysondc,項目名稱:TripleTap,代碼行數:36,代碼來源:SetGameCardView.java

示例13: addBookmarkWithAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public static void addBookmarkWithAnimation(final View bookmarkImage, Animator.AnimatorListener animatorListener) {
    bookmarkImage.setPivotY(0);
    ValueAnimator moveAnim = ObjectAnimator.ofFloat(bookmarkImage, View.SCALE_Y, 0, 1);
    moveAnim.setDuration(1000);
    moveAnim.setInterpolator(new OvershootInterpolator(BOOKMARK_ANIMATING_OVERSHOOT_TENSION));
    moveAnim.addListener(animatorListener);
    moveAnim.start();
}
 
開發者ID:fekracomputers,項目名稱:IslamicLibraryAndroid,代碼行數:9,代碼來源:AnimationUtils.java

示例14: performDismiss

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void performDismiss() {
    // Animate the dismissed view to zero-height and then fire the dismiss callback.
    // This triggers layout on each animation frame; in the future we may want to do something
    // smarter and more performant.

    final ViewGroup.LayoutParams lp = mView.getLayoutParams();
    final int originalHeight = mView.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mCallbacks.onDismiss(mView, mToken);
            // Reset view presentation
            mView.setAlpha(1f);
            mView.setTranslationX(0);
            lp.height = originalHeight;
            mView.setLayoutParams(lp);
        }
    });

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            mView.setLayoutParams(lp);
        }
    });

    animator.start();
}
 
開發者ID:jonashao,項目名稱:Samantha,代碼行數:33,代碼來源:SwipeDismissTouchListener.java

示例15: setStateRefreshing

import android.animation.ValueAnimator; //導入方法依賴的package包/類
protected void setStateRefreshing() {
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mLastRefreshingTime = currentTimeMillis();
            notifyStateChanged(RefreshState.Refreshing);
            if (mRefreshListener != null) {
                mRefreshListener.onRefresh(SmartRefreshLayout.this);
            }
            if (mRefreshHeader != null) {
                mRefreshHeader.onStartAnimator(SmartRefreshLayout.this, mHeaderHeight, mHeaderExtendHeight);
            }
            if (mOnMultiPurposeListener != null) {
                mOnMultiPurposeListener.onRefresh(SmartRefreshLayout.this);
                mOnMultiPurposeListener.onHeaderStartAnimator(mRefreshHeader, mHeaderHeight, mHeaderExtendHeight);
            }
        }
    };
    notifyStateChanged(RefreshState.RefreshReleased);
    ValueAnimator animator = animSpinner(mHeaderHeight);
    if (animator != null) {
        animator.addListener(listener);
    }
    if (mRefreshHeader != null) {
        //onRefreshReleased 的執行順序定在 animSpinner 之後 onAnimationEnd 之前
        // 這樣 onRefreshReleased內部 可以做出 對 前麵 animSpinner 的覆蓋 操作
        mRefreshHeader.onRefreshReleased(this, mHeaderHeight, mHeaderExtendHeight);
    }
    if (mOnMultiPurposeListener != null) {
        //同 mRefreshHeader.onRefreshReleased 一致
        mOnMultiPurposeListener.onHeaderReleased(mRefreshHeader, mHeaderHeight, mHeaderExtendHeight);
    }
    if (animator == null) {
        //onAnimationEnd 會改變狀態為 Refreshing 必須在 onRefreshReleased 之後調用
        listener.onAnimationEnd(null);
    }
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:38,代碼來源:SmartRefreshLayout.java


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