下面列出了android.support.v4.widget.EdgeEffectCompat#android.widget.EdgeEffect 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void setListViewEdgeEffectColor(AbsListView listView, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = AbsListView.class.getDeclaredField("mEdgeGlowTop");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(listView);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.setColor(color);
}
field = AbsListView.class.getDeclaredField("mEdgeGlowBottom");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(listView);
if (mEdgeGlowBottom != null) {
mEdgeGlowBottom.setColor(color);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void prepare(AttributeSet attrs)
{
setFocusable(true);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setWillNotDraw(false);
mScroller = new Scroller(getContext());
mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener);
mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);
if (attrs != null)
{
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomViewExtension, 0, 0);
autoScrollMargins = a.getDimensionPixelSize(R.styleable.CustomViewExtension_autoScrollMargins, 0);
a.recycle();
}
mEdgeGlowLeft = new EdgeEffect(getContext());
mEdgeGlowTop = new EdgeEffect(getContext());
mEdgeGlowRight = new EdgeEffect(getContext());
mEdgeGlowBottom = new EdgeEffect(getContext());
setWillNotDraw(false);
}
/**
* Tint the edge effect when you reach the end of a scroll view. API 21+ only
*
* @param scrollableView the scrollable view, such as a {@link android.widget.ScrollView}
* @param color the color
* @return true if it worked, false if it did not
*/
@TargetApi(21)
public static boolean tintEdgeEffect(@NonNull View scrollableView, @ColorInt int color) {
//http://stackoverflow.com/questions/27104521/android-lollipop-scrollview-edge-effect-color
boolean outcome = false;
final String[] edgeGlows = {"mEdgeGlowTop", "mEdgeGlowBottom", "mEdgeGlowLeft", "mEdgeGlowRight"};
for (String edgeGlow : edgeGlows) {
Class<?> clazz = scrollableView.getClass();
while (clazz != null) {
try {
final Field edgeGlowField = clazz.getDeclaredField(edgeGlow);
edgeGlowField.setAccessible(true);
final EdgeEffect edgeEffect = (EdgeEffect) edgeGlowField.get(scrollableView);
edgeEffect.setColor(color);
outcome = true;
break;
} catch (Exception e) {
clazz = clazz.getSuperclass();
}
}
}
return outcome;
}
public static void setEdgeEffectColor(final EdgeEffect edgeEffect, @ColorRes final int color) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
edgeEffect.setColor(color);
return;
}
final Field edgeField = EdgeEffect.class.getDeclaredField("mEdge");
final Field glowField = EdgeEffect.class.getDeclaredField("mGlow");
edgeField.setAccessible(true);
glowField.setAccessible(true);
final Drawable edge = (Drawable) edgeField.get(edgeEffect);
final Drawable glow = (Drawable) glowField.get(edgeEffect);
edge.setColorFilter(color, PorterDuff.Mode.SRC_IN);
glow.setColorFilter(color, PorterDuff.Mode.SRC_IN);
edge.setCallback(null); // free up any references
glow.setCallback(null); // free up any references
} catch (final Exception ignored) {
ignored.printStackTrace();
}
}
public PhotoViewPager(Context context, Adapter adapter) {
super(context);
setWillNotDraw(false);
float density = ResourceUtils.obtainDensity(context);
flingDistance = (int) (24 * density);
ViewConfiguration configuration = ViewConfiguration.get(context);
minimumVelocity = (int) (MIN_FLING_VELOCITY * density);
maximumVelocity = configuration.getScaledMaximumFlingVelocity();
touchSlop = configuration.getScaledTouchSlop();
scroller = new OverScroller(context);
edgeEffect = new EdgeEffect(context);
this.adapter = adapter;
for (int i = 0; i < 3; i++) {
View view = adapter.onCreateView(this);
super.addView(view, -1, generateDefaultLayoutParams());
photoViews.add(adapter.getPhotoView(view));
}
}
public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = ViewPager.class.getDeclaredField("mLeftEdge");
field.setAccessible(true);
EdgeEffect mLeftEdge = (EdgeEffect) field.get(viewPager);
if (mLeftEdge != null) {
mLeftEdge.setColor(color);
}
field = ViewPager.class.getDeclaredField("mRightEdge");
field.setAccessible(true);
EdgeEffect mRightEdge = (EdgeEffect) field.get(viewPager);
if (mRightEdge != null) {
mRightEdge.setColor(color);
}
} catch (Exception ignore) {
}
}
}
public static void setScrollViewEdgeEffectColor(HorizontalScrollView scrollView, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.setColor(color);
}
field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowBottom != null) {
mEdgeGlowBottom.setColor(color);
}
} catch (Exception e) {
FileLog.e(e);
}
}
}
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.setColor(color);
}
field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowBottom != null) {
mEdgeGlowBottom.setColor(color);
}
} catch (Exception e) {
FileLog.e(e);
}
}
}
public static void setViewPagerEdgeEffectColor(ViewPager viewPager, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = ViewPager.class.getDeclaredField("mLeftEdge");
field.setAccessible(true);
EdgeEffect mLeftEdge = (EdgeEffect) field.get(viewPager);
if (mLeftEdge != null) {
mLeftEdge.setColor(color);
}
field = ViewPager.class.getDeclaredField("mRightEdge");
field.setAccessible(true);
EdgeEffect mRightEdge = (EdgeEffect) field.get(viewPager);
if (mRightEdge != null) {
mRightEdge.setColor(color);
}
} catch (Exception ignore) {
}
}
}
public static void setScrollViewEdgeEffectColor(HorizontalScrollView scrollView, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowLeft");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.setColor(color);
}
field = HorizontalScrollView.class.getDeclaredField("mEdgeGlowRight");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowBottom != null) {
mEdgeGlowBottom.setColor(color);
}
} catch (Exception e) {
FileLog.e(e);
}
}
}
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color) {
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.setColor(color);
}
field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowBottom != null) {
mEdgeGlowBottom.setColor(color);
}
} catch (Exception e) {
FileLog.e(e);
}
}
}
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color)
{
if (Build.VERSION.SDK_INT >= 21)
{
try
{
Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowTop != null)
{
mEdgeGlowTop.setColor(color);
}
field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowBottom != null)
{
mEdgeGlowBottom.setColor(color);
}
}
catch (Exception e)
{
FileLog.e(e);
}
}
}
/**
* Set color of the supplied edge effect object.
*
* @param edgeEffect The edge effect object to set the color.
* @param color The edge effect color to be set.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setEdgeEffectColor(@Nullable Object edgeEffect, @ColorInt int color) {
initializeEdgeEffectFields();
if (edgeEffect instanceof EdgeEffectCompat) {
try {
F_EDGE_EFFECT_COMPAT_EDGE_EFFECT.setAccessible(true);
edgeEffect = F_EDGE_EFFECT_COMPAT_EDGE_EFFECT.get(edgeEffect);
} catch (IllegalAccessException illegalAccessException) {
return;
}
}
if (edgeEffect == null) {
return;
}
if (DynamicSdkUtils.is21()) {
((EdgeEffect) edgeEffect).setColor(color);
} else {
try {
F_EDGE_EFFECT_EDGE.setAccessible(true);
final Drawable mEdge = (Drawable) F_EDGE_EFFECT_EDGE.get(edgeEffect);
F_EDGE_EFFECT_GLOW.setAccessible(true);
final Drawable mGlow = (Drawable) F_EDGE_EFFECT_GLOW.get(edgeEffect);
if (mGlow != null) {
mGlow.setColorFilter(color, PorterDuff.Mode.SRC_IN);
mGlow.setCallback(null);
}
if (mEdge != null) {
mEdge.setColorFilter(color, PorterDuff.Mode.SRC_IN);
mEdge.setCallback(null);
}
} catch (Exception ignored) {
}
}
}
public static void setScrollViewEdgeEffectColor(ScrollView scrollView, int color)
{
if (Build.VERSION.SDK_INT >= 21)
{
try
{
Field field = ScrollView.class.getDeclaredField("mEdgeGlowTop");
field.setAccessible(true);
EdgeEffect mEdgeGlowTop = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowTop != null)
{
mEdgeGlowTop.setColor(color);
}
field = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
field.setAccessible(true);
EdgeEffect mEdgeGlowBottom = (EdgeEffect) field.get(scrollView);
if (mEdgeGlowBottom != null)
{
mEdgeGlowBottom.setColor(color);
}
}
catch (Exception e)
{
FileLog.e(e);
}
}
}
private void init() {
ViewConfiguration configuration = ViewConfiguration.get(getContext());
mScroller = new Scroller(getContext(), new LinearInterpolator());
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdgeEffect = new EdgeEffect(getContext());
mRightEdgeEffect = new EdgeEffect(getContext());
mShadePaint.setColor(Color.BLACK);
mShinePaint.setColor(Color.WHITE);
}
void initViewPager()
{
setWillNotDraw( false );
setDescendantFocusability( FOCUS_AFTER_DESCENDANTS );
setFocusable( true );
final Context context = getContext();
mScroller = new Scroller( context, sInterpolator );
final ViewConfiguration configuration = ViewConfiguration.get( context );
final float density = context.getResources().getDisplayMetrics().density;
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMinimumVelocity = (int) ( MIN_FLING_VELOCITY * density );
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdge = new EdgeEffect( context );
mRightEdge = new EdgeEffect( context );
mFlingDistance = (int) ( MIN_DISTANCE_FOR_FLING * density );
mCloseEnough = (int) ( CLOSE_ENOUGH * density );
mDefaultGutterSize = (int) ( DEFAULT_GUTTER_SIZE * density );
setAccessibilityDelegate( new MyAccessibilityDelegate() );
if ( this.getImportantForAccessibility()
== View.IMPORTANT_FOR_ACCESSIBILITY_AUTO )
{
setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_YES );
}
}
void initViewPager()
{
setWillNotDraw( false );
setDescendantFocusability( FOCUS_AFTER_DESCENDANTS );
setFocusable( true );
final Context context = getContext();
mScroller = new Scroller( context, sInterpolator );
final ViewConfiguration configuration = ViewConfiguration.get( context );
final float density = context.getResources().getDisplayMetrics().density;
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMinimumVelocity = (int) ( MIN_FLING_VELOCITY * density );
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdge = new EdgeEffect( context );
mRightEdge = new EdgeEffect( context );
mFlingDistance = (int) ( MIN_DISTANCE_FOR_FLING * density );
mCloseEnough = (int) ( CLOSE_ENOUGH * density );
mDefaultGutterSize = (int) ( DEFAULT_GUTTER_SIZE * density );
setAccessibilityDelegate( new MyAccessibilityDelegate() );
if ( this.getImportantForAccessibility()
== View.IMPORTANT_FOR_ACCESSIBILITY_AUTO )
{
setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_YES );
}
}
/**
* Controls whether the edge glows are enabled or not
*/
public void setEdgeEffectsEnabled(boolean val) {
mEdgeEffectsEnabled = val;
if (val) {
Context context = getContext();
setWillNotDraw(false);
mLeftEdge = new EdgeEffect(context);
mRightEdge = new EdgeEffect(context);
mTopEdge = new EdgeEffect(context);
mBottomEdge = new EdgeEffect(context);
} else {
setWillNotDraw(true);
mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
}
}
/**
* Controls whether the edge glows are enabled or not
*/
public void setEdgeEffectsEnabled(boolean val) {
mEdgeEffectsEnabled = val;
if (val) {
Context context = getContext();
setWillNotDraw(false);
mLeftEdge = new EdgeEffect(context);
mRightEdge = new EdgeEffect(context);
mTopEdge = new EdgeEffect(context);
mBottomEdge = new EdgeEffect(context);
} else {
setWillNotDraw(true);
mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
}
}
public PanView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// Sets up interactions
mGestureDetector = new GestureDetector(context, new ScrollFlingGestureListener());
mScroller = new OverScroller(context);
mEdgeEffectLeft = new EdgeEffect(context);
mEdgeEffectTop = new EdgeEffect(context);
mEdgeEffectRight = new EdgeEffect(context);
mEdgeEffectBottom = new EdgeEffect(context);
mDrawBlurredPaint = new Paint();
mDrawBlurredPaint.setDither(true);
}
public OverScrollGlow(View host) {
mHostView = host;
Context context = host.getContext();
mEdgeGlowTop = new EdgeEffect(context);
mEdgeGlowBottom = new EdgeEffect(context);
mEdgeGlowLeft = new EdgeEffect(context);
mEdgeGlowRight = new EdgeEffect(context);
}
public OverScrollGlow(View host) {
mHostView = host;
Context context = host.getContext();
mEdgeGlowTop = new EdgeEffect(context);
mEdgeGlowBottom = new EdgeEffect(context);
mEdgeGlowLeft = new EdgeEffect(context);
mEdgeGlowRight = new EdgeEffect(context);
}
/**
* Controls whether the edge glows are enabled or not
*/
public void setEdgeEffectsEnabled(boolean val) {
mEdgeEffectsEnabled = val;
if (val) {
Context context = getContext();
setWillNotDraw(false);
mLeftEdge = new EdgeEffect(context);
mRightEdge = new EdgeEffect(context);
mTopEdge = new EdgeEffect(context);
mBottomEdge = new EdgeEffect(context);
} else {
setWillNotDraw(true);
mLeftEdge = mRightEdge = mTopEdge = mBottomEdge = null;
}
}
void initViewPager() {
setWillNotDraw(false);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setFocusable(true);
final Context context = getContext();
mScroller = new Scroller(context, sInterpolator);
final ViewConfiguration configuration = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdge = new EdgeEffect(context);
mRightEdge = new EdgeEffect(context);
//添加顶部及底部的边缘效果
mTopEdge = new EdgeEffect(context);
mBottomEdge = new EdgeEffect(context);
mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
mCloseEnough = (int) (CLOSE_ENOUGH * density);
mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
ViewCompat.setAccessibilityDelegate(this, new CoolViewPager.MyAccessibilityDelegate());
if (ViewCompat.getImportantForAccessibility(this)
== ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
ViewCompat.setImportantForAccessibility(this,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
ViewCompat.setOnApplyWindowInsetsListener(this,
new android.support.v4.view.OnApplyWindowInsetsListener() {
private final Rect mTempRect = new Rect();
@Override
public WindowInsetsCompat onApplyWindowInsets(final View v,
final WindowInsetsCompat originalInsets) {
// First let the ViewPager itself try and consume them...
final WindowInsetsCompat applied =
ViewCompat.onApplyWindowInsets(v, originalInsets);
if (applied.isConsumed()) {
// If the ViewPager consumed all insets, return now
return applied;
}
// Now we'll manually dispatch the insets to our children. Since ViewPager
// children are always full-height, we do not want to use the standard
// ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
// the rest of the children will not receive any insets. To workaround this
// we manually dispatch the applied insets, not allowing children to
// consume them from each other. We do however keep track of any insets
// which are consumed, returning the union of our children's consumption
final Rect res = mTempRect;
res.left = applied.getSystemWindowInsetLeft();
res.top = applied.getSystemWindowInsetTop();
res.right = applied.getSystemWindowInsetRight();
res.bottom = applied.getSystemWindowInsetBottom();
for (int i = 0, count = getChildCount(); i < count; i++) {
final WindowInsetsCompat childInsets = ViewCompat
.dispatchApplyWindowInsets(getChildAt(i), applied);
// Now keep track of any consumed by tracking each dimension's min
// value
res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
res.left);
res.top = Math.min(childInsets.getSystemWindowInsetTop(),
res.top);
res.right = Math.min(childInsets.getSystemWindowInsetRight(),
res.right);
res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
res.bottom);
}
// Now return a new WindowInsets, using the consumed window insets
return applied.replaceSystemWindowInsets(
res.left, res.top, res.right, res.bottom);
}
});
}
void initSliderPager() {
setWillNotDraw(false);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setFocusable(true);
final Context context = getContext();
mScroller = new OwnScroller(context, DEFAULT_SCROLL_DURATION, sInterpolator);
final ViewConfiguration configuration = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mTouchSlop = configuration.getScaledPagingTouchSlop();
mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mLeftEdge = new EdgeEffect(context);
mRightEdge = new EdgeEffect(context);
mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
mCloseEnough = (int) (CLOSE_ENOUGH * density);
mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
if (ViewCompat.getImportantForAccessibility(this)
== ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
ViewCompat.setImportantForAccessibility(this,
ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
ViewCompat.setOnApplyWindowInsetsListener(this,
new androidx.core.view.OnApplyWindowInsetsListener() {
private final Rect mTempRect = new Rect();
@Override
public WindowInsetsCompat onApplyWindowInsets(final View v,
final WindowInsetsCompat originalInsets) {
// First let the SliderPager itself try and consume them...
final WindowInsetsCompat applied =
ViewCompat.onApplyWindowInsets(v, originalInsets);
if (applied.isConsumed()) {
// If the SliderPager consumed all insets, return now
return applied;
}
// Now we'll manually dispatch the insets to our children. Since SliderPager
// children are always full-height, we do not want to use the standard
// ViewGroup dispatchApplyWindowInsets since if child 0 consumes them,
// the rest of the children will not receive any insets. To workaround this
// we manually dispatch the applied insets, not allowing children to
// consume them from each other. We do however keep track of any insets
// which are consumed, returning the union of our children's consumption
final Rect res = mTempRect;
res.left = applied.getSystemWindowInsetLeft();
res.top = applied.getSystemWindowInsetTop();
res.right = applied.getSystemWindowInsetRight();
res.bottom = applied.getSystemWindowInsetBottom();
for (int i = 0, count = getChildCount(); i < count; i++) {
final WindowInsetsCompat childInsets = ViewCompat
.dispatchApplyWindowInsets(getChildAt(i), applied);
// Now keep track of any consumed by tracking each dimension's min
// value
res.left = Math.min(childInsets.getSystemWindowInsetLeft(),
res.left);
res.top = Math.min(childInsets.getSystemWindowInsetTop(),
res.top);
res.right = Math.min(childInsets.getSystemWindowInsetRight(),
res.right);
res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(),
res.bottom);
}
// Now return a new WindowInsets, using the consumed window insets
return applied.replaceSystemWindowInsets(
res.left, res.top, res.right, res.bottom);
}
});
}
/**
* Initialize edge effect or glow fields so that we can access them via reflection.
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static void initializeEdgeEffectFields() {
if (F_EDGE_EFFECT_EDGE != null
&& F_EDGE_EFFECT_GLOW != null
&& F_EDGE_EFFECT_COMPAT_EDGE_EFFECT != null) {
F_EDGE_EFFECT_EDGE.setAccessible(true);
F_EDGE_EFFECT_GLOW.setAccessible(true);
F_EDGE_EFFECT_COMPAT_EDGE_EFFECT.setAccessible(true);
return;
}
if (DynamicSdkUtils.is21()) {
F_EDGE_EFFECT_EDGE = null;
F_EDGE_EFFECT_GLOW = null;
} else if (DynamicSdkUtils.is14()) {
Field edge = null;
Field glow = null;
for (Field field : EdgeEffect.class.getDeclaredFields()) {
switch (field.getName()) {
case "mEdge":
field.setAccessible(true);
edge = field;
break;
case "mGlow":
field.setAccessible(true);
glow = field;
break;
}
}
F_EDGE_EFFECT_EDGE = edge;
F_EDGE_EFFECT_GLOW = glow;
}
Field edgeEffectCompat = null;
try {
edgeEffectCompat = EdgeEffectCompat.class.getDeclaredField("mEdgeEffect");
} catch (NoSuchFieldException ignored) {
}
F_EDGE_EFFECT_COMPAT_EDGE_EFFECT = edgeEffectCompat;
}
protected void setupEdgeEffect(Context context) {
// Sets up edge effects
mEdgeEffectLeft = new EdgeEffect(context);
mEdgeEffectRight = new EdgeEffect(context);
}
protected void setupEdgeEffect(Context context) {
// Sets up edge effects
mEdgeEffectLeft = new EdgeEffect(context);
mEdgeEffectRight = new EdgeEffect(context);
}
public static Object a(Context context)
{
return new EdgeEffect(context);
}
public static void a(Object obj, int i, int j)
{
((EdgeEffect)obj).setSize(i, j);
}