From 2b0228ab476426531f0f064e80e3cf2019081569 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 21 Feb 2019 13:21:32 +0800 Subject: Use another GifImageView library. --- .../java/CustomView/AspectRatioGifImageView.java | 2 +- .../infinityforreddit/PostRecyclerViewAdapter.java | 71 ---------------------- .../SubscribedSubredditRecyclerViewAdapter.java | 30 +-------- .../SubscribedUserRecyclerViewAdapter.java | 26 +------- .../infinityforreddit/ViewPostDetailActivity.java | 33 ---------- .../ViewSubredditDetailActivity.java | 25 +------- .../infinityforreddit/ViewUserDetailActivity.java | 26 +------- 7 files changed, 8 insertions(+), 205 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/CustomView/AspectRatioGifImageView.java b/app/src/main/java/CustomView/AspectRatioGifImageView.java index 379c8697..f1b907c4 100644 --- a/app/src/main/java/CustomView/AspectRatioGifImageView.java +++ b/app/src/main/java/CustomView/AspectRatioGifImageView.java @@ -4,7 +4,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; -import com.felipecsl.gifimageview.library.GifImageView; +import pl.droidsonroids.gif.GifImageView; public class AspectRatioGifImageView extends GifImageView { private float ratio; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index 291d8e26..d2ca18ea 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.ColorFilter; -import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.support.annotation.NonNull; @@ -158,22 +157,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - ((DataViewHolder) holder).subredditIconGifImageView.startAnimation(); - } - return false; - } - }) .into(((DataViewHolder) holder).subredditIconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) @@ -190,22 +173,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - ((DataViewHolder) holder).subredditIconGifImageView.startAnimation(); - } - return false; - } - }) .into(((DataViewHolder) holder).subredditIconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) @@ -240,22 +207,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - ((DataViewHolder) holder).subredditIconGifImageView.startAnimation(); - } - return false; - } - }) .into(((DataViewHolder) holder).subredditIconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) @@ -272,22 +223,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - ((DataViewHolder) holder).subredditIconGifImageView.startAnimation(); - } - return false; - } - }) .into(((DataViewHolder) holder).subredditIconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) @@ -687,12 +622,6 @@ class PostRecyclerViewAdapter extends PagedListAdapter { private Context mContext; @@ -62,23 +55,7 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - ((SubredditViewHolder) viewHolder).iconGifImageView.startAnimation(); - } - return false; - } - }).into(((SubredditViewHolder) viewHolder).iconGifImageView); - + .into(((SubredditViewHolder) viewHolder).iconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) @@ -97,9 +74,6 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter { private List mSubscribedUserData; @@ -60,22 +53,7 @@ public class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - ((Animatable) resource).start(); - ((SubscribedUserRecyclerViewAdapter.UserViewHolder) viewHolder).iconGifImageView.startAnimation(); - } - return false; - } - }).into(((UserViewHolder) viewHolder).iconGifImageView); + .into(((UserViewHolder) viewHolder).iconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index 51e9fd31..f6555da5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -4,7 +4,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.graphics.ColorFilter; import android.graphics.PorterDuff; -import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -139,22 +138,6 @@ public class ViewPostDetailActivity extends AppCompatActivity { glide.load(iconImageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - mSubredditIconGifImageView.startAnimation(); - } - return false; - } - }) .into(mSubredditIconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) @@ -169,22 +152,6 @@ public class ViewPostDetailActivity extends AppCompatActivity { glide.load(mPost.getSubredditIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - //((Animatable) resource).start(); - mSubredditIconGifImageView.startAnimation(); - } - return false; - } - }) .into(mSubredditIconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java index 1a083b3c..d24bb0b1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java @@ -3,11 +3,8 @@ package ml.docilealligator.infinityforreddit; import android.arch.lifecycle.ViewModelProviders; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.drawable.Animatable; -import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; -import android.support.annotation.Nullable; import android.support.design.chip.Chip; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CollapsingToolbarLayout; @@ -25,12 +22,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; -import com.bumptech.glide.load.DataSource; -import com.bumptech.glide.load.engine.GlideException; -import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; -import com.bumptech.glide.request.target.Target; -import com.felipecsl.gifimageview.library.GifImageView; import javax.inject.Inject; import javax.inject.Named; @@ -45,6 +37,7 @@ import SubscribedSubredditDatabase.SubscribedSubredditRoomDatabase; import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; +import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; public class ViewSubredditDetailActivity extends AppCompatActivity { @@ -168,22 +161,6 @@ public class ViewSubredditDetailActivity extends AppCompatActivity { glide.load(subredditData.getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - ((Animatable) resource).start(); - iconGifImageView.startAnimation(); - } - return false; - } - }) .into(iconGifImageView); iconGifImageView.setOnClickListener(view -> { Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageActivity.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java index 1922f47a..ed0f2437 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewUserDetailActivity.java @@ -3,11 +3,8 @@ package ml.docilealligator.infinityforreddit; import android.arch.lifecycle.ViewModelProviders; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.drawable.Animatable; -import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; -import android.support.annotation.Nullable; import android.support.design.chip.Chip; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CollapsingToolbarLayout; @@ -24,12 +21,7 @@ import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestManager; -import com.bumptech.glide.load.DataSource; -import com.bumptech.glide.load.engine.GlideException; -import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; -import com.bumptech.glide.request.target.Target; -import com.felipecsl.gifimageview.library.GifImageView; import javax.inject.Inject; import javax.inject.Named; @@ -44,6 +36,7 @@ import User.UserViewModel; import butterknife.BindView; import butterknife.ButterKnife; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; +import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; public class ViewUserDetailActivity extends AppCompatActivity { @@ -166,23 +159,8 @@ public class ViewUserDetailActivity extends AppCompatActivity { glide.load(userData.getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - if(resource instanceof Animatable) { - //This is a gif - ((Animatable) resource).start(); - iconGifImageView.startAnimation(); - } - return false; - } - }) .into(iconGifImageView); + iconGifImageView.setOnClickListener(view -> { Intent intent = new Intent(this, ViewImageActivity.class); intent.putExtra(ViewImageActivity.TITLE_KEY, title); -- cgit v1.2.3