1:修改搜索房间历史,添加删除功能
2:修改图片展示添加日志记录 3:更改设置群管理员的提示语
This commit is contained in:
@@ -9,18 +9,25 @@ import android.graphics.ColorMatrix;
|
|||||||
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.ColorMatrixColorFilter;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.DataSource;
|
||||||
import com.bumptech.glide.load.DecodeFormat;
|
import com.bumptech.glide.load.DecodeFormat;
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.model.GlideUrl;
|
import com.bumptech.glide.load.model.GlideUrl;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.bumptech.glide.signature.ObjectKey;
|
import com.bumptech.glide.signature.ObjectKey;
|
||||||
@@ -48,22 +55,153 @@ public class ImageLoader {
|
|||||||
|
|
||||||
public static void loadHead(Context context, ImageView view, String url) {
|
public static void loadHead(Context context, ImageView view, String url) {
|
||||||
RequestOptions options = RequestOptions.circleCropTransform();
|
RequestOptions options = RequestOptions.circleCropTransform();
|
||||||
Glide.with(context).load(url).apply(createUrlOnlyOptions(url)).error(com.xscm.moduleutil.R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).thumbnail(0.3f).into(view);
|
Glide.with(context).load(url).apply(createUrlOnlyOptions(url)).error(com.xscm.moduleutil.R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",url);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",url);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",url);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",url);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+url, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadHead(ImageView view, String url) {
|
public static void loadHead(ImageView view, String url) {
|
||||||
RequestOptions options = RequestOptions.circleCropTransform();
|
RequestOptions options = RequestOptions.circleCropTransform();
|
||||||
Glide.with(view).load(url).apply(createUrlOnlyOptions(url)).error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).thumbnail(0.3f).into(view);
|
Glide.with(view).load(url).apply(createUrlOnlyOptions(url)).error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",url);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",url);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",url);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",url);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+url, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadImage(ImageView view, String url) {
|
public static void loadImage(ImageView view, String url) {
|
||||||
RequestOptions options = RequestOptions.circleCropTransform();
|
RequestOptions options = RequestOptions.circleCropTransform();
|
||||||
Glide.with(view).load(url).apply(createUrlOnlyOptions(url)).error(R.mipmap.default_image).placeholder(R.mipmap.default_image).thumbnail(0.3f).into(view);
|
Glide.with(view).load(url).apply(createUrlOnlyOptions(url)).error(R.mipmap.default_image).placeholder(R.mipmap.default_image)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",url);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",url);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",url);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",url);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+url, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadImage(Context context, ImageView view, String url) {
|
public static void loadImage(Context context, ImageView view, String url) {
|
||||||
Glide.with(context).load(url).apply(createUrlOnlyOptions(url)).error(R.mipmap.default_image).placeholder(R.mipmap.default_image)
|
Glide.with(context).load(url).apply(createUrlOnlyOptions(url)).error(R.mipmap.default_image).placeholder(R.mipmap.default_image)
|
||||||
.thumbnail(0.3f).into(view);
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",url);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",url);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",url);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",url);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+url, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(view);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 加载图片并灰度
|
* 加载图片并灰度
|
||||||
@@ -74,13 +212,79 @@ public class ImageLoader {
|
|||||||
*/
|
*/
|
||||||
public static void loadImage(Context context,ImageView view, String url, Float placeholder) {
|
public static void loadImage(Context context,ImageView view, String url, Float placeholder) {
|
||||||
Glide.with(context).load(url).apply(RequestOptions.bitmapTransform(new GrayscaleTransformation(placeholder)))
|
Glide.with(context).load(url).apply(RequestOptions.bitmapTransform(new GrayscaleTransformation(placeholder)))
|
||||||
.error(R.mipmap.default_image).placeholder(R.mipmap.default_image).diskCacheStrategy(DiskCacheStrategy.RESOURCE).thumbnail(0.3f).into(view);
|
.error(R.mipmap.default_image).placeholder(R.mipmap.default_image).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",url);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",url);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",url);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",url);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+url, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(view);
|
||||||
}
|
}
|
||||||
// 可调节灰度程度的方法
|
// 可调节灰度程度的方法
|
||||||
public static void loadGrayscaleImage(Context context, String url, ImageView imageView, float saturation) {
|
public static void loadGrayscaleImage(Context context, String url, ImageView imageView, float saturation) {
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.load(url)
|
.load(url)
|
||||||
.apply(RequestOptions.bitmapTransform(new GrayscaleTransformation(saturation)))
|
.apply(RequestOptions.bitmapTransform(new GrayscaleTransformation(saturation)))
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",url);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",url);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",url);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",url);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+url, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
.into(imageView);
|
.into(imageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import android.graphics.RectF;
|
|||||||
import android.graphics.Shader;
|
import android.graphics.Shader;
|
||||||
import android.graphics.drawable.AnimationDrawable;
|
import android.graphics.drawable.AnimationDrawable;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -29,6 +30,7 @@ import androidx.annotation.RequiresApi;
|
|||||||
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
|
||||||
|
|
||||||
import com.blankj.utilcode.util.ConvertUtils;
|
import com.blankj.utilcode.util.ConvertUtils;
|
||||||
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.blankj.utilcode.util.Utils;
|
import com.blankj.utilcode.util.Utils;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.integration.webp.decoder.WebpDrawable;
|
import com.bumptech.glide.integration.webp.decoder.WebpDrawable;
|
||||||
@@ -80,7 +82,9 @@ public class ImageUtils {
|
|||||||
private static RequestOptions createUrlOnlyOptions(String url) {
|
private static RequestOptions createUrlOnlyOptions(String url) {
|
||||||
return new RequestOptions().signature(new ObjectKey(url!=null ? url :"")).diskCacheStrategy(DiskCacheStrategy.ALL)
|
return new RequestOptions().signature(new ObjectKey(url!=null ? url :"")).diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
.skipMemoryCache(false)
|
.skipMemoryCache(false)
|
||||||
.format(DecodeFormat.PREFER_RGB_565);
|
.format(DecodeFormat.PREFER_RGB_565)
|
||||||
|
.error(new ColorDrawable(Color.TRANSPARENT)); // 透明错误图;
|
||||||
|
|
||||||
// 禁止尺寸影响缓存
|
// 禁止尺寸影响缓存
|
||||||
// .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
|
// .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
|
||||||
}
|
}
|
||||||
@@ -89,7 +93,40 @@ public class ImageUtils {
|
|||||||
* 默认加载
|
* 默认加载
|
||||||
*/
|
*/
|
||||||
public static void loadImageView(String path, ImageView mImageView) {
|
public static void loadImageView(String path, ImageView mImageView) {
|
||||||
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path)).thumbnail(0.3f).into(mImageView);
|
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path))
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,7 +134,40 @@ public class ImageUtils {
|
|||||||
*/
|
*/
|
||||||
public static void loadIcon(String path, ImageView mImageView) {
|
public static void loadIcon(String path, ImageView mImageView) {
|
||||||
mImageView.setVisibility(TextUtils.isEmpty(path) ? GONE : View.VISIBLE);
|
mImageView.setVisibility(TextUtils.isEmpty(path) ? GONE : View.VISIBLE);
|
||||||
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path)).thumbnail(0.3f).into(mImageView);
|
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path))
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,7 +187,40 @@ public class ImageUtils {
|
|||||||
*/
|
*/
|
||||||
public static void loadSample(String path, ImageView mImageView, int width, int height) {
|
public static void loadSample(String path, ImageView mImageView, int width, int height) {
|
||||||
RequestOptions options = new RequestOptions().override(width, height).diskCacheStrategy(DiskCacheStrategy.RESOURCE);
|
RequestOptions options = new RequestOptions().override(width, height).diskCacheStrategy(DiskCacheStrategy.RESOURCE);
|
||||||
Glide.with(mImageView).load(path).apply(options).thumbnail(0.3f).into(mImageView);
|
Glide.with(mImageView).load(path).apply(options)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +313,39 @@ public class ImageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path)).error(errorRes).
|
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path)).error(errorRes).
|
||||||
placeholder(errorRes).centerCrop().diskCacheStrategy(DiskCacheStrategy.ALL).thumbnail(0.3f).into(mImageView);
|
placeholder(errorRes).centerCrop().listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(mImageView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +362,40 @@ public class ImageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path))
|
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path))
|
||||||
.placeholder(R.mipmap.default_avatar).diskCacheStrategy(DiskCacheStrategy.RESOURCE).thumbnail(0.3f).into(mImageView);
|
.placeholder(R.mipmap.default_avatar).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).thumbnail(0.3f).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadHeadCC(String path, ImageView mImageView) {
|
public static void loadHeadCC(String path, ImageView mImageView) {
|
||||||
@@ -243,7 +411,8 @@ public class ImageUtils {
|
|||||||
}
|
}
|
||||||
Glide.with(mImageView).asBitmap().load(path)
|
Glide.with(mImageView).asBitmap().load(path)
|
||||||
.apply(createUrlOnlyOptions(path))
|
.apply(createUrlOnlyOptions(path))
|
||||||
.error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).centerCrop().thumbnail(0.3f).into(mImageView);
|
.error(R.mipmap.default_avatar).placeholder(R.mipmap.default_avatar).centerCrop()
|
||||||
|
.thumbnail(0.3f).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadHead(String path, ImageView mImageView) {
|
public static void loadHead(String path, ImageView mImageView) {
|
||||||
@@ -258,7 +427,39 @@ public class ImageUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path))
|
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path))
|
||||||
.thumbnail(0.3f).into(mImageView);
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}) .thumbnail(0.3f).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadHeadCC(String path, ImageView mImageView, LinearLayout.LayoutParams params) {
|
public static void loadHeadCC(String path, ImageView mImageView, LinearLayout.LayoutParams params) {
|
||||||
@@ -307,18 +508,83 @@ public class ImageUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadCenterCrop(String path, ImageView mImageView) {
|
public static void loadCenterCrop(String path, ImageView mImageView) {
|
||||||
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path)).centerCrop().into(mImageView);
|
Glide.with(mImageView).load(path).apply(createUrlOnlyOptions(path)).centerCrop()
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).into(mImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadRes(int path, ImageView mImageView) {
|
public static void loadRes(int path, ImageView mImageView) {
|
||||||
Glide.with(mImageView).load(path).diskCacheStrategy(DiskCacheStrategy.RESOURCE).into(mImageView);
|
Glide.with(mImageView).load(path).diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model,
|
||||||
|
Target<Drawable> target, DataSource dataSource,
|
||||||
|
boolean isFirstResource) {
|
||||||
|
// dataSource 是关键参数!
|
||||||
|
switch (dataSource) {
|
||||||
|
case DATA_DISK_CACHE:
|
||||||
|
case RESOURCE_DISK_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自磁盘缓存",path);
|
||||||
|
break;
|
||||||
|
case MEMORY_CACHE:
|
||||||
|
LogUtils.e("GlideCache", "来自内存缓存",path);
|
||||||
|
break;
|
||||||
|
case LOCAL: // 本地文件
|
||||||
|
LogUtils.e("GlideCache", "来自本地文件",path);
|
||||||
|
break;
|
||||||
|
case REMOTE: // 网络下载
|
||||||
|
LogUtils.e("GlideCache", "来自网络下载",path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogUtils.e("GlideCache", "来自: " + dataSource);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||||
|
Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
Log.e("GlideCache", "加载失败"+"path:"+path, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).into(mImageView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载图片(优先使用本地缓存,无缓存则下载)
|
* 加载图片(优先使用本地缓存,无缓存则下载)
|
||||||
*
|
*
|
||||||
* @param context 上下文
|
|
||||||
* @param url 图片 URL
|
* @param url 图片 URL
|
||||||
* @param imageView 目标 ImageView
|
* @param imageView 目标 ImageView
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class GroupUserListAdapter :
|
|||||||
private fun showOptionsDialog(ismute: Int, item: GroupBean.GroupUserBean?, b: Boolean) {
|
private fun showOptionsDialog(ismute: Int, item: GroupBean.GroupUserBean?, b: Boolean) {
|
||||||
val options = arrayOf<String?>(
|
val options = arrayOf<String?>(
|
||||||
if (ismute == 1) "解禁" else "禁言",
|
if (ismute == 1) "解禁" else "禁言",
|
||||||
if (b) "设置成普通成员" else "设置成管理员"
|
if (b) "取消管理员" else "设置管理员"
|
||||||
)
|
)
|
||||||
if (isOwner != 1){
|
if (isOwner != 1){
|
||||||
options[1] = ""
|
options[1] = ""
|
||||||
|
|||||||
@@ -106,7 +106,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:visibility="gone" />
|
android:src="@mipmap/dele_foot"
|
||||||
|
/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|||||||
Reference in New Issue
Block a user