Skip to content

Commit 53b91ac

Browse files
committed
Merge pull request riggaroo#2 from geralt-encore/support-annotations
Support annotations
2 parents cf55dd3 + 3caaae1 commit 53b91ac

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

app/src/main/java/za/co/riggaroo/helptut/helptutorialexample/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ public void loadTutorial() {
3939
}
4040

4141
private ArrayList<TutorialItem> getTutorialItems(Context context) {
42-
TutorialItem tutorialItem1 = new TutorialItem(context.getString(R.string.slide_1_african_story_books), context.getString(R.string.slide_1_african_story_books_subtitle),
42+
TutorialItem tutorialItem1 = new TutorialItem(R.string.slide_1_african_story_books, R.string.slide_1_african_story_books,
4343
R.color.slide_1, R.drawable.tut_page_1_front, R.drawable.tut_page_1_background);
4444

45-
TutorialItem tutorialItem2 = new TutorialItem(context.getString(R.string.slide_2_volunteer_professionals), context.getString(R.string.slide_2_volunteer_professionals_subtitle),
45+
TutorialItem tutorialItem2 = new TutorialItem(R.string.slide_2_volunteer_professionals, R.string.slide_2_volunteer_professionals_subtitle,
4646
R.color.slide_2, R.drawable.tut_page_2_front, R.drawable.tut_page_2_background);
4747

4848
TutorialItem tutorialItem3 = new TutorialItem(context.getString(R.string.slide_3_download_and_go), null,
4949
R.color.slide_3, R.drawable.tut_page_3_foreground);
5050

51-
TutorialItem tutorialItem4 = new TutorialItem(context.getString(R.string.slide_4_different_languages), context.getString(R.string.slide_4_different_languages_subtitle),
51+
TutorialItem tutorialItem4 = new TutorialItem(R.string.slide_4_different_languages, R.string.slide_4_different_languages_subtitle,
5252
R.color.slide_4, R.drawable.tut_page_4_foreground, R.drawable.tut_page_4_background);
5353

5454
ArrayList<TutorialItem> tutorialItems = new ArrayList<>();

materialhelptutorial/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ android {
2727
}
2828

2929
dependencies {
30+
final SUPPORT_LIBRARY_VERSION = '23.1.1'
31+
3032
compile fileTree(dir: 'libs', include: ['*.jar'])
3133
testCompile 'junit:junit:4.12'
32-
compile 'com.android.support:appcompat-v7:23.1.0'
33-
compile 'com.android.support:percent:23.1.0'
34+
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
35+
compile "com.android.support:percent:$SUPPORT_LIBRARY_VERSION"
36+
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
3437
compile 'com.github.bumptech.glide:glide:3.6.0'
3538
}
3639

materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/MaterialTutorialFragment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
5454
TextView textView = (TextView) v.findViewById(R.id.fragment_help_tutorial_text);
5555
if (!TextUtils.isEmpty(tutorialItem.getTitleText())) {
5656
textView.setText(tutorialItem.getTitleText());
57+
} else if (tutorialItem.getTitleTextRes() != -1) {
58+
textView.setText(tutorialItem.getTitleTextRes());
5759
}
5860
if (!TextUtils.isEmpty(tutorialItem.getSubTitleText())) {
5961
textViewSubTitle.setText(tutorialItem.getSubTitleText());
62+
} else if (tutorialItem.getSubTitleTextRes() != -1) {
63+
textViewSubTitle.setText(tutorialItem.getSubTitleTextRes());
6064
}
6165
if (tutorialItem.getBackgroundImageRes() != -1) {
6266
Glide.with(this).load(tutorialItem.getBackgroundImageRes()).into(imageViewBack);

materialhelptutorial/src/main/java/za/co/riggaroo/materialhelptutorial/TutorialItem.java

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,51 @@
33

44
import android.os.Parcel;
55
import android.os.Parcelable;
6+
import android.support.annotation.ColorRes;
7+
import android.support.annotation.DrawableRes;
8+
import android.support.annotation.NonNull;
9+
import android.support.annotation.Nullable;
10+
import android.support.annotation.StringRes;
611

712
public class TutorialItem implements Parcelable {
813
private String titleText;
914
private String subTitleText;
1015
private int backgroundColor;
11-
private int foregroundImageRes;
16+
private int foregroundImageRes = -1;
1217
private int backgroundImageRes = -1;
18+
private int titleTextRes = -1;
19+
private int subTitleTextRes = -1;
1320

14-
public TutorialItem(String titleText, String subTitleText, int backgroundColor, int foregroundImageRes, int backgroundImageRes) {
21+
public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, @DrawableRes int backgroundImageRes) {
1522
this.titleText = titleText;
1623
this.subTitleText = subTitleText;
1724
this.backgroundColor = backgroundColor;
1825
this.foregroundImageRes = foregroundImageRes;
1926
this.backgroundImageRes = backgroundImageRes;
2027
}
2128

22-
public TutorialItem(String titleText, String subTitleText, int backgroundColor, int foregroundImageRes) {
29+
public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes) {
2330
this.titleText = titleText;
2431
this.subTitleText = subTitleText;
2532
this.backgroundColor = backgroundColor;
2633
this.foregroundImageRes = foregroundImageRes;
2734
}
2835

36+
public TutorialItem(@StringRes int titleTextRes, @StringRes int subTitleTextRes, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, @DrawableRes int backgroundImageRes) {
37+
this.titleTextRes = titleTextRes;
38+
this.subTitleTextRes = subTitleTextRes;
39+
this.backgroundColor = backgroundColor;
40+
this.foregroundImageRes = foregroundImageRes;
41+
this.backgroundImageRes = backgroundImageRes;
42+
}
43+
44+
public TutorialItem(@StringRes int titleTextRes, @StringRes int subTitleTextRes, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes) {
45+
this.subTitleTextRes = titleTextRes;
46+
this.subTitleTextRes = subTitleTextRes;
47+
this.backgroundColor = backgroundColor;
48+
this.foregroundImageRes = foregroundImageRes;
49+
}
50+
2951
public String getTitleText() {
3052
return titleText;
3153
}
@@ -46,6 +68,14 @@ public int getBackgroundImageRes() {
4668
return backgroundImageRes;
4769
}
4870

71+
public int getTitleTextRes() {
72+
return titleTextRes;
73+
}
74+
75+
public int getSubTitleTextRes() {
76+
return subTitleTextRes;
77+
}
78+
4979
@Override
5080
public int describeContents() {
5181
return 0;
@@ -58,6 +88,8 @@ public void writeToParcel(Parcel dest, int flags) {
5888
dest.writeInt(this.backgroundColor);
5989
dest.writeInt(this.foregroundImageRes);
6090
dest.writeInt(this.backgroundImageRes);
91+
dest.writeInt(this.titleTextRes);
92+
dest.writeInt(this.subTitleTextRes);
6193
}
6294

6395
protected TutorialItem(Parcel in) {
@@ -66,6 +98,8 @@ protected TutorialItem(Parcel in) {
6698
this.backgroundColor = in.readInt();
6799
this.foregroundImageRes = in.readInt();
68100
this.backgroundImageRes = in.readInt();
101+
this.titleTextRes = in.readInt();
102+
this.subTitleTextRes = in.readInt();
69103
}
70104

71105
public static final Parcelable.Creator<TutorialItem> CREATOR = new Parcelable.Creator<TutorialItem>() {

0 commit comments

Comments
 (0)