Browse Source

使用glide加载图片

调味吧台
liup 5 months ago
parent
commit
17ad24cd4a
15 changed files with 668 additions and 13 deletions
  1. +7
    -0
      app/build.gradle
  2. +115
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java
  3. +50
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/MyAppGlideModule.java
  4. +95
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/transform/FitXYRoundRadiusTransform.java
  5. +67
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideBorderTransform.java
  6. +64
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideRoundTransform.java
  7. +85
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/transform/RoundRadiusTransform.java
  8. +155
    -0
      app/src/main/java/com/bonait/bnframework/common/glide/transform/TransformationFitXYUtils.java
  9. +5
    -2
      app/src/main/java/com/bonait/bnframework/common/view/AddGoodDialog.java
  10. +3
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/image_sp_adapter.java
  11. +3
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/newgood_adapter.java
  12. +3
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/newmakegood_adapter.java
  13. +7
    -3
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/GoodInformation.java
  14. +7
    -3
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java
  15. +2
    -2
      app/src/main/res/layout/datatab/layout/pfsx_item.xml

+ 7
- 0
app/build.gradle View File

@@ -181,4 +181,11 @@ dependencies {
//腾讯bugly
//sdk地址 https://bugly.qq.com/docs/user-guide/instruction-manual-android/?v=1.0.0
implementation 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新Bugly SDK版本号,也可以指定明确的版本号,例如4.0.3

api 'org.greenrobot:eventbus:3.1.1'

api 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
api "com.github.bumptech.glide:okhttp3-integration:4.16.0"
api 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
}

+ 115
- 0
app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java View File

@@ -0,0 +1,115 @@
package com.bonait.bnframework.common.glide;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bonait.bnframework.common.glide.transform.FitXYRoundRadiusTransform;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;

/**
* @author: liup
* @description:
* @date: 2024/5/8 16:45.
*/
public class GlideUtil {

private static final int CROSS_FADE_DURATION = 100;

private GlideUtil() {
throw new AssertionError();
}

// public static String exchangeUrl(String path){
// String result=path;
// if(!TextUtils.isEmpty(PATH_PRE)&&!TextUtils.isEmpty(path)) {
// if(!path.contains("http:")&&!path.contains("https:")){
// if(path.contains(".png")||path.contains(".jpg")||path.contains(".jpeg")||path.contains(".gif")){
// if(TEST) {
// result = PATH_PRE + path.replace("images", "modules");
// }else{
// result = PATH_PRE + path;
// }
// if(first){
// LogUtils.d("GlideUtil exchangeUrl result:"+result);
// first=false;
// }
// }
// }
// }
//// LogUtils.i("GlideUtil exchangeUrl"+result);
// return result;
// }

public static void showImage(Context context, String path, ImageView imageView,int placeId) {
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 showImageWithRadius(Context context, String path, ImageView imageView,int placeId,int radius) {
if (context == null||path==null) {
return;
}
setType(imageView);
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;
}
})
.transition(DrawableTransitionOptions.withCrossFade(CROSS_FADE_DURATION))
// .apply(RequestOptions.bitmapTransform(new RoundedCorners(RADIUS)))
.apply(new RequestOptions().transform(new FitXYRoundRadiusTransform(radius)))
.into(imageView);
}

private static void setType(ImageView imageView){//硬件加速
imageView.setLayerType(View.LAYER_TYPE_HARDWARE,null);
}
}

+ 50
- 0
app/src/main/java/com/bonait/bnframework/common/glide/MyAppGlideModule.java View File

@@ -0,0 +1,50 @@
package com.bonait.bnframework.common.glide;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.load.engine.cache.MemorySizeCalculator;
import com.bumptech.glide.module.AppGlideModule;

/**
* Glide模块
*
* @author song.zheng@androidmov.com
*/
@GlideModule
public final class MyAppGlideModule extends AppGlideModule {

@Override
public boolean isManifestParsingEnabled() {
return false;
}

@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
builder.setLogLevel(Log.WARN);
int cacheSize100MegaBytes = 104857600;
//应用私有目录
builder.setDiskCache(
new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes)
);

MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
.setMemoryCacheScreens(2)
.build();
int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
int defaultBitmapPoolSize = calculator.getBitmapPoolSize();

int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize);
int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize);

