Skip to content

Commit

Permalink
Invalid pointer fix and getClass fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeinstein10 committed Dec 9, 2013
1 parent e9721f7 commit d929476
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Expand Up @@ -732,9 +732,6 @@ public boolean onTouchEvent(MotionEvent ev) {
int initialVelocity = (int) VelocityTrackerCompat.getXVelocity( int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
velocityTracker, mActivePointerId); velocityTracker, mActivePointerId);
final int scrollX = getScrollX(); final int scrollX = getScrollX();
// final int widthWithMargin = getWidth();
// final float pageOffset = (float) (scrollX % widthWithMargin) / widthWithMargin;
// TODO test this. should get better flinging behavior
final float pageOffset = (float) (scrollX - getDestScrollX(mCurItem)) / getBehindWidth(); final float pageOffset = (float) (scrollX - getDestScrollX(mCurItem)) / getBehindWidth();
final int activePointerIndex = getPointerIndex(ev, mActivePointerId); final int activePointerIndex = getPointerIndex(ev, mActivePointerId);
if (mActivePointerId != INVALID_POINTER) { if (mActivePointerId != INVALID_POINTER) {
Expand Down Expand Up @@ -780,7 +777,7 @@ public boolean onTouchEvent(MotionEvent ev) {
private void determineDrag(MotionEvent ev) { private void determineDrag(MotionEvent ev) {
final int activePointerId = mActivePointerId; final int activePointerId = mActivePointerId;
final int pointerIndex = getPointerIndex(ev, activePointerId); final int pointerIndex = getPointerIndex(ev, activePointerId);
if (activePointerId == INVALID_POINTER) if (activePointerId == INVALID_POINTER || pointerIndex == INVALID_POINTER)
return; return;
final float x = MotionEventCompat.getX(ev, pointerIndex); final float x = MotionEventCompat.getX(ev, pointerIndex);
final float dx = x - mLastMotionX; final float dx = x - mLastMotionX;
Expand Down
Expand Up @@ -31,7 +31,7 @@


public class SlidingMenu extends RelativeLayout { public class SlidingMenu extends RelativeLayout {


private static final String TAG = getClass().getSimpleName(); private static final String TAG = SlidingMenu.class.getSimpleName();


public static final int SLIDING_WINDOW = 0; public static final int SLIDING_WINDOW = 0;
public static final int SLIDING_CONTENT = 1; public static final int SLIDING_CONTENT = 1;
Expand Down Expand Up @@ -997,8 +997,6 @@ protected boolean fitSystemWindows(Rect insets) {
} }
return true; return true;
} }

private Handler mHandler = new Handler();


@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) { public void manageLayers(float percentOpen) {
Expand All @@ -1008,7 +1006,7 @@ public void manageLayers(float percentOpen) {
final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE; final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;


if (layerType != getContent().getLayerType()) { if (layerType != getContent().getLayerType()) {
mHandler.post(new Runnable() { getHandler().post(new Runnable() {
public void run() { public void run() {
Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE)); Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
getContent().setLayerType(layerType, null); getContent().setLayerType(layerType, null);
Expand Down

0 comments on commit d929476

Please sign in to comment.