bug 930059 - Overscroll.java doesn't need to use compatibility libraries, follow up to not use invalidateAfterAnnimation on ICS r=wesj

This commit is contained in:
Brad Lassey 2013-11-20 14:35:10 -08:00
Родитель 79ded462ff
Коммит 0f8d21e4e6
1 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -7,9 +7,11 @@ package org.mozilla.gecko.gfx;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Build;
import android.widget.EdgeEffect;
import android.view.View;
public class OverscrollEdgeEffect implements Overscroll {
// Used to index particular edges in the edges array
private static final int TOP = 0;
@ -54,6 +56,14 @@ public class OverscrollEdgeEffect implements Overscroll {
}
}
private void invalidate() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mView.postInvalidateOnAnimation();
} else {
mView.postInvalidateDelayed(10);
}
}
public void setVelocity(final float velocity, final Axis axis) {
final EdgeEffect edge = getEdgeForAxisAndSide(axis, velocity);
@ -65,7 +75,7 @@ public class OverscrollEdgeEffect implements Overscroll {
edge.onAbsorb((int)velocity);
}
mView.postInvalidateOnAnimation();
invalidate();
}
public void setDistance(final float distance, final Axis axis) {
@ -76,7 +86,7 @@ public class OverscrollEdgeEffect implements Overscroll {
final EdgeEffect edge = getEdgeForAxisAndSide(axis, (int)distance);
edge.onPull(distance / (axis == Axis.X ? mView.getWidth() : mView.getHeight()));
mView.postInvalidateOnAnimation();
invalidate();
}
public void draw(final Canvas canvas, final ImmutableViewportMetrics metrics) {
@ -104,7 +114,7 @@ public class OverscrollEdgeEffect implements Overscroll {
// If the edge effect is animating off screen, invalidate.
if (invalidate) {
mView.postInvalidateOnAnimation();
invalidate();
}
}