Browse Source

修改图片地址

炒锅机器人_一拖多
liup 2 months ago
parent
commit
af05d1975d
4 changed files with 23 additions and 32 deletions
  1. +16
    -27
      app/src/main/java/com/bonait/bnframework/common/glide/GlideUtil.java
  2. +1
    -1
      app/src/main/java/com/bonait/bnframework/newui/activity/ImageChooseActivity.java
  3. +3
    -2
      app/src/main/java/com/bonait/bnframework/newui/http/UpdateAllDataService.java
  4. +3
    -2
      app/src/main/java/com/bonait/bnframework/newui/http/UpdateDataService.java

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

@@ -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)


+ 1
- 1
app/src/main/java/com/bonait/bnframework/newui/activity/ImageChooseActivity.java View File

@@ -81,7 +81,7 @@ public class ImageChooseActivity extends BaseActivity {
recyclerView.postDelayed(new Runnable() {
@Override
public void run() {
EventBus.getDefault().post(new ImageSelectEvent(CACHE_PATH+"/"+sp.url));
EventBus.getDefault().post(new ImageSelectEvent(sp.url));
}
},500);
}


+ 3
- 2
app/src/main/java/com/bonait/bnframework/newui/http/UpdateAllDataService.java View File

@@ -378,8 +378,9 @@ public class UpdateAllDataService {
if(classify!=null){
String imgUrl = "";
if(good.url!=null){
String path = Environment.getExternalStorageDirectory().getAbsolutePath()+ ConfigName.dataPath+"/WebImage/";
imgUrl = "https://bpa.oss-cn-chengdu.aliyuncs.com/hkerp/test/goods//"+good.url.replace(path,"");
if((good.url.contains("png")||good.url.contains("jpg")||good.url.contains("jpeg"))){
imgUrl = "https://bpa.oss-cn-chengdu.aliyuncs.com/hkerp/test/goods//"+good.url;
}
}
upMaterialBean.add(new GoodsDataInfo(good.id,good.name,"",imgUrl,"0",false,good.propClassifyId,classify.name));
}


+ 3
- 2
app/src/main/java/com/bonait/bnframework/newui/http/UpdateDataService.java View File

@@ -424,8 +424,9 @@ public class UpdateDataService {

String imgUrl = "";
if(goods.url!=null){
String path = Environment.getExternalStorageDirectory().getAbsolutePath()+ ConfigName.dataPath+"/WebImage/";
imgUrl = "https://bpa.oss-cn-chengdu.aliyuncs.com/hkerp/test/goods//"+goods.url.replace(path,"");
if((goods.url.contains("png")||goods.url.contains("jpg")||goods.url.contains("jpeg"))){
imgUrl = "https://bpa.oss-cn-chengdu.aliyuncs.com/hkerp/test/goods//"+goods.url;
}
}
upMaterialBean.add(new GoodsDataInfo(goods.id,goods.name,"",imgUrl,"0",false,goods.propClassifyId,
classify.name));


Loading…
Cancel
Save