调整Glide设置高宽的方法
隐藏直播间右侧贵族头条之类的view 取消首页进入密码房输入密码,不然会弹两次密码输入框 密码输入框响应取消按钮
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestBuilder;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
@@ -44,26 +45,12 @@ public class ImgLoader {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.load(url)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (width == -1 || height == -1) {
|
||||
imageView.setImageBitmap(resource);
|
||||
} else {
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url);
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
}
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
public static void display2(Context context, String url, ImageView imageView) {
|
||||
@@ -73,36 +60,23 @@ public class ImgLoader {
|
||||
/**
|
||||
* 手动清空内存
|
||||
*/
|
||||
public static void clearMemory(Context context){
|
||||
public static void clearMemory(Context context) {
|
||||
Glide.get(context)
|
||||
.clearMemory();
|
||||
}
|
||||
|
||||
public static void display2(Context context, String url, ImageView imageView, int width, int height) {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.placeholder(imageView.getDrawable())
|
||||
.dontAnimate()
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (width == -1 || height == -1) {
|
||||
imageView.setImageBitmap(resource);
|
||||
} else {
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
.placeholder(imageView.getDrawable());
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
}
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
public static void display2(Context context, int url, ImageView imageView) {
|
||||
@@ -129,27 +103,14 @@ public class ImgLoader {
|
||||
if (imageView == null) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.error(errorRes)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (width == -1 || height == -1) {
|
||||
imageView.setImageBitmap(resource);
|
||||
} else {
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
.error(errorRes);
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
}
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
public static void displayWithError(Context context, int url, ImageView imageView, int errorRes) {
|
||||
@@ -173,27 +134,14 @@ public class ImgLoader {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.error(R.mipmap.icon_avatar_placeholder)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (width == -1 || height == -1) {
|
||||
imageView.setImageBitmap(resource);
|
||||
} else {
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
.error(R.mipmap.icon_avatar_placeholder);
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
}
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
public static void displayAvatar(Context context, int url, ImageView imageView) {
|
||||
@@ -256,7 +204,7 @@ public class ImgLoader {
|
||||
|
||||
public static void displayDrawable(Context context, String url, final DrawableCallback callback) {
|
||||
|
||||
if (TextUtils.isEmpty(url)||!contextIsExist(context)) {
|
||||
if (TextUtils.isEmpty(url) || !contextIsExist(context)) {
|
||||
if (callback != null)
|
||||
callback.onLoadFailed();
|
||||
} else {
|
||||
@@ -329,27 +277,14 @@ public class ImgLoader {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
.apply(RequestOptions.bitmapTransform(sBlurTransformation))
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (width == -1 || height == -1) {
|
||||
imageView.setImageBitmap(resource);
|
||||
} else {
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
.apply(RequestOptions.bitmapTransform(sBlurTransformation));
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
}
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,26 +298,14 @@ public class ImgLoader {
|
||||
if (!contextIsExist(context)) {
|
||||
return;
|
||||
}
|
||||
Glide.with(context).asBitmap().load(url)
|
||||
.skipMemoryCache(SKIP_MEMORY_CACHE)
|
||||
RequestBuilder<Drawable> builder = Glide.with(context)
|
||||
.load(url)
|
||||
.apply(RequestOptions.bitmapTransform(new BlurTransformation(20)))
|
||||
.placeholder(R.mipmap.live_bg)
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
if (width == -1 || height == -1) {
|
||||
imageView.setImageBitmap(resource);
|
||||
} else {
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(resource, width, height);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
.placeholder(R.mipmap.live_bg);
|
||||
if (width != -1 && height != -1) {
|
||||
builder = builder.override(width, height);
|
||||
}
|
||||
builder.into(imageView);
|
||||
}
|
||||
|
||||
private static boolean contextIsExist(Context context) {
|
||||
|
||||
Reference in New Issue
Block a user