builder.setMemoryCache( new LruResourceCache( customMemoryCacheSize ));
builder.setBitmapPool(new LruBitmapPool( customBitmapPoolSize ));
}
}

+ 95
- 0
app/src/main/java/com/bonait/bnframework/common/glide/transform/FitXYRoundRadiusTransform.java View File

@@ -0,0 +1,95 @@
package com.bonait.bnframework.common.glide.transform;

import android.graphics.Bitmap;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.util.Util;

import java.nio.ByteBuffer;
import java.security.MessageDigest;

/**
* @author: wx
* @date: 2023/1/29
*/
public class FitXYRoundRadiusTransform extends BitmapTransformation {

// 此处用实际类的完整路径
private static final String ID = "com.amt.module_common.util.image.FitXYRoundRadiusTransform";
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);

private final int roundingRadius;

private boolean isLeftTop = true;
private boolean isRightTop = true;
private boolean isLeftBottom = true;
private boolean isRightBottom = true;


public FitXYRoundRadiusTransform(int roundingRadius) {
this.roundingRadius = roundingRadius;
}

public FitXYRoundRadiusTransform(int roundingRadius, boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) {
this.roundingRadius = roundingRadius;
setNeedCorner(leftTop, rightTop, leftBottom, rightBottom);
}

/**
* 需要设置圆角的部分
*
* @param leftTop 左上角
* @param rightTop 右上角
* @param leftBottom 左下角
* @param rightBottom 右下角
*/
public void setNeedCorner(boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) {
isLeftTop = leftTop;
isRightTop = rightTop;
isLeftBottom = leftBottom;
isRightBottom = rightBottom;
}

@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {

Bitmap bitmap = TransformationFitXYUtils.fitXY(pool, toTransform, outWidth, outHeight);

return TransformationFitXYUtils.roundCrop(pool, bitmap,
isLeftTop ? roundingRadius : 0,
isRightTop ? roundingRadius : 0,
isRightBottom ? roundingRadius : 0,
isLeftBottom ? roundingRadius : 0);
}


@Override
public boolean equals(Object o) {
if (o instanceof FitXYRoundRadiusTransform) {
FitXYRoundRadiusTransform other = (FitXYRoundRadiusTransform) o;
return roundingRadius == other.roundingRadius;
}
return false;
}

@Override
public int hashCode() {
return Util.hashCode(ID.hashCode(), Util.hashCode(roundingRadius));
}

@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
messageDigest.update(ID_BYTES);

byte[] radiusData = ByteBuffer.allocate(4).putInt(roundingRadius).array();
messageDigest.update(radiusData);
}





}

+ 67
- 0
app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideBorderTransform.java View File

@@ -0,0 +1,67 @@
package com.bonait.bnframework.common.glide.transform;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;

import java.security.MessageDigest;

/**
* Glide边框转换
*
* @author song.zheng@androidmov.com
*/
public class GlideBorderTransform extends BitmapTransformation {
private final float borderWidth;
private final int borderColor;

public GlideBorderTransform(float borderWidth, int borderColor) {
super();
this.borderWidth = borderWidth;
this.borderColor = borderColor;
}

@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth,
int outHeight) {
Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight);
return border(pool, bitmap);
}

private Bitmap border(BitmapPool pool, Bitmap source) {
if (source == null) {
return null;
}
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
canvas.drawRect(rectF, paint);
paint.reset();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(borderWidth);
paint.setColor(borderColor);
paint.setAntiAlias(true);
canvas.drawRect(rectF, paint);
return result;
}

public String getId() {
return getClass().getName() + Math.round(borderWidth);
}

@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {

}
}

+ 64
- 0
app/src/main/java/com/bonait/bnframework/common/glide/transform/GlideRoundTransform.java View File

@@ -0,0 +1,64 @@
package com.bonait.bnframework.common.glide.transform;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;

import java.security.MessageDigest;

/**
* Glide圆角转换
*
* @author song.zheng@androidmov.com
*/
public class GlideRoundTransform extends BitmapTransformation {
private static float radius = 0f;

public GlideRoundTransform(Context context) {
this(context, 8);
}

public GlideRoundTransform(Context context, int px) {
super();
radius = px;
}

@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth,
int outHeight) {
Bitmap bitmap = TransformationUtils.centerCrop(pool, toTransform, outWidth, outHeight);
return roundCrop(pool, bitmap);
}

