当前位置: 首页>>代码示例>>Java>>正文


Java Utils.postInvalidateOnAnimation方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.utils.Utils.postInvalidateOnAnimation方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.postInvalidateOnAnimation方法的具体用法?Java Utils.postInvalidateOnAnimation怎么用?Java Utils.postInvalidateOnAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.utils.Utils的用法示例。


在下文中一共展示了Utils.postInvalidateOnAnimation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeScroll

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
public void computeScroll() {

        if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f)
            return; // There's no deceleration in progress

        final long currentTime = AnimationUtils.currentAnimationTimeMillis();

        mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef();
        mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef();

        final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f;

        float distanceX = mDecelerationVelocity.x * timeInterval;
        float distanceY = mDecelerationVelocity.y * timeInterval;

        mDecelerationCurrentPoint.x += distanceX;
        mDecelerationCurrentPoint.y += distanceY;

        MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x,
                mDecelerationCurrentPoint.y, 0);
        performDrag(event);
        event.recycle();
        mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false);

        mDecelerationLastTime = currentTime;

        if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01)
            Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
        else {
            // Range might have changed, which means that Y-axis labels
            // could have changed in size, affecting Y-axis size.
            // So we need to recalculate offsets.
            mChart.calculateOffsets();
            mChart.postInvalidate();

            stopDeceleration();
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:BarLineChartTouchListener.java

示例2: computeScroll

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
public void computeScroll() {

        if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f)
            return; // There's no deceleration in progress

        final long currentTime = AnimationUtils.currentAnimationTimeMillis();

        mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef();
        mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef();

        final float timeInterval = (float)(currentTime - mDecelerationLastTime) / 1000.f;

        float distanceX = mDecelerationVelocity.x * timeInterval;
        float distanceY = mDecelerationVelocity.y * timeInterval;

        mDecelerationCurrentPoint.x += distanceX;
        mDecelerationCurrentPoint.y += distanceY;

        MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0);
        performDrag(event);
        event.recycle();
        mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false);

        mDecelerationLastTime = currentTime;

        if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01)
            Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
        else {
            // Range might have changed, which means that Y-axis labels
            // could have changed in size, affecting Y-axis size.
            // So we need to recalculate offsets.
            mChart.calculateOffsets();
            mChart.postInvalidate();

            stopDeceleration();
        }
    }
 
开发者ID:rahulmaddineni,项目名称:Stayfit,代码行数:38,代码来源:BarLineChartTouchListener.java

示例3: computeScroll

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
public void computeScroll() {

        if (mDecelerationVelocity.x == 0.f && mDecelerationVelocity.y == 0.f)
            return; // There's no deceleration in progress

        final long currentTime = AnimationUtils.currentAnimationTimeMillis();

        mDecelerationVelocity.x *= mChart.getDragDecelerationFrictionCoef();
        mDecelerationVelocity.y *= mChart.getDragDecelerationFrictionCoef();

        final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f;

        float distanceX = mDecelerationVelocity.x * timeInterval;
        float distanceY = mDecelerationVelocity.y * timeInterval;

        mDecelerationCurrentPoint.x += distanceX;
        mDecelerationCurrentPoint.y += distanceY;

        MotionEvent event = MotionEvent.obtain(currentTime, currentTime, MotionEvent.ACTION_MOVE, mDecelerationCurrentPoint.x, mDecelerationCurrentPoint.y, 0);
        performDrag(event);
        event.recycle();
        mMatrix = mChart.getViewPortHandler().refresh(mMatrix, mChart, false);

        mDecelerationLastTime = currentTime;

        if (Math.abs(mDecelerationVelocity.x) >= 0.01 || Math.abs(mDecelerationVelocity.y) >= 0.01)
            Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
        else {
            // Range might have changed, which means that Y-axis labels
            // could have changed in size, affecting Y-axis size.
            // So we need to recalculate offsets.
            mChart.calculateOffsets();
            mChart.postInvalidate();

            stopDeceleration();
        }
    }
 
开发者ID:pencil-box,项目名称:NetKnight,代码行数:38,代码来源:BarLineChartTouchListener.java

