mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Use SubsamplingScaleImageView in ViewImgurImageFragment. Probably fix gif too small in AspectRatioGifImageView.
This commit is contained in:
parent
67cb832c46
commit
c97120528b
@ -11,7 +11,6 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -155,16 +154,6 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
|
|||||||
setTitle("");
|
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 -> {
|
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
mLoadErrorLinearLayout.setVisibility(View.GONE);
|
||||||
|
@ -1248,7 +1248,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mPost.getPostType() == Post.GIF_TYPE && mAutoplayNsfwVideos)) || (mPost.isSpoiler() && mNeedBlurSpoiler)) {
|
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);
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > mPost.getPreviewWidth()) {
|
if (mImageViewWidth > mPost.getPreviewWidth() && mPost.getPostType() == Post.IMAGE_TYPE) {
|
||||||
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
imageRequestBuilder.into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||||
|
@ -875,7 +875,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
|
.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
|
||||||
} else {
|
} else {
|
||||||
if (mImageViewWidth > post.getPreviewWidth()) {
|
if (mImageViewWidth > post.getPreviewWidth() && post.getPostType() == Post.IMAGE_TYPE) {
|
||||||
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
|
imageRequestBuilder.override(Target.SIZE_ORIGINAL).into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
|
||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
|
imageRequestBuilder.into(((PostImageAndGifAutoplayViewHolder) holder).imageView);
|
||||||
|
@ -26,7 +26,6 @@ import androidx.core.content.ContextCompat;
|
|||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.alexvasilkov.gestures.views.GestureImageView;
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.load.DataSource;
|
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.CustomTarget;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
|
import com.davemorrissey.labs.subscaleview.ImageSource;
|
||||||
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class ViewImgurImageFragment extends Fragment {
|
|||||||
@BindView(R.id.progress_bar_view_imgur_image_fragment)
|
@BindView(R.id.progress_bar_view_imgur_image_fragment)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.image_view_view_imgur_image_fragment)
|
@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)
|
@BindView(R.id.load_image_error_linear_layout_view_imgur_image_fragment)
|
||||||
LinearLayout errorLinearLayout;
|
LinearLayout errorLinearLayout;
|
||||||
|
|
||||||
@ -110,20 +111,30 @@ public class ViewImgurImageFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadImage() {
|
private void loadImage() {
|
||||||
glide.load(imgurMedia.getLink()).listener(new RequestListener<Drawable>() {
|
glide.asBitmap().load(imgurMedia.getLink()).listener(new RequestListener<Bitmap>() {
|
||||||
@Override
|
@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);
|
progressBar.setVisibility(View.GONE);
|
||||||
errorLinearLayout.setVisibility(View.VISIBLE);
|
errorLinearLayout.setVisibility(View.VISIBLE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
progressBar.setVisibility(View.GONE);
|
||||||
return false;
|
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
|
@Override
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<translate
|
|
||||||
android:duration="@android:integer/config_shortAnimTime"
|
|
||||||
android:fromYDelta="0"
|
|
||||||
android:toYDelta="+50%p" />
|
|
||||||
<alpha
|
|
||||||
android:duration="@android:integer/config_shortAnimTime"
|
|
||||||
android:fromAlpha="1.0"
|
|
||||||
android:toAlpha="0.0" />
|
|
||||||
</set>
|
|
@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<translate
|
|
||||||
android:duration="@android:integer/config_shortAnimTime"
|
|
||||||
android:fromYDelta="0"
|
|
||||||
android:toYDelta="-50%p" />
|
|
||||||
<alpha
|
|
||||||
android:duration="@android:integer/config_shortAnimTime"
|
|
||||||
android:fromAlpha="1.0"
|
|
||||||
android:toAlpha="0.0" />
|
|
||||||
</set>
|
|
@ -13,13 +13,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true" />
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
<com.alexvasilkov.gestures.views.GestureImageView
|
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
android:id="@+id/image_view_view_imgur_image_fragment"
|
android:id="@+id/image_view_view_imgur_image_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:adjustViewBounds="true"
|
app:quickScaleEnabled="false" />
|
||||||
android:scaleType="fitCenter"
|
|
||||||
app:gest_fillViewport="true" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/load_image_error_linear_layout_view_imgur_image_fragment"
|
android:id="@+id/load_image_error_linear_layout_view_imgur_image_fragment"
|
||||||
|
Loading…
Reference in New Issue
Block a user