本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}