private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
if (source == null) {
return null;
}
Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
Paint paint = new Paint();
paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
paint.setAntiAlias(true);
RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
canvas.drawRoundRect(rectF, radius, radius, paint);
return result;
}

public String getId() {
return getClass().getName() + Math.round(radius);
}

@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {

}
}

+ 85
- 0
app/src/main/java/com/bonait/bnframework/common/glide/transform/RoundRadiusTransform.java View File

@@ -0,0 +1,85 @@
package com.bonait.bnframework.common.glide.transform;

import android.graphics.Bitmap;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
import com.bumptech.glide.util.Util;

import java.nio.ByteBuffer;
import java.security.MessageDigest;

/**
* @author: wx
* @date: 2023/1/29
*/
public class RoundRadiusTransform extends BitmapTransformation {

// 此处用实际类的完整路径
private static final String ID = "com.amt.module_common.util.image.RoundRadiusTransform";
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);

private final int roundingRadius;

private boolean isLeftTop, isRightTop, isLeftBottom, isRightBottom;

private static RoundRadiusTransform mInstance;

public RoundRadiusTransform(int roundingRadius) {
this.roundingRadius = roundingRadius;
}
public RoundRadiusTransform(int roundingRadius,boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) {
this.roundingRadius = roundingRadius;
setNeedCorner(leftTop, rightTop, leftBottom, rightBottom);
}

/**
* 需要设置圆角的部分
*
* @param leftTop 左上角
* @param rightTop 右上角
* @param leftBottom 左下角
* @param rightBottom 右下角
*/
public void setNeedCorner(boolean leftTop, boolean rightTop, boolean leftBottom, boolean rightBottom) {
isLeftTop = leftTop;
isRightTop = rightTop;
isLeftBottom = leftBottom;
isRightBottom = rightBottom;
}

@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
return TransformationUtils.roundedCorners(pool, toTransform,
isLeftTop ? roundingRadius : 0,
isRightTop ? roundingRadius : 0,
isRightBottom ? roundingRadius : 0,
isLeftBottom ? roundingRadius : 0);
}


@Override
public boolean equals(Object o) {
if (o instanceof RoundRadiusTransform) {
RoundRadiusTransform other = (RoundRadiusTransform) o;
return roundingRadius == other.roundingRadius;
}
return false;
}

@Override
public int hashCode() {
return Util.hashCode(ID.hashCode(), Util.hashCode(roundingRadius));
}

@Override
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
messageDigest.update(ID_BYTES);

byte[] radiusData = ByteBuffer.allocate(4).putInt(roundingRadius).array();
messageDigest.update(radiusData);
}
}

+ 155
- 0
app/src/main/java/com/bonait/bnframework/common/glide/transform/TransformationFitXYUtils.java View File

@@ -0,0 +1,155 @@
package com.bonait.bnframework.common.glide.transform;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
import com.bumptech.glide.util.Synthetic;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;

