use of android.widget.EdgeEffect in project android-support-v4-googlemaps by petedoyle.
the class EdgeEffectCompatIcs method onRelease.
public static boolean onRelease(Object edgeEffect) {
EdgeEffect eff = (EdgeEffect) edgeEffect;
eff.onRelease();
return eff.isFinished();
}
use of android.widget.EdgeEffect in project FreeFlow by Comcast.
the class FreeFlowContainer method setEdgeEffectsEnabled.
/**
* 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;
}
}
use of android.widget.EdgeEffect in project android_frameworks_base by crdroidandroid.
the class ViewPager method performDrag.
private boolean performDrag(float x) {
boolean needsInvalidate = false;
final int width = getPaddedWidth();
final float deltaX = mLastMotionX - x;
mLastMotionX = x;
final EdgeEffect startEdge;
final EdgeEffect endEdge;
if (isLayoutRtl()) {
startEdge = mRightEdge;
endEdge = mLeftEdge;
} else {
startEdge = mLeftEdge;
endEdge = mRightEdge;
}
// Translate scroll to relative coordinates.
final float nextScrollX = getScrollX() + deltaX;
final float scrollStart;
if (isLayoutRtl()) {
scrollStart = MAX_SCROLL_X - nextScrollX;
} else {
scrollStart = nextScrollX;
}
final float startBound;
final ItemInfo startItem = mItems.get(0);
final boolean startAbsolute = startItem.position == 0;
if (startAbsolute) {
startBound = startItem.offset * width;
} else {
startBound = width * mFirstOffset;
}
final float endBound;
final ItemInfo endItem = mItems.get(mItems.size() - 1);
final boolean endAbsolute = endItem.position == mAdapter.getCount() - 1;
if (endAbsolute) {
endBound = endItem.offset * width;
} else {
endBound = width * mLastOffset;
}
final float clampedScrollStart;
if (scrollStart < startBound) {
if (startAbsolute) {
final float over = startBound - scrollStart;
startEdge.onPull(Math.abs(over) / width);
needsInvalidate = true;
}
clampedScrollStart = startBound;
} else if (scrollStart > endBound) {
if (endAbsolute) {
final float over = scrollStart - endBound;
endEdge.onPull(Math.abs(over) / width);
needsInvalidate = true;
}
clampedScrollStart = endBound;
} else {
clampedScrollStart = scrollStart;
}
// Translate back to absolute coordinates.
final float targetScrollX;
if (isLayoutRtl()) {
targetScrollX = MAX_SCROLL_X - clampedScrollStart;
} else {
targetScrollX = clampedScrollStart;
}
// Don't lose the rounded component.
mLastMotionX += targetScrollX - (int) targetScrollX;
scrollTo((int) targetScrollX, getScrollY());
pageScrolled((int) targetScrollX);
return needsInvalidate;
}
use of android.widget.EdgeEffect in project platform_frameworks_base by android.
the class ViewPager method performDrag.
private boolean performDrag(float x) {
boolean needsInvalidate = false;
final int width = getPaddedWidth();
final float deltaX = mLastMotionX - x;
mLastMotionX = x;
final EdgeEffect startEdge;
final EdgeEffect endEdge;
if (isLayoutRtl()) {
startEdge = mRightEdge;
endEdge = mLeftEdge;
} else {
startEdge = mLeftEdge;
endEdge = mRightEdge;
}
// Translate scroll to relative coordinates.
final float nextScrollX = getScrollX() + deltaX;
final float scrollStart;
if (isLayoutRtl()) {
scrollStart = MAX_SCROLL_X - nextScrollX;
} else {
scrollStart = nextScrollX;
}
final float startBound;
final ItemInfo startItem = mItems.get(0);
final boolean startAbsolute = startItem.position == 0;
if (startAbsolute) {
startBound = startItem.offset * width;
} else {
startBound = width * mFirstOffset;
}
final float endBound;
final ItemInfo endItem = mItems.get(mItems.size() - 1);
final boolean endAbsolute = endItem.position == mAdapter.getCount() - 1;
if (endAbsolute) {
endBound = endItem.offset * width;
} else {
endBound = width * mLastOffset;
}
final float clampedScrollStart;
if (scrollStart < startBound) {
if (startAbsolute) {
final float over = startBound - scrollStart;
startEdge.onPull(Math.abs(over) / width);
needsInvalidate = true;
}
clampedScrollStart = startBound;
} else if (scrollStart > endBound) {
if (endAbsolute) {
final float over = scrollStart - endBound;
endEdge.onPull(Math.abs(over) / width);
needsInvalidate = true;
}
clampedScrollStart = endBound;
} else {
clampedScrollStart = scrollStart;
}
// Translate back to absolute coordinates.
final float targetScrollX;
if (isLayoutRtl()) {
targetScrollX = MAX_SCROLL_X - clampedScrollStart;
} else {
targetScrollX = clampedScrollStart;
}
// Don't lose the rounded component.
mLastMotionX += targetScrollX - (int) targetScrollX;
scrollTo((int) targetScrollX, getScrollY());
pageScrolled((int) targetScrollX);
return needsInvalidate;
}
use of android.widget.EdgeEffect in project FlipViewPager.Draco by Yalantis.
the class FlipViewPager method init.
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);
}
Aggregations