Get rid of EdgeEffectCompat
This commit is contained in:
parent
9fc51aac3d
commit
5e06b6e030
@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package android.support.v4.view;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.view.View;
|
||||
import android.widget.EdgeEffect;
|
||||
|
||||
/**
|
||||
* Wrapper around {@link EdgeEffect} for compatibility with older versions of
|
||||
* Android.
|
||||
*/
|
||||
@TargetApi(14)
|
||||
public class EdgeEffectCompat {
|
||||
/**
|
||||
* The wrapped EdgeEffect.
|
||||
*/
|
||||
private EdgeEffect mEdge;
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#EdgeEffect(Context)}.
|
||||
*/
|
||||
public EdgeEffectCompat(Context context)
|
||||
{
|
||||
mEdge = new EdgeEffect(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#onPull(float)}.
|
||||
*/
|
||||
public void onPull(float deltaDistance)
|
||||
{
|
||||
mEdge.onPull(deltaDistance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#finish()}.
|
||||
*/
|
||||
public void finish()
|
||||
{
|
||||
mEdge.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#isFinished()}.
|
||||
*/
|
||||
public boolean isFinished()
|
||||
{
|
||||
return mEdge.isFinished();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#onRelease()}.
|
||||
*/
|
||||
public void onRelease()
|
||||
{
|
||||
mEdge.onRelease();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#draw(Canvas)}.
|
||||
*/
|
||||
public boolean draw(Canvas canvas)
|
||||
{
|
||||
return mEdge.draw(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link EdgeEffect#setSize(int,int)}.
|
||||
*/
|
||||
public void setSize(int width, int height)
|
||||
{
|
||||
mEdge.setSize(width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link View#getOverScrollMode()}.
|
||||
*
|
||||
* (This is unrelated to EdgeEffect; it's thrown in here since ViewPager
|
||||
* also uses it.)
|
||||
*/
|
||||
public static int getOverScrollMode(View view)
|
||||
{
|
||||
return view.getOverScrollMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link View#canScrollHorizontally(int)}.
|
||||
*
|
||||
* (This is unrelated to EdgeEffect; it's thrown in here since ViewPager
|
||||
* also uses it.)
|
||||
*/
|
||||
public static boolean canScrollHorizontally(View view, int direction)
|
||||
{
|
||||
return view.canScrollHorizontally(direction);
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ import android.view.ViewParent;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.Scroller;
|
||||
import android.widget.EdgeEffect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -152,8 +153,8 @@ public class ViewPager extends ViewGroup {
|
||||
private boolean mFakeDragging;
|
||||
private long mFakeDragBeginTime;
|
||||
|
||||
private EdgeEffectCompat mLeftEdge;
|
||||
private EdgeEffectCompat mRightEdge;
|
||||
private EdgeEffect mLeftEdge;
|
||||
private EdgeEffect mRightEdge;
|
||||
|
||||
private boolean mFirstLayout = true;
|
||||
private boolean mCalledSuper;
|
||||
@ -256,8 +257,8 @@ public class ViewPager extends ViewGroup {
|
||||
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
|
||||
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
mLeftEdge = new EdgeEffectCompat(context);
|
||||
mRightEdge = new EdgeEffectCompat(context);
|
||||
mLeftEdge = new EdgeEffect(context);
|
||||
mRightEdge = new EdgeEffect(context);
|
||||
}
|
||||
|
||||
final float density = context.getResources().getDisplayMetrics().density;
|
||||
@ -1570,7 +1571,7 @@ public class ViewPager extends ViewGroup {
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
boolean needsInvalidate = false;
|
||||
|
||||
final int overScrollMode = EdgeEffectCompat.getOverScrollMode(this);
|
||||
final int overScrollMode = this.getOverScrollMode();
|
||||
if (overScrollMode == View.OVER_SCROLL_ALWAYS ||
|
||||
(overScrollMode == View.OVER_SCROLL_IF_CONTENT_SCROLLS &&
|
||||
mAdapter != null && mAdapter.getCount() > 1)) {
|
||||
@ -1820,7 +1821,7 @@ public class ViewPager extends ViewGroup {
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
return checkV && EdgeEffectCompat.canScrollHorizontally(v, -dx);
|
||||
return checkV && v.canScrollHorizontally(-dx);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user