Skip to content
This repository was archived by the owner on Jun 19, 2021. It is now read-only.

Commit 1e035de

Browse files
author
Laurent Meyer
committed
Added a Beta GIF Support
1 parent db992d0 commit 1e035de

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

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)