/**
* @author Nov
* @date 23.7.11
*/
public class TransformationFitXYUtils {
private static final Lock BITMAP_DRAWABLE_LOCK =
new NoLock();

@NonNull
private static Bitmap.Config getNonNullConfig(@NonNull Bitmap bitmap) {
return bitmap.getConfig() != null ? bitmap.getConfig() : Bitmap.Config.ARGB_8888;
}

private static void applyMatrix(
@NonNull Bitmap inBitmap, @NonNull Bitmap targetBitmap, Matrix matrix) {
BITMAP_DRAWABLE_LOCK.lock();
try {
Canvas canvas = new Canvas(targetBitmap);
canvas.drawBitmap(inBitmap, matrix, DEFAULT_PAINT);
clear(canvas);
} finally {
BITMAP_DRAWABLE_LOCK.unlock();
}
}

public static final int PAINT_FLAGS = Paint.DITHER_FLAG | Paint.FILTER_BITMAP_FLAG;
private static final Paint DEFAULT_PAINT = new Paint(PAINT_FLAGS);

private static final class NoLock implements Lock {

@Synthetic
NoLock() {
}

@Override
public void lock() {
// do nothing
}

@Override
public void lockInterruptibly() throws InterruptedException {
// do nothing
}

@Override
public boolean tryLock() {
return true;
}

@Override
public boolean tryLock(long time, @NonNull TimeUnit unit) throws InterruptedException {
return true;
}

@Override
public void unlock() {
// do nothing
}

@NonNull
@Override
public Condition newCondition() {
throw new UnsupportedOperationException("Should not be called");
}
}

private static void clear(Canvas canvas) {
canvas.setBitmap(null);
}


public static Bitmap fitXY(
@NonNull BitmapPool pool, @NonNull Bitmap inBitmap, int width, int height) {

if (inBitmap.getWidth() == width && inBitmap.getHeight() == height) {
return inBitmap;
}
final float widthPercentage = width / (float) inBitmap.getWidth();
final float heightPercentage = height / (float) inBitmap.getHeight();
int targetWidth = (int) (widthPercentage * inBitmap.getWidth());
int targetHeight = (int) (heightPercentage * inBitmap.getHeight());

Bitmap.Config config = getNonNullConfig(inBitmap);
Bitmap toReuse = pool.get(targetWidth, targetHeight, config);
TransformationUtils.setAlpha(inBitmap, toReuse);
Matrix matrix = new Matrix();
matrix.setScale(widthPercentage, heightPercentage);
applyMatrix(inBitmap, toReuse, matrix);
return toReuse;
}

public static Bitmap roundCrop(BitmapPool pool,
Bitmap source,
float topLeft,
float topRight,
float bottomRight,
float bottomLeft) {
if (source == null) return null;

Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
}
BitmapShader shader =
new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

Paint paint = new Paint();
paint.setShader(shader);
paint.setAntiAlias(true);
RectF rect = new RectF(0f, 0f, source.getWidth(), source.getHeight());
BITMAP_DRAWABLE_LOCK.lock();
try {
Canvas canvas = new Canvas(result);
Path path = new Path();
path.addRoundRect(
rect,
new float[]{
topLeft,
topLeft,
topRight,
topRight,
bottomRight,
bottomRight,
bottomLeft,
bottomLeft
},
Path.Direction.CW);
canvas.drawPath(path, paint);
clear(canvas);
} finally {
BITMAP_DRAWABLE_LOCK.unlock();
}
return result;
}
}

+ 5
- 2
app/src/main/java/com/bonait/bnframework/common/view/AddGoodDialog.java View File