示例4: onTouch

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {

    if (mGestureDetector.onTouchEvent(event))
        return true;

    // if rotation by touch is enabled
    if (mChart.isRotationEnabled()) {

        float x = event.getX();
        float y = event.getY();

        switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:

                startAction(event);

                stopDeceleration();

                resetVelocity();

                if (mChart.isDragDecelerationEnabled())
                    sampleVelocity(x, y);

                setGestureStartAngle(x, y);
                mTouchStartPoint.x = x;
                mTouchStartPoint.y = y;

                break;
            case MotionEvent.ACTION_MOVE:

                if (mChart.isDragDecelerationEnabled())
                    sampleVelocity(x, y);

                if (mTouchMode == NONE
                        && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y)
                        > Utils.convertDpToPixel(8f)) {
                    mLastGesture = ChartGesture.ROTATE;
                    mTouchMode = ROTATE;
                    mChart.disableScroll();
                } else if (mTouchMode == ROTATE) {
                    updateGestureRotation(x, y);
                    mChart.invalidate();
                }

                endAction(event);

                break;
            case MotionEvent.ACTION_UP:

                if (mChart.isDragDecelerationEnabled()) {

                    stopDeceleration();

                    sampleVelocity(x, y);

                    mDecelerationAngularVelocity = calculateVelocity();

                    if (mDecelerationAngularVelocity != 0.f) {
                        mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis();

                        Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
                    }
                }

                mChart.enableScroll();
                mTouchMode = NONE;

                endAction(event);

                break;
        }
    }

    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:PieRadarChartTouchListener.java

示例5: computeScroll

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
public void computeScroll() {

        if (mDecelerationAngularVelocity == 0.f)
            return; // There's no deceleration in progress

        final long currentTime = AnimationUtils.currentAnimationTimeMillis();

        mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef();

        final float timeInterval = (float) (currentTime - mDecelerationLastTime) / 1000.f;

        mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval);

        mDecelerationLastTime = currentTime;

        if (Math.abs(mDecelerationAngularVelocity) >= 0.001)
            Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
        else
            stopDeceleration();
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:PieRadarChartTouchListener.java

示例6: onTouch

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {

    if (mGestureDetector.onTouchEvent(event))
        return true;

    // if rotation by touch is enabled
    if (mChart.isRotationEnabled()) {

        float x = event.getX();
        float y = event.getY();

        switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:

                stopDeceleration();

                resetVelocity();

                if (mChart.isDragDecelerationEnabled())
                    sampleVelocity(x, y);

                setGestureStartAngle(x, y);
                mTouchStartPoint.x = x;
                mTouchStartPoint.y = y;

                break;
            case MotionEvent.ACTION_MOVE:

                if (mChart.isDragDecelerationEnabled())
                    sampleVelocity(x, y);

                if (mTouchMode == NONE
                        && distance(x, mTouchStartPoint.x, y, mTouchStartPoint.y)
                        > Utils.convertDpToPixel(8f)) {
                    mTouchMode = ROTATE;
                    mChart.disableScroll();
                } else if (mTouchMode == ROTATE) {
                    updateGestureRotation(x, y);
                    mChart.invalidate();
                }

                break;
            case MotionEvent.ACTION_UP:

                if (mChart.isDragDecelerationEnabled()) {

                    stopDeceleration();

                    sampleVelocity(x, y);

                    mDecelerationAngularVelocity = calculateVelocity();

                    if (mDecelerationAngularVelocity != 0.f) {
                        mDecelerationLastTime = AnimationUtils.currentAnimationTimeMillis();

                        Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
                    }
                }

                mChart.enableScroll();
                mTouchMode = NONE;

                break;
        }
    }

    return true;
}
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:72,代码来源:PieRadarChartTouchListener.java

示例7: computeScroll

import com.github.mikephil.charting.utils.Utils; //导入方法依赖的package包/类
public void computeScroll() {

        if (mDecelerationAngularVelocity == 0.f)
            return; // There's no deceleration in progress

        final long currentTime = AnimationUtils.currentAnimationTimeMillis();

        mDecelerationAngularVelocity *= mChart.getDragDecelerationFrictionCoef();

        final float timeInterval = (float)(currentTime - mDecelerationLastTime) / 1000.f;

        mChart.setRotationAngle(mChart.getRotationAngle() + mDecelerationAngularVelocity * timeInterval);

        mDecelerationLastTime = currentTime;

        if (Math.abs(mDecelerationAngularVelocity) >= 0.001)
            Utils.postInvalidateOnAnimation(mChart); // This causes computeScroll to fire, recommended for this by Google
        else
            stopDeceleration();
    }
 
开发者ID:xinpengfei520,项目名称:P2P,代码行数:21,代码来源:PieRadarChartTouchListener.java


注:本文中的com.github.mikephil.charting.utils.Utils.postInvalidateOnAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。