餐品配比终端初始化

This commit is contained in:
马增飞
2025-01-22 11:53:25 +08:00
parent 74010127c7
commit e50fa8e6f5
542 changed files with 60062 additions and 0 deletions
@@ -0,0 +1,68 @@
package com.sw.st.net;
import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.FutureTarget;
import com.bumptech.glide.request.RequestOptions;
import com.sw.st.R;
import java.io.File;
/**
* 图片加载管理
*/
public class ImageLoaderManager {
public static void LoadRoundImage(Context context, String imgUrl, ImageView imageView, int roundingRadius) {
RequestOptions cropOptions = new RequestOptions();
cropOptions.transform(new RoundedCorners(roundingRadius));//new CenterCrop()
Glide.with(context)
.load(imgUrl)
.placeholder(R.mipmap.ic_launcher)
.dontAnimate() //解决圆形图显示占位图问题
.error(R.mipmap.ic_launcher)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.apply(cropOptions)
.into(imageView);
}
public static void LoadImage(Context context, String imgUrl, ImageView imageView) {
Glide.with(context)
.load(imgUrl)
.placeholder(R.mipmap.ic_launcher)
.dontAnimate() //解决圆形图显示占位图问题
.error(R.mipmap.ic_launcher)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(imageView);
// Glide
// .with(myFragment)
// .load(url)
// .centerCrop()
// .placeholder(R.drawable.loading_spinner)
// .into(myImageView);
}
/**
* 缓存图片到本地
*/
public static File CacheFile(Context context, String imgUrl) {
File cacheFile = null;
FutureTarget<File> future = Glide.with(context)
.load(imgUrl)
.downloadOnly(500, 500);
try {
cacheFile = future.get();
} catch (Exception e) {
e.printStackTrace();
}
return cacheFile;
}
}