Skip to content

Commit 7cea5c6

Browse files
Merge pull request Cleveroad#38 from Cleveroad/develop
Develop
2 parents 55918e4 + 4ef13c1 commit 7cea5c6

File tree

10 files changed

+68
-269
lines changed

10 files changed

+68
-269
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
Version | Changes
88
--- | ---
9+
v.1.0.5 | Fixed NullPointerException & IndexOutOfBoundsException inside ViewPager. Added SlidingTutorialViewPager
910
v.1.0.4 | Added ability to set PageTransformer
1011
v.1.0.3 | Fixed issues with layout customizations. Fixed issues with translate animations
1112
v.1.0.2 | Minor fixes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ All you need to do is:
3131
First, add gradle dependency into your build.gradle:
3232
```groovy
3333
dependencies {
34-
compile 'com.cleveroad:slidingtutorial:1.0.4'
34+
compile 'com.cleveroad:slidingtutorial:1.0.5'
3535
}
3636
```
3737

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VERSION_NAME=1.0.4
2-
VERSION_CODE=14
1+
VERSION_NAME=1.0.5
2+
VERSION_CODE=15
33
GROUP=com.cleveroad
44

55
POM_DESCRIPTION=Sliding tutorial is simple library that help other developers easy create great tutotial

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

gradlew

Lines changed: 0 additions & 164 deletions
This file was deleted.

gradlew.bat

Lines changed: 0 additions & 90 deletions
This file was deleted.

lib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 14
99
targetSdkVersion 24
10-
versionCode 14
11-
versionName "1.0.4"
10+
versionCode 15
11+
versionName "1.0.5"
1212
}
1313
buildTypes {
1414
release {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.cleveroad.slidingtutorial;
2+
3+
import android.content.Context;
4+
import android.graphics.Canvas;
5+
import android.support.v4.view.ViewPager;
6+
import android.util.AttributeSet;
7+
import android.view.MotionEvent;
8+
9+
/**
10+
* {@link SlidingTutorialViewPager} fix well-known bug (Issue 66620) when:
11+
* - {@link ViewPager#getChildDrawingOrder(int, int)} throws {@link ArrayIndexOutOfBoundsException}
12+
* - {@link ViewPager#dispatchDraw(Canvas)} throws {@link NullPointerException}
13+
* <p>
14+
* This error is produced only in the SDK older than 17 (JELLY_BEAN_MR1).
15+
*
16+
* @see <a href="https://code.google.com/p/android/issues/detail?id=66620">Issue 66620</a>
17+
*/
18+
public class SlidingTutorialViewPager extends ViewPager {
19+
public SlidingTutorialViewPager(Context context) {
20+
super(context);
21+
}
22+
23+
public SlidingTutorialViewPager(Context context, AttributeSet attrs) {
24+
super(context, attrs);
25+
}
26+
27+
@Override
28+
public boolean onInterceptTouchEvent(MotionEvent event) {
29+
if (getAdapter() == null || getAdapter().getCount() == 0) {
30+
return false;
31+
}
32+
return super.onInterceptTouchEvent(event);
33+
}
34+
35+
@Override
36+
public boolean onTouchEvent(MotionEvent ev) {
37+
if (getAdapter() == null || getAdapter().getCount() == 0) {
38+
return false;
39+
}
40+
return super.onTouchEvent(ev);
41+
}
42+
43+
@Override
44+
protected int getChildDrawingOrder(int childCount, int i) {
45+
try {
46+
return super.getChildDrawingOrder(childCount, i);
47+
} catch (IndexOutOfBoundsException ignored) {
48+
}
49+
50+
return 0;
51+
}
52+
53+
@Override
54+
protected void dispatchDraw(Canvas canvas) {
55+
try {
56+
super.dispatchDraw(canvas);
57+
} catch (NullPointerException ignored) {
58+
}
59+
}
60+
}

sample/src/main/res/layout/custom_tutorial_layout.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
54
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
87
tools:background="@android:color/darker_gray">
98

10-
<android.support.v4.view.ViewPager
9+
<com.cleveroad.slidingtutorial.SlidingTutorialViewPager
1110
android:id="@+id/viewPager"
1211
android:layout_width="match_parent"
1312
android:layout_height="match_parent"/>

sample/src/main/res/layout/custom_tutorial_layout_ids_example.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<FrameLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
54
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
87
tools:background="@android:color/darker_gray">
98

10-
<android.support.v4.view.ViewPager
9+
<com.cleveroad.slidingtutorial.SlidingTutorialViewPager
1110
android:id="@+id/viewPagerCustom"
1211
android:layout_width="match_parent"
1312
android:layout_height="match_parent"/>

0 commit comments

Comments
 (0)