|
|
@@ -2,11 +2,15 @@ package com.bonait.bnframework.common.glide; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
import android.os.Environment; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.ImageView; |
|
|
|
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
|
|
|
import com.bonait.bnframework.MainApplication; |
|
|
|
import com.bonait.bnframework.R; |
|
|
|
import com.bonait.bnframework.common.constant.ConfigName; |
|
|
|
import com.bonait.bnframework.common.glide.transform.FitXYRoundRadiusTransform; |
|
|
|
import com.bonait.bnframework.common.utils.DimensUtil; |
|
|
|
import com.bumptech.glide.load.DataSource; |
|
|
@@ -59,35 +63,13 @@ public class GlideUtil { |
|
|
|
if (context == null||path==null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
GlideApp.with(context) |
|
|
|
.load(path) |
|
|
|
.addListener(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 (imageView == null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
imageView.setBackground(null); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}) |
|
|
|
.placeholder(placeId) |
|
|
|
.transition(DrawableTransitionOptions.withCrossFade(CROSS_FADE_DURATION)) |
|
|
|
.into(imageView); |
|
|
|
} |
|
|
|
|
|
|
|
public static void showImage(Context context, int path, ImageView imageView,int placeId) { |
|
|
|
if (context == null) { |
|
|
|
if((!path.contains("png")&&!path.contains("jpg")&&!path.contains("jpeg"))){ |
|
|
|
imageView.setImageResource(R.mipmap.loading123); |
|
|
|
return; |
|
|
|
} |
|
|
|
if(!path.contains("http")){ |
|
|
|
path = Environment.getExternalStorageDirectory().getAbsolutePath()+ ConfigName.dataPath+"/WebImage/"+path; |
|
|
|
} |
|
|
|
GlideApp.with(context) |
|
|
|
.load(path) |
|
|
|
.addListener(new RequestListener<Drawable>() { |
|
|
@@ -117,6 +99,13 @@ public class GlideUtil { |
|
|
|
if (context == null||path==null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if((!path.contains("png")&&!path.contains("jpg")&&!path.contains("jpeg"))){ |
|
|
|
imageView.setImageResource(R.mipmap.loading123); |
|
|
|
return; |
|
|
|
} |
|
|
|
if(!path.contains("http")){ |
|
|
|
path = Environment.getExternalStorageDirectory().getAbsolutePath()+ ConfigName.dataPath+"/WebImage/"+path; |
|
|
|
} |
|
|
|
setType(imageView); |
|
|
|
GlideApp.with(context) |
|
|
|
.load(path) |
|
|
|