Skip to content

Commit 99390e0

Browse files
committed
fixed issue with non working override methods TutorialFragment#getLayoutResId(), #getViewPagerId() and etc..
1 parent b0010a3 commit 99390e0

File tree

7 files changed

+140
-26
lines changed

7 files changed

+140
-26
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
8+
classpath 'com.android.tools.build:gradle:2.2.0-rc1'
99

1010
// NOTE: Do not place your application dependencies here; they belong
1111
// in the individual module build.gradle files

lib/src/main/java/com/cleveroad/slidingtutorial/TutorialFragment.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public void removeCurrentFragment() {
7272
.commitAllowingStateLoss();
7373
}
7474

75+
@Override
76+
public int getLayoutResId() {
77+
return TutorialFragment.this.getLayoutResId();
78+
}
79+
7580
@Override
7681
public PagerAdapter getPagerAdapter() {
7782
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
@@ -80,6 +85,26 @@ public PagerAdapter getPagerAdapter() {
8085
return new TutorialAdapter(getFragmentManager());
8186
}
8287
}
88+
89+
@Override
90+
public int getViewPagerResId() {
91+
return TutorialFragment.this.getViewPagerResId();
92+
}
93+
94+
@Override
95+
public int getIndicatorResId() {
96+
return TutorialFragment.this.getIndicatorResId();
97+
}
98+
99+
@Override
100+
public int getButtonSkipResId() {
101+
return TutorialFragment.this.getButtonSkipResId();
102+
}
103+
104+
@Override
105+
public int getSeparatorResId() {
106+
return TutorialFragment.this.getSeparatorResId();
107+
}
83108
};
84109

