mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1098096 - Add a hack to make overscroll effect work on Android 5.0 r=lucasr
This commit is contained in:
parent
48ce620bae
commit
a1b63d989d
@ -9,9 +9,13 @@ import org.mozilla.gecko.AppConstants.Versions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.view.View;
|
||||
import android.widget.EdgeEffect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class OverscrollEdgeEffect implements Overscroll {
|
||||
// Used to index particular edges in the edges array
|
||||
@ -27,10 +31,31 @@ public class OverscrollEdgeEffect implements Overscroll {
|
||||
private final View mView;
|
||||
|
||||
public OverscrollEdgeEffect(final View v) {
|
||||
Field paintField = null;
|
||||
if (Versions.feature21Plus) {
|
||||
try {
|
||||
paintField = EdgeEffect.class.getDeclaredField("mPaint");
|
||||
paintField.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
}
|
||||
}
|
||||
|
||||
mView = v;
|
||||
Context context = v.getContext();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mEdges[i] = new EdgeEffect(context);
|
||||
|
||||
try {
|
||||
if (paintField != null) {
|
||||
final Paint p = (Paint) paintField.get(mEdges[i]);
|
||||
|
||||
// The Android EdgeEffect class uses a mode of SRC_ATOP here, which means it will only
|
||||
// draw the effect where there are non-transparent pixels in the destination. Since the LayerView
|
||||
// itself is fully transparent, it doesn't display at all. We need to use SRC instead.
|
||||
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user