aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-07-14 15:26:19 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-07-14 15:26:19 +0000
commitc97120528bd158c7ff430846ac04acfa74f78058 (patch)
tree5e090acc0902b8c5941734caf4f498534c1386a1 /app/src/main/java
parent67cb832c46895193c85a2b9d1b5c95873588ad26 (diff)
downloadinfinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.tar
infinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.tar.gz
infinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.tar.bz2
infinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.tar.lz
infinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.tar.xz
infinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.tar.zst
infinity-for-reddit-c97120528bd158c7ff430846ac04acfa74f78058.zip
Use SubsamplingScaleImageView in ViewImgurImageFragment. Probably fix gif too small in AspectRatioGifImageView.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java23
4 files changed, 19 insertions, 19 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java
index 0577ba2f..dd2b0d1c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewImageOrGifActivity.java
@@ -11,7 +11,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
-import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -155,16 +154,6 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
setTitle("");
}
- DisplayMetrics displayMetrics = new DisplayMetrics();
- getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
- int windowHeight = displayMetrics.heightPixels;
-
- /*mHaulerView.setOnDragDismissedListener(dragDirection -> {
- int slide = dragDirection == DragDirection.UP ? R.anim.slide_out_up : R.anim.slide_out_down;
- finish();
- overridePendingTransition(0, slide);
- });*/
-
mLoadErrorLinearLayout.setOnClickListener(view -> {
mProgressBar.setVisibility(View.VISIBLE);
mLoadErrorLinearLayout.setVisibility(View.GONE);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index bbf36110..a7975e47 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -1248,7 +1248,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else {
- if (mImageViewWidth > mPost.getPreviewWidth()) {
+ if (mImageViewWidth > mPost.getPreviewWidth() && mPost.getPostType() == Post.IMAGE_TYPE) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
} else {
imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 835d8af1..d630f12a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -875,7 +875,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
} else {
- if (mImageViewWidth > post.getPreviewWidth()) {
+ if (mImageViewWidth > post.getPreviewWidth() && post.getPostType() == Post.IMAGE_TYPE) {
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
} else {
imageRequestBuilder.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
index 51c48d26..83411416 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/ViewImgurImageFragment.java
@@ -26,7 +26,6 @@ import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.fragment.app.Fragment;
-import com.alexvasilkov.gestures.views.GestureImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.load.DataSource;
@@ -35,6 +34,8 @@ import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
+import com.davemorrissey.labs.subscaleview.ImageSource;
+import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import java.io.File;
@@ -58,7 +59,7 @@ public class ViewImgurImageFragment extends Fragment {
@BindView(R.id.progress_bar_view_imgur_image_fragment)
ProgressBar progressBar;
@BindView(R.id.image_view_view_imgur_image_fragment)
- GestureImageView imageView;
+ SubsamplingScaleImageView imageView;
@BindView(R.id.load_image_error_linear_layout_view_imgur_image_fragment)
LinearLayout errorLinearLayout;
@@ -110,20 +111,30 @@ public class ViewImgurImageFragment extends Fragment {
}
private void loadImage() {
- glide.load(imgurMedia.getLink()).listener(new RequestListener<Drawable>() {
+ glide.asBitmap().load(imgurMedia.getLink()).listener(new RequestListener<Bitmap>() {
@Override
- public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
+ public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
errorLinearLayout.setVisibility(View.VISIBLE);
return false;
}
@Override
- public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
+ public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
- }).override(Target.SIZE_ORIGINAL).into(imageView);
+ }).into(new CustomTarget<Bitmap>() {
+ @Override
+ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
+ imageView.setImage(ImageSource.bitmap(resource));
+ }
+
+ @Override
+ public void onLoadCleared(@Nullable Drawable placeholder) {
+
+ }
+ });
}
@Override