@@ -29,6 +29,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.res.ResMaterilas;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
@@ -198,7 +199,8 @@ public class AddGoodDialog extends Dialog {
public void onMessage(Object msg) {
if (msg != null) {
url=(String) msg;
new MyBitmapUtils().disPlay(cpfm,url);
GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3);
// new MyBitmapUtils().disPlay(cpfm,url);
}
}
});
@@ -286,7 +288,8 @@ public class AddGoodDialog extends Dialog {
{
edittext.setText(Data.name);
edittext1.setText(Data.foreignKeyRe);
new MyBitmapUtils().disPlay(cpfm,Data.url);
// new MyBitmapUtils().disPlay(cpfm,Data.url);
GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3);
int index=0;
for (Map.Entry<String, String> entry : map_fl.entrySet()) {
String key = entry.getKey();


+ 3
- 1
app/src/main/java/com/bonait/bnframework/modules/home/adapter/image_sp_adapter.java View File

@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
@@ -70,7 +71,8 @@ public class image_sp_adapter extends RecyclerView.Adapter<RecyclerView.ViewHold
if (holder instanceof MyLCViewHolder1) {
MyLCViewHolder1 myViewHolder = (MyLCViewHolder1) holder;
//设置图片
new MyBitmapUtils().disPlay(myViewHolder.img,goods.get(position).url);
// new MyBitmapUtils().disPlay(myViewHolder.img,goods.get(position).url);
GlideUtil.showImage(myViewHolder.img.getContext(),goods.get(position).url,myViewHolder.img,R.mipmap.loading3);
myViewHolder.img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {


+ 3
- 1
app/src/main/java/com/bonait/bnframework/modules/home/adapter/newgood_adapter.java View File

@@ -22,6 +22,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
@@ -75,7 +76,8 @@ public class newgood_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
myViewHolder.Tag_text.setText(goods.name);
//设置图片
if (!goods.url.equals("未知") && !goods.url.isEmpty() && !goods.url.equals("")) {
myBitmapUtils.disPlay(myViewHolder.ImageUrl, goods.url);
// myBitmapUtils.disPlay(myViewHolder.ImageUrl, goods.url);
GlideUtil.showImage(myViewHolder.ImageUrl.getContext(),goods.url,myViewHolder.ImageUrl,R.mipmap.loading3);
}

/**


+ 3
- 1
app/src/main/java/com/bonait/bnframework/modules/home/adapter/newmakegood_adapter.java View File

@@ -16,6 +16,7 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
@@ -68,7 +69,8 @@ public class newmakegood_adapter extends RecyclerView.Adapter<RecyclerView.View
myViewHolder.Tag_text.setText(goods.name);
//设置图片
if (!goods.url.equals("未知") && !goods.url.isEmpty() && !goods.url.equals("")) {
myBitmapUtils.disPlay(myViewHolder.ImageUrl, goods.url);
// myBitmapUtils.disPlay(myViewHolder.ImageUrl, goods.url);
GlideUtil.showImage(myViewHolder.ImageUrl.getContext(),goods.url,myViewHolder.ImageUrl,R.mipmap.loading3);
}

/**


+ 7
- 3
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/GoodInformation.java View File

@@ -34,6 +34,7 @@ import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.res.ResGoodProperty;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.ResMaterilas;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
@@ -344,7 +345,8 @@ public class GoodInformation extends LinearLayout implements MyClickListener {
if (Data != null) {
edittext.setText(Data.name);
edittext1.setText(Data.foreignKeyRe);
new MyBitmapUtils().disPlay(cpfm, Data.url);
// new MyBitmapUtils().disPlay(cpfm, Data.url);
GlideUtil.showImage(cpfm.getContext(),Data.url,cpfm,R.mipmap.loading3);
url = Data.url;
int index = 0;
for (Map.Entry<String, String> entry : map_fl.entrySet()) {
@@ -358,7 +360,8 @@ public class GoodInformation extends LinearLayout implements MyClickListener {
} else {
edittext.setText("");
edittext1.setText("");
new MyBitmapUtils().disPlay(cpfm, "");
// new MyBitmapUtils().disPlay(cpfm, "");
GlideUtil.showImage(cpfm.getContext(),"",cpfm,R.mipmap.loading3);
url = "";
}

@@ -644,7 +647,8 @@ public class GoodInformation extends LinearLayout implements MyClickListener {
public void onMessage(Object msg) {
if (msg != null) {
url = (String) msg;
new MyBitmapUtils().disPlay(cpfm, url);
// new MyBitmapUtils().disPlay(cpfm, url);
GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3);
}
}
});


+ 7
- 3
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_good_control.java View File

@@ -23,6 +23,7 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.res.ResMaterilas;
import com.bonait.bnframework.common.glide.GlideUtil;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.image.MyBitmapUtils;
import com.bonait.bnframework.common.message.MessageLooper;
@@ -221,7 +222,8 @@ public class add_good_control extends LinearLayout {
public void onMessage(Object msg) {
if (msg != null) {
url=(String) msg;
new MyBitmapUtils().disPlay(cpfm,url);
// new MyBitmapUtils().disPlay(cpfm,url);
GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3);
}
}
});
@@ -315,7 +317,8 @@ public class add_good_control extends LinearLayout {
{
edittext.setText(Data.name);
edittext1.setText(Data.foreignKeyRe);
new MyBitmapUtils().disPlay(cpfm,Data.url);
// new MyBitmapUtils().disPlay(cpfm,Data.url);
GlideUtil.showImage(cpfm.getContext(),url,cpfm,R.mipmap.loading3);
url=Data.url;
int index=0;
for (Map.Entry<String, String> entry : map_fl.entrySet()) {
@@ -331,7 +334,8 @@ public class add_good_control extends LinearLayout {
{
edittext.setText("");
edittext1.setText("");
new MyBitmapUtils().disPlay(cpfm,"");
// new MyBitmapUtils().disPlay(cpfm,"");
GlideUtil.showImage(cpfm.getContext(),"",cpfm,R.mipmap.loading3);
url="";
}



+ 2
- 2
app/src/main/res/layout/datatab/layout/pfsx_item.xml View File

@@ -22,8 +22,8 @@
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/dp_10"
android:text="回锅"
android:textAlignment="textEnd"
android:textSize="19dp" />
android:gravity="center"
android:textSize="18sp" />
</RelativeLayout>




Loading…
Cancel
Save