I'm using picasso library to load images for my app. But I don't how to implement my own disk (sdcard) caching with picasso library.
我正在构建一个聊天应用程序,我试图将图像附加到EditText,通过使用Picasso从URL获取图像和附加和ImageGetter将图像附加到EditText.但是,我在下面实现的内容不起作用,因为在使用应用程序时附加消息不显示任何内容(但消息确实显示在数据库中).
我已经在不使用Picasso的情况下进行了测试,因为只需在应用程序中使用带有图像资源的ImageGetter就可以正常工作,只有它不是来自URL所需.
配置ImageGetter和/或append方法的正确方法是什么,以便此功能可以与Picasso一起使用?或者有更简单的方法吗?
追加方法:
public void appendToMessageHistory(final String username,
final String message) {
if (username != null && message != null) {
Picasso.with(getBaseContext())
.load("http://localhost:3000/uploads/campaign/image/2/2.jpg")
.into(new Target() {
@Override
public void onPrepareLoad(Drawable arg0) {
}
@Override
public void onBitmapLoaded(Bitmap bitmap,
LoadedFrom arg1) {
Drawable drawImage = new BitmapDrawable(
getBaseContext().getResources(), bitmap);
drawImage.setBounds(0, 0,
drawImage.getIntrinsicHeight(),
drawImage.getIntrinsicWidth());
messageHistoryText.append(Html.fromHtml("<b>"
+ username + ":" + "</b>" + "<br>"));
messageHistoryText.append(Html.fromHtml(message
+ "<hr>" + "<br>")
+ System.getProperty("line.separator") + "");
messageHistoryText.append(Html
.fromHtml("<img src = '" + drawImage
+ "'/>", …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用Picasso将图像从URL加载到图像视图中.我想执行一个操作,但只有在图像到达时才执行,而不是在加载占位符可见时.
我该如何实现这一目标?
谢谢!