I have HTML text, I need to show it in textview. I did it. There are
some images in it. I also made ImageGetter
which loads image from remote server and displays it. But the issue is
now its very slow.
I know i can load it async. But i haven't got a single example or help
for this.
Below is the code to get the image
@Override
public Drawable getDrawable(String source) {
Drawable drawable = null;
Bitmap bitmap = null;
InputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new
URL(source).openStream(),4096);
final ByteArrayOutputStream dataStream = new
ByteArrayOutputStream();
out = new BufferedOutputStream(dataStream, 4096);
copy(in, out);
out.flush();
final byte[] data = dataStream.toByteArray();
bitmap = BitmapFactory.decodeByteArray(data, 0,
data.length);
drawable = new BitmapDrawable(bitmap);
int width = getScreen();
int fin = width - 120;
drawable.setBounds(0, 0, fin, 200);
return drawable;
}catch (Throwable e) {
return null;
}
}
Can any one tell my how can get it async without stopping UI?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en