@Override
public Drawable getDrawable(String source) {
Logger.d("URLImageParser", "source:" + source);
final LevelListDrawable mDrawable = new LevelListDrawable();
Drawable empty = new BitmapDrawable();
mDrawable.addLevel(0, 0, empty);
mDrawable.setBounds(0, 0, empty.getIntrinsicWidth(), empty.getIntrinsicHeight());
// get the actual source
ImageLoader.loadBitmapFromUrl(context, source, cookie, referer, new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(Bitmap bitmap) {
if (bitmap != null) {
Bitmap copy = bitmap.copy(Bitmap.Config.ARGB_8888, true);
Drawable drawable = new BitmapDrawable(context.getResources(), copy);
mDrawable.addLevel(1, 1, drawable);
mDrawable.setBounds(0, 0, copy.getWidth(), copy.getHeight());
mDrawable.setLevel(1);
new Handler(context.getMainLooper()).post(new Runnable() {
@Override
public void run() {
CharSequence t = textView.getText();
textView.setText(t);
}
});
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
}
});
// return reference to URLDrawable where I will change with actual image from
// the src tag
return mDrawable;
}
URLImageParser.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:H-Viewer
作者:
评论列表
文章目录