Skip to content

Commit

Permalink
预览页优化
Browse files Browse the repository at this point in the history
  • Loading branch information
teach committed Sep 27, 2019
1 parent 5368d72 commit 75a7b5c
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.PagerAdapter;

import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand Down Expand Up @@ -76,18 +78,18 @@ public Object instantiateItem(ViewGroup container, final int position) {
if (image.isGif()) {
currentView.setScaleType(ImageView.ScaleType.FIT_CENTER);
Glide.with(mContext).load(isAndroidQ ? image.getUri() : image.getPath())
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE)).override(720,1080)
.into(currentView);
} else {
Glide.with(mContext).asBitmap()
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE))
.load(isAndroidQ ? image.getUri() : image.getPath()).into(new SimpleTarget<Bitmap>() {
.load(isAndroidQ ? image.getUri() : image.getPath()).into(new SimpleTarget<Bitmap>(720,1080) {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
int bw = resource.getWidth();
int bh = resource.getHeight();
if (bw > 8192 || bh > 8192) {
Bitmap bitmap = ImageUtil.zoomBitmap(resource, 8192, 8192);
if (bw > 4096 || bh > 4096) {
Bitmap bitmap = ImageUtil.zoomBitmap(resource, 4096, 4096);
setBitmap(currentView, bitmap);
} else {
setBitmap(currentView, resource);
Expand Down

0 comments on commit 75a7b5c

Please sign in to comment.