我在电影安卓应用程序上工作,它从一个提供所有电影的海报路径的API获得电影列表。
我想从图像的URL中将图像作为Bitmap
获取,以便将其保存为模型类中的Bitmap
变量。我想在DB中将图像保存为blob,以便直接检索它,而不必每次用户打开应用程序时重新下载它。这有可能吗?
我想做这样的事情,但它总是返回null。
private Bitmap posterBitmap;
public void setPosterBitmap () {
Picasso.get().load(POSTERS_URL).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
posterBitmap = bitmap; // I don't want to set it to an Image view here
}
@Override
public void onBitmapFailed(Exception e, Drawable errorDrawable) {}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {}
});
}
提前谢谢。
发布于 2019-11-18 18:28:22
new Thread(() -> {
try {
Bitmap mBitmap = Picasso.get().load(link).get();
} catch (Exception e) {
Log.e(""+e);
}
}).start();
通过使用实现'com.squareup.picasso:picasso:2.71828‘
https://stackoverflow.com/questions/51450984
复制相似问题