当前位置: 首页>>代码示例>>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;未经允许,请勿转载。