From 02af3ceb6b04eada664f81ea5e5f92986ea7916c Mon Sep 17 00:00:00 2001 From: Vans Z <196425254@qq.com> Date: Thu, 28 May 2020 11:56:45 +0800 Subject: [PATCH] =?UTF-8?q?[M]=E4=BF=AE=E5=A4=8D=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E6=8A=96=E5=8A=A8=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hitomi/tilibrary/transfer/TransferState.java | 8 ++++++-- .../transferimage/activity/ComplexDemoActivity.java | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Transferee/src/main/java/com/hitomi/tilibrary/transfer/TransferState.java b/Transferee/src/main/java/com/hitomi/tilibrary/transfer/TransferState.java index aa6780c..d9b7215 100644 --- a/Transferee/src/main/java/com/hitomi/tilibrary/transfer/TransferState.java +++ b/Transferee/src/main/java/com/hitomi/tilibrary/transfer/TransferState.java @@ -1,5 +1,6 @@ package com.hitomi.tilibrary.transfer; +import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.drawable.Drawable; @@ -10,6 +11,7 @@ import androidx.annotation.NonNull; +import com.gyf.immersionbar.ImmersionBar; import com.hitomi.tilibrary.loader.ImageLoader; import com.hitomi.tilibrary.view.image.TransferImage; @@ -141,9 +143,11 @@ void startPreview(final TransferImage targetImage, final File source, * @param clipSize 裁剪的尺寸数组 */ void clipTargetImage(TransferImage targetImage, Drawable originDrawable, int[] clipSize) { - DisplayMetrics displayMetrics = transfer.getContext().getResources().getDisplayMetrics(); + if (!(transfer.getContext() instanceof Activity)) return; + Activity activity = ((Activity) transfer.getContext()); + DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics(); int width = displayMetrics.widthPixels; - int height = displayMetrics.heightPixels; + int height = displayMetrics.heightPixels + ImmersionBar.getNotchHeight(activity); targetImage.setOriginalInfo( originDrawable, diff --git a/app/src/main/java/com/hitomi/transferimage/activity/ComplexDemoActivity.java b/app/src/main/java/com/hitomi/transferimage/activity/ComplexDemoActivity.java index 54881e8..1a753d7 100644 --- a/app/src/main/java/com/hitomi/transferimage/activity/ComplexDemoActivity.java +++ b/app/src/main/java/com/hitomi/transferimage/activity/ComplexDemoActivity.java @@ -16,6 +16,8 @@ import com.hitomi.tilibrary.transfer.Transferee; import com.hitomi.transferimage.R; import com.hitomi.transferimage.SourceConfig; +import com.nostra13.universalimageloader.core.ImageLoader; +import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.squareup.picasso.Picasso; import com.vansz.glideimageloader.GlideImageLoader; import com.vansz.picassoimageloader.PicassoImageLoader; @@ -60,14 +62,12 @@ private void noneViewDemo() { } private void singleViewDemo() { - Glide.with(this) - .load(SourceConfig.getMixingSourceGroup().get(0)) - .placeholder(R.mipmap.ic_empty_photo) - .into(imageView); + ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); + ImageLoader.getInstance().displayImage(SourceConfig.getMixingSourceGroup().get(0), imageView); imageView.setOnClickListener(v -> { Transferee.getDefault(this).apply(TransferConfig.build() .setSourceUrlList(SourceConfig.getMixingSourceGroup()) - .setImageLoader(GlideImageLoader.with(getApplicationContext())) + .setImageLoader(UniversalImageLoader.with(getApplicationContext())) .enableJustLoadHitPage(true) .setCustomView(View.inflate(getBaseContext(), R.layout.layout_custom, null)) .bindImageView(imageView)