Skip to content

Commit e17f5d4

Browse files
committed
Merge pull request riggaroo#11 from lolobosse/pr
Added a beta gif support
2 parents 028da56 + eaabd09 commit e17f5d4

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ In your activity, create a list of TutorialItems (set the title, subtitle, backg
3131
TutorialItem tutorialItem1 = new TutorialItem(context.getString(R.string.slide_1_african_story_books), context.getString(R.string.slide_1_african_story_books_subtitle),
3232
R.color.slide_1, R.drawable.tut_page_1_front, R.drawable.tut_page_1_background);
3333

34+
// You can also add gifs, [IN BETA YET] (because Glide is awesome!)
35+
TutorialItem tutorialItem1 = new TutorialItem(context.getString(R.string.slide_1_african_story_books), context.getString(R.string.slide_1_african_story_books_subtitle),
36+
R.color.slide_1, R.drawable.gif_drawable, true);
37+
3438
...
3539

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

materialhelptutorial/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
3535
compile "com.android.support:percent:$SUPPORT_LIBRARY_VERSION"
3636
compile "com.android.support:support-annotations:$SUPPORT_LIBRARY_VERSION"
37-
compile 'com.github.bumptech.glide:glide:3.6.0'
37+
compile 'com.github.bumptech.glide:glide:3.7.0'
3838
}
3939

4040

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.widget.TextView;
1111

1212
import com.bumptech.glide.Glide;
13+
import com.bumptech.glide.load.engine.DiskCacheStrategy;
1314

1415
/**
1516
* @author rebeccafranks
@@ -65,9 +66,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
6566
if (tutorialItem.getBackgroundImageRes() != -1) {
6667
Glide.with(this).load(tutorialItem.getBackgroundImageRes()).into(imageViewBack);
6768
}
68-
if (tutorialItem.getForegroundImageRes() != -1) {
69+
if (tutorialItem.getForegroundImageRes() != -1 && !tutorialItem.isGif()) {
6970
Glide.with(this).load(tutorialItem.getForegroundImageRes()).into(imageViewFront);
7071
}
72+
if (tutorialItem.getForegroundImageRes() != -1 && tutorialItem.isGif()){
73+
Glide.with(this).load(tutorialItem.getForegroundImageRes()).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageViewFront);
74+
}
7175
return v;
7276
}
7377

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class TutorialItem implements Parcelable {
1717
private int backgroundImageRes = -1;
1818
private int titleTextRes = -1;
1919
private int subTitleTextRes = -1;
20+
private boolean isGif = false;
2021

2122
public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, @DrawableRes int backgroundImageRes) {
2223
this.titleText = titleText;
@@ -33,6 +34,14 @@ public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @C
3334
this.foregroundImageRes = foregroundImageRes;
3435
}
3536

37+
public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, boolean isGif) {
38+
this.titleText = titleText;
39+
this.subTitleText = subTitleText;
40+
this.backgroundColor = backgroundColor;
41+
this.foregroundImageRes = foregroundImageRes;
42+
this.isGif = isGif;
43+
}
44+
3645
public TutorialItem(@StringRes int titleTextRes, @StringRes int subTitleTextRes, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, @DrawableRes int backgroundImageRes) {
3746
this.titleTextRes = titleTextRes;
3847
this.subTitleTextRes = subTitleTextRes;
@@ -76,6 +85,10 @@ public int getSubTitleTextRes() {
7685
return subTitleTextRes;
7786
}
7887

88+
public boolean isGif() {
89+
return isGif;
90+
}
91+
7992
@Override
8093
public int describeContents() {
8194
return 0;
@@ -90,6 +103,7 @@ public void writeToParcel(Parcel dest, int flags) {
90103
dest.writeInt(this.backgroundImageRes);
91104
dest.writeInt(this.titleTextRes);
92105
dest.writeInt(this.subTitleTextRes);
106+
dest.writeInt(this.isGif ? 1:0);
93107
}
94108

95109
protected TutorialItem(Parcel in) {
@@ -100,6 +114,7 @@ protected TutorialItem(Parcel in) {
100114
this.backgroundImageRes = in.readInt();
101115
this.titleTextRes = in.readInt();
102116
this.subTitleTextRes = in.readInt();
117+
this.isGif = in.readInt() == 1;
103118
}
104119

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

0 commit comments

Comments
 (0)