|
@@ -1,21 +1,23 @@
|
|
|
package com.tencent.qcloud.tuikit.timcommon.component.impl;
|
|
package com.tencent.qcloud.tuikit.timcommon.component.impl;
|
|
|
|
|
|
|
|
-import android.content.Context;
|
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Bitmap;
|
|
|
-import android.net.Uri;
|
|
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
|
|
+
|
|
|
import com.bumptech.glide.Glide;
|
|
import com.bumptech.glide.Glide;
|
|
|
-import com.bumptech.glide.Priority;
|
|
|
|
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
|
import com.bumptech.glide.request.RequestListener;
|
|
import com.bumptech.glide.request.RequestListener;
|
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
import com.tencent.qcloud.tuicore.TUILogin;
|
|
import com.tencent.qcloud.tuicore.TUILogin;
|
|
|
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
|
import com.tencent.qcloud.tuicore.TUIThemeManager;
|
|
|
import com.tencent.qcloud.tuikit.timcommon.R;
|
|
import com.tencent.qcloud.tuikit.timcommon.R;
|
|
|
-import java.io.File;
|
|
|
|
|
|
|
+
|
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author 王鹏鹏
|
|
|
|
|
+ */
|
|
|
public class GlideEngine {
|
|
public class GlideEngine {
|
|
|
|
|
+
|
|
|
public static void loadCornerImageWithoutPlaceHolder(ImageView imageView, String filePath, RequestListener listener, float radius) {
|
|
public static void loadCornerImageWithoutPlaceHolder(ImageView imageView, String filePath, RequestListener listener, float radius) {
|
|
|
RoundedCorners transform = null;
|
|
RoundedCorners transform = null;
|
|
|
if ((int) radius > 0) {
|
|
if ((int) radius > 0) {
|
|
@@ -33,14 +35,6 @@ public class GlideEngine {
|
|
|
Glide.with(TUILogin.getAppContext()).clear(imageView);
|
|
Glide.with(TUILogin.getAppContext()).clear(imageView);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static void loadImage(ImageView imageView, String filePath, RequestListener listener) {
|
|
|
|
|
- Glide.with(TUILogin.getAppContext())
|
|
|
|
|
- .load(filePath)
|
|
|
|
|
- .listener(listener)
|
|
|
|
|
- .apply(new RequestOptions().error(TUIThemeManager.getAttrResId(TUILogin.getAppContext(), R.attr.core_default_user_icon)))
|
|
|
|
|
- .into(imageView);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public static void loadImage(ImageView imageView, String filePath) {
|
|
public static void loadImage(ImageView imageView, String filePath) {
|
|
|
Glide.with(TUILogin.getAppContext())
|
|
Glide.with(TUILogin.getAppContext())
|
|
|
.load(filePath)
|
|
.load(filePath)
|
|
@@ -48,32 +42,6 @@ public class GlideEngine {
|
|
|
.into(imageView);
|
|
.into(imageView);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static void loadImage(ImageView imageView, Uri uri) {
|
|
|
|
|
- if (uri == null) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- Glide.with(TUILogin.getAppContext())
|
|
|
|
|
- .load(uri)
|
|
|
|
|
- .apply(new RequestOptions().error(TUIThemeManager.getAttrResId(TUILogin.getAppContext(), R.attr.core_default_user_icon)))
|
|
|
|
|
- .into(imageView);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static void loadImage(String filePath, String url) {
|
|
|
|
|
- try {
|
|
|
|
|
- File file = Glide.with(TUILogin.getAppContext()).asFile().load(url).submit().get();
|
|
|
|
|
- File destFile = new File(filePath);
|
|
|
|
|
- file.renameTo(destFile);
|
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- } catch (ExecutionException e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
|
|
|
|
|
- Glide.with(context).load(uri).apply(new RequestOptions().override(resizeX, resizeY).priority(Priority.HIGH).fitCenter()).into(imageView);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public static void loadImage(ImageView imageView, Object uri) {
|
|
public static void loadImage(ImageView imageView, Object uri) {
|
|
|
if (uri == null) {
|
|
if (uri == null) {
|
|
|
return;
|
|
return;
|
|
@@ -96,10 +64,6 @@ public class GlideEngine {
|
|
|
.into(imageView);
|
|
.into(imageView);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static void loadUserIcon(ImageView imageView, Object uri, int defaultResId, int radius) {
|
|
|
|
|
- Glide.with(TUILogin.getAppContext()).load(uri).placeholder(defaultResId).apply(new RequestOptions().centerCrop().error(defaultResId)).into(imageView);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
public static Bitmap loadBitmap(Object imageUrl, int targetImageSize) throws InterruptedException, ExecutionException {
|
|
public static Bitmap loadBitmap(Object imageUrl, int targetImageSize) throws InterruptedException, ExecutionException {
|
|
|
if (imageUrl == null) {
|
|
if (imageUrl == null) {
|
|
|
return null;
|
|
return null;
|
|
@@ -111,20 +75,4 @@ public class GlideEngine {
|
|
|
.into(targetImageSize, targetImageSize)
|
|
.into(targetImageSize, targetImageSize)
|
|
|
.get();
|
|
.get();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public static Bitmap loadBitmap(Object imageUrl, int width, int height) throws InterruptedException, ExecutionException {
|
|
|
|
|
- if (imageUrl == null) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
- return Glide.with(TUILogin.getAppContext())
|
|
|
|
|
- .asBitmap()
|
|
|
|
|
- .load(imageUrl)
|
|
|
|
|
- .apply(new RequestOptions().error(TUIThemeManager.getAttrResId(TUILogin.getAppContext(), R.attr.core_default_user_icon)))
|
|
|
|
|
- .into(width, height)
|
|
|
|
|
- .get();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public static void loadImageSetDefault(ImageView imageView, Object uri, int defaultResId) {
|
|
|
|
|
- Glide.with(TUILogin.getAppContext()).load(uri).placeholder(defaultResId).apply(new RequestOptions().centerCrop().error(defaultResId)).into(imageView);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|