85110
/**
@@ -181,27 +206,27 @@ public boolean removeOnTutorialPageChangeListener(@NonNull OnTutorialPageChangeL
181206

182207
@LayoutRes
183208
protected int getLayoutResId() {
184-
return mTutorial.getLayoutResId();
209+
return mTutorial.getDefaultLayoutResId();
185210
}
186211

187212
@IdRes
188213
protected int getViewPagerResId() {
189-
return mTutorial.getViewPagerResId();
214+
return mTutorial.getDefaultViewPagerResId();
190215
}
191216

192217
@IdRes
193218
protected int getIndicatorResId() {
194-
return mTutorial.getIndicatorResId();
219+
return mTutorial.getDefaultIndicatorResId();
195220
}
196221

197222
@IdRes
198223
protected int getButtonSkipResId() {
199-
return mTutorial.getButtonSkipResId();
224+
return mTutorial.getDefaultButtonSkipResId();
200225
}
201226

202227
@IdRes
203228
protected int getSeparatorResId() {
204-
return mTutorial.getSeparatorResId();
229+
return mTutorial.getDefaultSeparatorResId();
205230
}
206231

207232
/**

lib/src/main/java/com/cleveroad/slidingtutorial/TutorialImpl.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public void onChanged() {
7070
}
7171

7272
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
73-
View view = inflater.inflate(getLayoutResId(), container, false);
73+
View view = inflater.inflate(mInternalFragment.getLayoutResId(), container, false);
7474

75-
mViewPager = (ViewPager) view.findViewById(getViewPagerResId());
76-
mPageIndicator = (TutorialPageIndicator) view.findViewById(getIndicatorResId());
77-
mButtonSkip = view.findViewById(getButtonSkipResId());
78-
mSeparator = view.findViewById(getSeparatorResId());
75+
mViewPager = (ViewPager) view.findViewById(mInternalFragment.getViewPagerResId());
76+
mPageIndicator = (TutorialPageIndicator) view.findViewById(mInternalFragment.getIndicatorResId());
77+
mButtonSkip = view.findViewById(mInternalFragment.getButtonSkipResId());
78+
mSeparator = view.findViewById(mInternalFragment.getSeparatorResId());
7979

8080
mViewPager.setPageTransformer(true, new FragmentTransformer());
8181
mViewPager.addOnPageChangeListener(new InternalHelperPageChangeDecorator());
@@ -173,27 +173,27 @@ boolean removeOnTutorialPageChangeListener(@NonNull OnTutorialPageChangeListener
173173
}
174174

175175
@LayoutRes
176-
int getLayoutResId() {
176+
int getDefaultLayoutResId() {
177177
return R.layout.st_fragment_presentation;
178178
}
179179

180180
@IdRes
181-
int getViewPagerResId() {
181+
int getDefaultViewPagerResId() {
182182
return R.id.viewPager;
183183
}
184184

185185
@IdRes
186-
int getIndicatorResId() {
186+
int getDefaultIndicatorResId() {
187187
return R.id.indicator;
188188
}
189189

190190
@IdRes
191-
int getButtonSkipResId() {
191+
int getDefaultButtonSkipResId() {
192192
return R.id.tvSkip;
193193
}
194194

195195
@IdRes
196-
int getSeparatorResId() {
196+
int getDefaultSeparatorResId() {
197197
return R.id.separator;
198198
}
199199

@@ -306,6 +306,21 @@ interface InternalFragment {
306306
PagerAdapter getPagerAdapter();
307307

308308
void removeCurrentFragment();
309+
310+
@LayoutRes
311+
int getLayoutResId();
312+
313+
@IdRes
314+
int getViewPagerResId();
315+
316+
@IdRes
317+
int getIndicatorResId();
318+
319+
@IdRes
320+
int getButtonSkipResId();
321+
322+
@IdRes
323+
int getSeparatorResId();
309324
}
310325

311326
@SuppressWarnings("unused")

lib/src/main/java/com/cleveroad/slidingtutorial/TutorialSupportFragment.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,32 @@ public void removeCurrentFragment() {
7575
public PagerAdapter getPagerAdapter() {
7676
return new TutorialAdapter(getChildFragmentManager());
7777
}
78+
79+
@Override
80+
public int getLayoutResId() {
81+
return TutorialSupportFragment.this.getLayoutResId();
82+
}
83+
84+
@Override
85+
public int getViewPagerResId() {
86+
return TutorialSupportFragment.this.getViewPagerResId();
87+
}
88+
89+
@Override
90+
public int getIndicatorResId() {
91+
return TutorialSupportFragment.this.getIndicatorResId();
92+
}
93+
94+
@Override
95+
public int getButtonSkipResId() {
96+
return TutorialSupportFragment.this.getButtonSkipResId();
97+
}
98+
99+
@Override
100+
public int getSeparatorResId() {
101+
return TutorialSupportFragment.this.getSeparatorResId();
102+
}
103+
78104
};
79105

80106
/**
@@ -176,27 +202,27 @@ public boolean removeOnTutorialPageChangeListener(@NonNull OnTutorialPageChangeL
176202

177203
@LayoutRes
178204
protected int getLayoutResId() {
179-
return mTutorial.getLayoutResId();
205+
return mTutorial.getDefaultLayoutResId();
180206
}
181207

182208
@IdRes
183209
protected int getViewPagerResId() {
184-
return mTutorial.getViewPagerResId();
210+
return mTutorial.getDefaultViewPagerResId();
185211
}
186212

187213
@IdRes
188214
protected int getIndicatorResId() {
189-
return mTutorial.getIndicatorResId();
215+
return mTutorial.getDefaultIndicatorResId();
190216
}
191217

192218
@IdRes
193219
protected int getButtonSkipResId() {
194-
return mTutorial.getButtonSkipResId();
220+
return mTutorial.getDefaultButtonSkipResId();
195221
}
196222

197223
@IdRes
198224
protected int getSeparatorResId() {
199-
return mTutorial.getSeparatorResId();
225+
return mTutorial.getDefaultSeparatorResId();
200226
}
201227

202228
/**

lib/src/main/res/layout/st_empty_fragment.xml

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

sample/src/main/java/com/cleveroad/slidingtutorial/sample/support/CustomTutorialSupportFragment.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ protected TutorialOptions provideTutorialOptions() {
150150
.build();
151151
}
152152

153+
@Override
154+
protected int getLayoutResId() {
155+
return R.layout.custom_tutorial_layout;
156+
}
157+
153158
@Override
154159
public void onPageChanged(int position) {
155160
Log.i(TAG, "onPageChanged: position = " + position);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:background="@android:color/darker_gray">
9+
10+
<android.support.v4.view.ViewPager
11+
android:id="@+id/viewPager"
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent"/>
14+
15+
<FrameLayout
16+
android:layout_width="match_parent"
17+
android:layout_height="50dp"
18+
android:layout_gravity="bottom|center_horizontal">
19+
20+
<View
21+
android:id="@+id/separator"
22+
android:layout_width="match_parent"
23+
android:layout_height="0.1dp"
24+
android:background="@android:color/white"/>
25+
26+
<TextView
27+
android:id="@+id/tvSkip"
28+
android:layout_width="wrap_content"
29+
android:layout_height="match_parent"
30+
android:layout_gravity="bottom"
31+
android:layout_marginEnd="10dp"
32+
android:layout_marginRight="10dp"
33+
android:fontFamily="sans-serif-light"
34+
android:padding="10dp"
35+
android:text="@string/st_skip"
36+
android:textColor="@android:color/white"
37+
android:textSize="21sp"
38+
tools:ignore="UnusedAttribute"/>
39+
40+
<com.cleveroad.slidingtutorial.TutorialPageIndicator
41+
android:id="@+id/indicator"
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:layout_gravity="center"/>
45+
46+
</FrameLayout>
47+
48+
</FrameLayout>

0 commit comments

Comments
 (0)