Skip to content

Commit 61f19ff

Browse files
committed
Merge pull request Cleveroad#2 from Cleveroad/develop
Infinite scroll behavior
2 parents 2eac45c + 92b03f0 commit 61f19ff

22 files changed

+969
-868
lines changed

README.md

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ All you need to do is:
1616

1717
First, add gradle dependency with command:<br>
1818
```groovy
19-
dependencies {
20-
compile 'com.cleveroad:slidingtutorial:0.9'
21-
}
19+
dependencies {
20+
compile 'com.cleveroad:slidingtutorial:0.9.1'
21+
}
2222
```
2323

2424
After you have to create each fragment that must extend from PageFragment. Also you have to create your xml file with images.
@@ -28,21 +28,13 @@ public class FirstCustomPageFragment extends PageFragment {
2828

2929
@Override
3030
protected int getLayoutResId() {
31+
// layout id of fragment
3132
return R.layout.fragment_page_first;
3233
}
3334

34-
@Override
35-
protected int getBackgroundColorResId() {
36-
return android.R.color.holo_orange_dark;
37-
}
38-
39-
@Override
40-
public int getRootResId() {
41-
return R.id.rootFirstPage;
42-
}
43-
4435
@Override
4536
protected TransformItem[] provideTransformItems() {
37+
// list of transformation items
4638
return new TransformItem[]{
4739
new TransformItem(R.id.ivFirstImage, true, 20),
4840
new TransformItem(R.id.ivSecondImage, false, 6),
@@ -62,37 +54,93 @@ Then you should provide these fragments in main slidingtutroial fragment
6254
```java
6355
public class CustomPresentationPagerFragment extends PresentationPagerFragment {
6456

65-
@Override
66-
protected List<? extends PageFragment> getPageFragments() {
67-
List<PageFragment> pageFragments = new ArrayList<>();
68-
pageFragments.add(new FirstCustomPageFragment());
69-
pageFragments.add(new SecondCustomPageFragment());
70-
pageFragments.add(new ThirdCustomPageFragment());
71-
return pageFragments;
72-
}
73-
7457
@Override
7558
public int getLayoutResId() {
59+
// layout id of fragment
7660
return R.layout.fragment_presentation;
7761
}
7862

7963
@Override
8064
public int getViewPagerResId() {
65+
// id of view pager
8166
return R.id.viewPager;
8267
}
8368

8469
@Override
8570
public int getIndicatorResId() {
71+
// id of circular indicator
8672
return R.id.indicator;
8773
}
8874

8975
@Override
9076
public int getButtonSkipResId() {
77+
// id of skip button
9178
return R.id.tvSkip;
9279
}
80+
81+
@Override
82+
protected int getPagesCount() {
83+
// total number of pages
84+
return 3;
85+
}
86+
87+
@Override
88+
protected PageFragment getPage(int position) {
89+
// get page for position
90+
if (position == 0)
91+
return new FirstCustomPageFragment();
92+
if (position == 1)
93+
return new SecondCustomPageFragment();
94+
if (position == 2)
95+
return new ThirdCustomPageFragment();
96+
throw new IllegalArgumentException("Unknown position: " + position);
97+
}
98+
99+
@ColorInt
100+
@Override
101+
protected int getPageColor(int position) {
102+
// get color of page
103+
if (position == 0)
104+
return ContextCompat.getColor(getContext(), android.R.color.holo_orange_dark);
105+
if (position == 1)
106+
return ContextCompat.getColor(getContext(), android.R.color.holo_green_dark);
107+
if (position == 2)
108+
return ContextCompat.getColor(getContext(), android.R.color.holo_blue_dark);
109+
return Color.TRANSPARENT;
110+
}
111+
112+
@Override
113+
protected boolean isInfiniteScrollEnabled() {
114+
// enable/disable infinite scroll behavior
115+
return true;
116+
}
93117
}
94118
```
95119

120+
## Changelog
121+
122+
| Version | Changes |
123+
| --- | --- |
124+
| v.0.9.1 | Added infinite scroll behavior |
125+
| v.0.9 | First public release |
126+
127+
## Migrations from v.0.9 to v.0.9.1
128+
####CirclePageIndicator
129+
This class is final now. Make sure you're not extending from it.
130+
131+
####LayersHolder
132+
This class is package-local now. Make sure you're not using it.
133+
134+
####PageFragment
135+
**getRootResId()** and **getBackgroundColorResId()** methods are deprecated. You can remove them now. To specify page's color use **PresentationPagerFragment.getPageColor(int)** method.
136+
137+
####PresentationPagerFragment
138+
**getPageFragments()** method is deprecated. You can remove it now. Use **getPagesCount()** and **getPage(int)** methods instead.
139+
140+
Added **isInfinityScrollEnabled()** method. Override it and return `true` to enable this feature.
141+
142+
**NOTE:** make sure you're returning new fragment instance when displaying tutorial with infinite scroll enabled.
143+
96144
## Support
97145
If you have any questions regarding the use of this tutorial, please contact us for support
98146
at info@cleveroad.com (email subject: «Sliding android app tutorial. Support request.»)
@@ -108,7 +156,7 @@ at info@cleveroad.com (email subject: «Sliding android app tutorial. Support re
108156

109157
The MIT License (MIT)
110158

111-
Copyright (c) 2015 Cleveroad
159+
Copyright (c) 2015-2016 Cleveroad
112160

113161
Permission is hereby granted, free of charge, to any person obtaining a copy
114162
of this software and associated documentation files (the "Software"), to deal

gradle.properties

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

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

lib/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
22

33
android {
44
compileSdkVersion 23
5-
buildToolsVersion "23.0.1"
5+
buildToolsVersion "23.0.2"
66

77
defaultConfig {
88
minSdkVersion 14
@@ -21,7 +21,7 @@ android {
2121
dependencies {
2222
compile fileTree(dir: 'libs', include: ['*.jar'])
2323
testCompile 'junit:junit:4.12'
24-
compile 'com.android.support:appcompat-v7:23.0.1'
24+
compile 'com.android.support:appcompat-v7:23.1.1'
2525
}
2626

2727
apply from: './gradle-mvn-push.gradle'

0 commit comments

Comments
 (0)