diff --git a/library/build.gradle b/library/build.gradle index e2a5bf978..089c4112a 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -3,22 +3,22 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:0.4.+' + classpath 'com.android.tools.build:gradle:0.12.+' } } -apply plugin: 'android-library' +apply plugin: 'com.android.library' dependencies { - compile 'com.android.support:support-v4:13.0.0' + compile 'com.android.support:support-v4:20.0.0' } android { - compileSdkVersion 17 - buildToolsVersion "17.0.0" + compileSdkVersion 20 + buildToolsVersion "20.0.0" defaultConfig { minSdkVersion 7 - targetSdkVersion 16 + targetSdkVersion 20 } sourceSets { diff --git a/library/library.iml b/library/library.iml index a6e3c8f47..8aa3d0bd3 100644 --- a/library/library.iml +++ b/library/library.iml @@ -1,19 +1,88 @@ - + + + + + + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - + \ No newline at end of file diff --git a/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java b/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java index fa73ef05b..5d1a71981 100644 --- a/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java +++ b/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java @@ -779,21 +779,27 @@ private void determineDrag(MotionEvent ev) { final int pointerIndex = getPointerIndex(ev, activePointerId); if (activePointerId == INVALID_POINTER || pointerIndex == INVALID_POINTER) return; - final float x = MotionEventCompat.getX(ev, pointerIndex); - final float dx = x - mLastMotionX; - final float xDiff = Math.abs(dx); - final float y = MotionEventCompat.getY(ev, pointerIndex); - final float dy = y - mLastMotionY; - final float yDiff = Math.abs(dy); - if (xDiff > (isMenuOpen()?mTouchSlop/2:mTouchSlop) && xDiff > yDiff && thisSlideAllowed(dx)) { - startDrag(); - mLastMotionX = x; - mLastMotionY = y; - setScrollingCacheEnabled(true); - // TODO add back in touch slop check - } else if (xDiff > mTouchSlop) { - mIsUnableToDrag = true; - } + try { + final float x = MotionEventCompat.getX(ev, pointerIndex); + final float dx = x - mLastMotionX; + final float xDiff = Math.abs(dx); + final float y = MotionEventCompat.getY(ev, pointerIndex); + final float dy = y - mLastMotionY; + final float yDiff = Math.abs(dy); + if (xDiff > (isMenuOpen()?mTouchSlop/2:mTouchSlop) && xDiff > yDiff && thisSlideAllowed(dx)) { + startDrag(); + mLastMotionX = x; + mLastMotionY = y; + setScrollingCacheEnabled(true); + // TODO add back in touch slop check + } else if (xDiff > mTouchSlop) { + mIsUnableToDrag = true; + } + } + catch (ArrayIndexOutOfBoundsException e) { + // Ignore. Occasionally happens in MotionEventCompat.getX + // Known problem, caused in Android Framework + } } @Override diff --git a/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java b/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java index 8b88708b9..0a879508a 100644 --- a/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java +++ b/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java @@ -1008,12 +1008,17 @@ public void manageLayers(float percentOpen) { if (layerType != getContent().getLayerType()) { getHandler().post(new Runnable() { public void run() { - Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE)); - getContent().setLayerType(layerType, null); - getMenu().setLayerType(layerType, null); - if (getSecondaryMenu() != null) { - getSecondaryMenu().setLayerType(layerType, null); - } + try { + Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE)); + getContent().setLayerType(layerType, null); + getMenu().setLayerType(layerType, null); + if (getSecondaryMenu() != null) { + getSecondaryMenu().setLayerType(layerType, null); + } + } + catch (NullPointerException e) { + // Happens on some motorola devices + } } }); }