2017-08-17 32 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()的任何線索 –

相關問題