2017-08-17 35 views
3

当我加载图像像这样的东西:加载图像,同时服务器返回的base64

String url = "https://example.com/user/123123/profile_pic" Glide.with(context).load(url).into(imageView);

服务器响应为Base64和滑行默认不

我目前处理它解决方案:

load image with retrofit -> pass image encoded to glide

在这种情况下我会失去滑翔缓存

。我想知道是否有办法通过滑动来处理该请求并处理base64响应?

回答

1

您可以将Base64字符串转换为字节,然后将该字节加载到滑行。

byte[] imageByteArray = Base64.decode(imageBytes, Base64.DEFAULT); 
// here imageBytes is base64String 

Glide.with(context) 
    .load(imageByteArray) 
    .asBitmap() 
    .into(imageView); 
+1

但事情是我需要在其他地方提出请求,然后将它传递给Glide。然后没有缓存等我正在寻找Glide句柄base64响应 – Tomas

+0

无法解析asBitmap()的任何线索 –

相关问题