diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-02-21 05:21:32 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-02-21 05:21:32 +0000 |
commit | 2b0228ab476426531f0f064e80e3cf2019081569 (patch) | |
tree | 5747f83f4e5c1d0895522468fbdefd37a6eacf06 /app/src/main | |
parent | 3a58964d6cdde4435fb257542e89fea6de501dba (diff) | |
download | infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.tar infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.tar.gz infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.tar.bz2 infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.tar.lz infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.tar.xz infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.tar.zst infinity-for-reddit-2b0228ab476426531f0f064e80e3cf2019081569.zip |
Use another GifImageView library.
Diffstat (limited to '')
10 files changed, 13 insertions, 216 deletions
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<Post, RecyclerView.ViewHo glide.load(iconImageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Post, RecyclerView.ViewHo glide.load(post.getSubredditIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Post, RecyclerView.ViewHo glide.load(iconImageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Post, RecyclerView.ViewHo glide.load(post.getAuthorIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Post, RecyclerView.ViewHo @Override public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { if(holder instanceof DataViewHolder) { - if(((DataViewHolder) holder).imageView.isAnimating()) { - ((DataViewHolder) holder).imageView.stopAnimation(); - } - if(((DataViewHolder) holder).subredditIconGifImageView.isAnimating()) { - ((DataViewHolder) holder).subredditIconGifImageView.stopAnimation(); - } glide.clear(((DataViewHolder) holder).imageView); glide.clear(((DataViewHolder) holder).subredditIconGifImageView); ((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java index c737298d..d4098c1b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java @@ -2,10 +2,7 @@ package ml.docilealligator.infinityforreddit; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.Animatable; -import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -14,17 +11,13 @@ 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 java.util.List; import SubscribedSubredditDatabase.SubscribedSubredditData; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; +import pl.droidsonroids.gif.GifImageView; class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private Context mContext; @@ -62,23 +55,7 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl glide.load(mSubscribedSubredditData.get(i).getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Recycl @Override public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { - if(((SubredditViewHolder) holder).iconGifImageView.isAnimating()) { - ((SubredditViewHolder) holder).iconGifImageView.stopAnimation(); - } glide.clear(((SubredditViewHolder) holder).iconGifImageView); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java index bec617c6..8f0e402e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java @@ -2,10 +2,7 @@ package ml.docilealligator.infinityforreddit; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.Animatable; -import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -14,17 +11,13 @@ 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 java.util.List; import SubscribedUserDatabase.SubscribedUserData; import jp.wasabeef.glide.transformations.RoundedCornersTransformation; +import pl.droidsonroids.gif.GifImageView; public class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { private List<SubscribedUserData> mSubscribedUserData; @@ -60,22 +53,7 @@ public class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<Recy glide.load(mSubscribedUserData.get(i).getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon)) - .listener(new RequestListener<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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<Drawable>() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> 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); diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml index 1460efac..51566dbe 100644 --- a/app/src/main/res/layout/activity_view_subreddit_detail.xml +++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml @@ -32,17 +32,14 @@ android:layout_height="180dp" android:contentDescription="@string/content_description_banner_imageview" /> - <com.felipecsl.gifimageview.library.GifImageView + <pl.droidsonroids.gif.GifImageView android:id="@+id/icon_gif_image_view_view_subreddit_detail_activity" android:layout_width="72dp" android:layout_height="72dp" android:layout_marginTop="-36dp" - app:civ_border_color="@android:color/white" - app:civ_border_width="1dp" android:layout_below="@id/banner_image_view_view_subreddit_detail_activity" android:layout_centerHorizontal="true" - android:elevation="4dp" - app:civ_circle_background_color="@android:color/white"/> + android:elevation="4dp" /> <LinearLayout android:layout_width="match_parent" diff --git a/app/src/main/res/layout/activity_view_user_detail.xml b/app/src/main/res/layout/activity_view_user_detail.xml index 664230ce..a1fa6dc4 100644 --- a/app/src/main/res/layout/activity_view_user_detail.xml +++ b/app/src/main/res/layout/activity_view_user_detail.xml @@ -32,17 +32,14 @@ android:layout_height="180dp" android:contentDescription="@string/content_description_banner_imageview" /> - <com.felipecsl.gifimageview.library.GifImageView + <pl.droidsonroids.gif.GifImageView android:id="@+id/icon_gif_image_view_view_user_detail_activity" android:layout_width="72dp" android:layout_height="72dp" android:layout_marginTop="-36dp" - app:civ_border_color="@android:color/white" - app:civ_border_width="1dp" android:layout_below="@id/banner_image_view_view_user_detail_activity" android:layout_centerHorizontal="true" - android:elevation="4dp" - app:civ_circle_background_color="@android:color/white"/> + android:elevation="4dp" /> <LinearLayout android:layout_width="match_parent" diff --git a/app/src/main/res/layout/item_subscribed_subreddit.xml b/app/src/main/res/layout/item_subscribed_subreddit.xml index 0b68efbf..0717c7c4 100644 --- a/app/src/main/res/layout/item_subscribed_subreddit.xml +++ b/app/src/main/res/layout/item_subscribed_subreddit.xml @@ -7,7 +7,7 @@ android:focusable="true" android:background="?attr/selectableItemBackground"> - <com.felipecsl.gifimageview.library.GifImageView + <pl.droidsonroids.gif.GifImageView android:id="@+id/subreddit_icon_gif_image_view_item_subscribed_subreddit" android:layout_width="24dp" android:layout_height="24dp" |