Skip to content
This repository was archived by the owner on Jun 19, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added a Beta GIF Support
  • Loading branch information
Laurent Meyer committed May 23, 2016
commit 1e035de2e912732ba57a59413aa17a2a9f51e377
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

/**
* @author rebeccafranks
Expand Down Expand Up @@ -65,9 +66,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
if (tutorialItem.getBackgroundImageRes() != -1) {
Glide.with(this).load(tutorialItem.getBackgroundImageRes()).into(imageViewBack);
}
if (tutorialItem.getForegroundImageRes() != -1) {
if (tutorialItem.getForegroundImageRes() != -1 && !tutorialItem.isGif()) {
Glide.with(this).load(tutorialItem.getForegroundImageRes()).into(imageViewFront);
}
if (tutorialItem.getForegroundImageRes() != -1 && tutorialItem.isGif()){
Glide.with(this).load(tutorialItem.getForegroundImageRes()).asGif().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageViewFront);
Copy link

@TWiStErRob TWiStErRob May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lolobosse @spongebobrf You don't need this distinction because you're loading from resources. This will just copy the already big GIF files to the cache which won't be faster because the APK and the cache are both on device / sd card. This just wastes space for users. Also asGif() is not needed because Glide knows if it's still or not.

Copy link

@TWiStErRob TWiStErRob May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best would be to use NONE for all loads, after all this should be only seen once by each user, and if the user goes back to a previous page of the tutorial it should still be in memory cache. After it is dismissed the files will just stay in disk cache otherwise, likely not ever loaded again.

}
return v;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class TutorialItem implements Parcelable {
private int backgroundImageRes = -1;
private int titleTextRes = -1;
private int subTitleTextRes = -1;
private boolean isGif = false;

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

public TutorialItem(@NonNull String titleText, @Nullable String subTitleText, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, boolean isGif) {
this.titleText = titleText;
this.subTitleText = subTitleText;
this.backgroundColor = backgroundColor;
this.foregroundImageRes = foregroundImageRes;
this.isGif = isGif;
}

public TutorialItem(@StringRes int titleTextRes, @StringRes int subTitleTextRes, @ColorRes int backgroundColor, @DrawableRes int foregroundImageRes, @DrawableRes int backgroundImageRes) {
this.titleTextRes = titleTextRes;
this.subTitleTextRes = subTitleTextRes;
Expand Down Expand Up @@ -76,6 +85,10 @@ public int getSubTitleTextRes() {
return subTitleTextRes;
}

public boolean isGif() {
return isGif;
}

@Override
public int describeContents() {
return 0;
Expand All @@ -90,6 +103,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.backgroundImageRes);
dest.writeInt(this.titleTextRes);
dest.writeInt(this.subTitleTextRes);
dest.writeInt(this.isGif ? 1:0);
}

protected TutorialItem(Parcel in) {
Expand All @@ -100,6 +114,7 @@ protected TutorialItem(Parcel in) {
this.backgroundImageRes = in.readInt();
this.titleTextRes = in.readInt();
this.subTitleTextRes = in.readInt();
this.isGif = in.readInt() == 1;
}

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