aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/CustomView/AspectRatioGifImageView.java54
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java67
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java45
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java43
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java43
6 files changed, 223 insertions, 31 deletions
diff --git a/app/src/main/java/CustomView/AspectRatioGifImageView.java b/app/src/main/java/CustomView/AspectRatioGifImageView.java
new file mode 100644
index 00000000..379c8697
--- /dev/null
+++ b/app/src/main/java/CustomView/AspectRatioGifImageView.java
@@ -0,0 +1,54 @@
+package CustomView;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+
+import com.felipecsl.gifimageview.library.GifImageView;
+
+public class AspectRatioGifImageView extends GifImageView {
+ private float ratio;
+
+ public final float getRatio() {
+ return this.ratio;
+ }
+
+ public final void setRatio(float var1) {
+ this.ratio = var1;
+ }
+
+ private final void init(Context context, AttributeSet attrs) {
+ if (attrs != null) {
+ TypedArray a = context.obtainStyledAttributes(attrs, com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView);
+ this.ratio = a.getFloat(com.santalu.aspectratioimageview.R.styleable.AspectRatioImageView_ari_ratio, 1.0F);
+ a.recycle();
+ }
+
+ }
+
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int width = this.getMeasuredWidth();
+ int height = this.getMeasuredHeight();
+ if (width != 0 || height != 0) {
+ if (width > 0) {
+ height = (int)((float)width * this.ratio);
+ } else {
+ width = (int)((float)height / this.ratio);
+ }
+
+ this.setMeasuredDimension(width, height);
+ }
+ }
+
+ public AspectRatioGifImageView(Context context) {
+ super(context);
+ this.ratio = 1.0F;
+ }
+
+ public AspectRatioGifImageView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.ratio = 1.0F;
+ this.init(context, attrs);
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
index 0b856945..e3a2ba5a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
@@ -61,7 +61,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
private PostRecyclerViewAdapter mAdapter;
- private PostViewModel mPostViewModel;
+ PostViewModel mPostViewModel;
@Inject @Named("no_oauth")
Retrofit mRetrofit;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
index a3a7e504..66c29d65 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java
@@ -4,6 +4,7 @@ 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;
@@ -32,14 +33,14 @@ 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.santalu.aspectratioimageview.AspectRatioImageView;
import java.util.ArrayList;
+import CustomView.AspectRatioGifImageView;
import butterknife.BindView;
import butterknife.ButterKnife;
-import de.hdodenhof.circleimageview.CircleImageView;
import jp.wasabeef.glide.transformations.BlurTransformation;
+import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import retrofit2.Retrofit;
/**
@@ -115,10 +116,29 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
if(mContext != null && !mPostData.isEmpty()) {
if(!iconImageUrl.equals("")) {
glide.load(iconImageUrl)
- .into(((DataViewHolder) holder).subredditIconCircleImageView);
+ .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)
- .into(((DataViewHolder) holder).subredditIconCircleImageView);
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((DataViewHolder) holder).subredditIconGifImageView);
}
if(holder.getAdapterPosition() >= 0) {
@@ -128,9 +148,30 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
}
}).execute();
} else if(!mPostData.get(position).getSubredditIconUrl().equals("")) {
- glide.load(mPostData.get(position).getSubredditIconUrl()).into(((DataViewHolder) holder).subredditIconCircleImageView);
+ glide.load(mPostData.get(position).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).into(((DataViewHolder) holder).subredditIconCircleImageView);
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((DataViewHolder) holder).subredditIconGifImageView);
}
((DataViewHolder) holder).cardView.setOnClickListener(new View.OnClickListener() {
@@ -146,7 +187,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
}
});
- ((DataViewHolder) holder).subredditIconCircleImageView.setOnClickListener(new View.OnClickListener() {
+ ((DataViewHolder) holder).subredditIconGifImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(canStartActivity) {
@@ -537,7 +578,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
class DataViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.card_view_view_post_detail) CardView cardView;
- @BindView(R.id.subreddit_icon_circle_image_view_best_post_item) CircleImageView subredditIconCircleImageView;
+ @BindView(R.id.subreddit_icon_gif_image_view_best_post_item) AspectRatioGifImageView subredditIconGifImageView;
@BindView(R.id.subreddit_text_view_best_post_item) TextView subredditNameTextView;
@BindView(R.id.stickied_post_image_view_best_post_item) ImageView stickiedPostImageView;
@BindView(R.id.post_time_text_view_best_post_item) TextView postTimeTextView;
@@ -549,7 +590,7 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
@BindView(R.id.nsfw_text_view_item_best_post) TextView nsfwTextView;
@BindView(R.id.image_view_wrapper_item_best_post) RelativeLayout relativeLayout;
@BindView(R.id.progress_bar_best_post_item) ProgressBar progressBar;
- @BindView(R.id.image_view_best_post_item) AspectRatioImageView imageView;
+ @BindView(R.id.image_view_best_post_item) AspectRatioGifImageView imageView;
@BindView(R.id.load_image_error_relative_layout_best_post_item) RelativeLayout errorRelativeLayout;
@BindView(R.id.image_view_no_preview_link_best_post_item) ImageView noPreviewLinkImageView;
@BindView(R.id.plus_button_item_best_post) ImageView upvoteButton;
@@ -577,8 +618,14 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
@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).subredditIconCircleImageView);
+ glide.clear(((DataViewHolder) holder).subredditIconGifImageView);
((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.GONE);
((DataViewHolder) holder).relativeLayout.setVisibility(View.GONE);
((DataViewHolder) holder).gildedImageView.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 45d9dfb0..87c679cd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedSubredditRecyclerViewAdapter.java
@@ -2,7 +2,10 @@ 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;
@@ -11,10 +14,16 @@ 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 de.hdodenhof.circleimageview.CircleImageView;
+import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context mContext;
@@ -54,9 +63,30 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
}
});
if(!mSubscribedSubredditData.get(i).getIconUrl().equals("")) {
- glide.load(mSubscribedSubredditData.get(i).getIconUrl()).into(((SubredditViewHolder) viewHolder).iconCircleImageView);
+ 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);
+
} else {
- glide.load(R.drawable.subreddit_default_icon).into(((SubredditViewHolder) viewHolder).iconCircleImageView);
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(mSubscribedSubredditData.get(i).getName());
}
@@ -71,7 +101,10 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
- glide.clear(((SubredditViewHolder) holder).iconCircleImageView);
+ if(((SubredditViewHolder) holder).iconGifImageView.isAnimating()) {
+ ((SubredditViewHolder) holder).iconGifImageView.stopAnimation();
+ }
+ glide.clear(((SubredditViewHolder) holder).iconGifImageView);
}
void setSubscribedSubreddits(List<SubscribedSubredditData> subscribedSubreddits){
@@ -81,12 +114,12 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
private class SubredditViewHolder extends RecyclerView.ViewHolder {
- private final CircleImageView iconCircleImageView;
+ private final GifImageView iconGifImageView;
private final TextView subredditNameTextView;
public SubredditViewHolder(View itemView) {
super(itemView);
- iconCircleImageView = itemView.findViewById(R.id.subreddit_icon_circle_image_view_item_subscribed_subreddit);
+ iconGifImageView = itemView.findViewById(R.id.subreddit_icon_gif_image_view_item_subscribed_subreddit);
subredditNameTextView = itemView.findViewById(R.id.subreddit_name_text_view_item_subscribed_subreddit);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java
index 44089043..e36dea17 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubscribedUserRecyclerViewAdapter.java
@@ -1,7 +1,10 @@
package ml.docilealligator.infinityforreddit;
import android.content.Context;
+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;
@@ -10,10 +13,16 @@ 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 de.hdodenhof.circleimageview.CircleImageView;
+import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<SubscribedUserData> mSubscribedUserData;
@@ -36,7 +45,7 @@ class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
}
@Override
- public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
+ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -46,9 +55,29 @@ class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
}
});
if(!mSubscribedUserData.get(i).getIconUrl().equals("")) {
- glide.load(mSubscribedUserData.get(i).getIconUrl()).into(((UserViewHolder) viewHolder).iconCircleImageView);
+ 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);
} else {
- glide.load(R.drawable.subreddit_default_icon).into(((UserViewHolder) viewHolder).iconCircleImageView);
+ glide.load(R.drawable.subreddit_default_icon)
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
+ .into(((UserViewHolder) viewHolder).iconGifImageView);
}
((UserViewHolder) viewHolder).subredditNameTextView.setText(mSubscribedUserData.get(i).getName());
}
@@ -63,7 +92,7 @@ class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
- glide.clear(((UserViewHolder) holder).iconCircleImageView);
+ glide.clear(((UserViewHolder) holder).iconGifImageView);
}
void setSubscribedUsers(List<SubscribedUserData> subscribedUsers){
@@ -73,12 +102,12 @@ class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
private class UserViewHolder extends RecyclerView.ViewHolder {
- private final CircleImageView iconCircleImageView;
+ private final GifImageView iconGifImageView;
private final TextView subredditNameTextView;
public UserViewHolder(View itemView) {
super(itemView);
- iconCircleImageView = itemView.findViewById(R.id.subreddit_icon_circle_image_view_item_subscribed_subreddit);
+ iconGifImageView = itemView.findViewById(R.id.subreddit_icon_gif_image_view_item_subscribed_subreddit);
subredditNameTextView = itemView.findViewById(R.id.subreddit_name_text_view_item_subscribed_subreddit);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
index 37055713..cc7bb742 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
+import android.graphics.drawable.Animatable;
+import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
@@ -21,13 +23,19 @@ import android.widget.Toast;
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;
import butterknife.BindView;
import butterknife.ButterKnife;
-import de.hdodenhof.circleimageview.CircleImageView;
+import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import retrofit2.Retrofit;
public class ViewSubredditDetailActivity extends AppCompatActivity {
@@ -39,7 +47,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
private static final String FRAGMENT_OUT_STATE_KEY = "FOSK";
@BindView(R.id.banner_image_view_view_subreddit_detail_activity) ImageView bannerImageView;
- @BindView(R.id.icon_circle_image_view_view_subreddit_detail_activity) CircleImageView iconCircleImageView;
+ @BindView(R.id.icon_gif_image_view_view_subreddit_detail_activity) GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_view_subreddit_detail_activity) TextView subredditNameTextView;
@BindView(R.id.subscriber_count_text_view_view_subreddit_detail_activity) TextView nSubscribersTextView;
@BindView(R.id.online_subscriber_count_text_view_view_subreddit_detail_activity) TextView nOnlineSubscribersTextView;
@@ -117,7 +125,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
public void onChanged(@Nullable final SubredditData subredditData) {
if(subredditData != null) {
if(subredditData.getBannerUrl().equals("")) {
- iconCircleImageView.setOnClickListener(new View.OnClickListener() {
+ iconGifImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Do nothing as it has no image
@@ -138,16 +146,37 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
}
if(subredditData.getIconUrl().equals("")) {
- glide.load(getDrawable(R.drawable.subreddit_default_icon)).into(iconCircleImageView);
- iconCircleImageView.setOnClickListener(new View.OnClickListener() {
+ glide.load(getDrawable(R.drawable.subreddit_default_icon))
+ .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))
+ .into(iconGifImageView);
+ iconGifImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Do nothing as it is a default icon
}
});
} else {
- glide.load(subredditData.getIconUrl()).into(iconCircleImageView);
- iconCircleImageView.setOnClickListener(new View.OnClickListener() {
+ 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(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageActivity.class);