Skip to content

Instantly share code, notes, and snippets.

@jinqian
Last active December 19, 2015 11:29
Show Gist options
  • Select an option

  • Save jinqian/5948367 to your computer and use it in GitHub Desktop.

Select an option

Save jinqian/5948367 to your computer and use it in GitHub Desktop.
public void DisplayImage(final Namespace ns, String key, final ImageView imageView) {
Bitmap bitmap = getBitmap(ns, key);
if (bitmap != null) {
Log.d(TAG, "BITMAP ALREADY DOWNLOWDED");
imageView.setImageBitmap(bitmap);
}
else {
imageView.setImageResource(R.drawable.stub);
ns.load(key, new Namespace.LoadListener() {
@Override
public void onLoadStart(String namespace, String key) {
Log.d(TAG, "START LOADING IMAGE:" + key);
}
@Override
public void onLoadFailed(String namespace, String key, WinchError e) {
// TODO Auto-generated method stub
}
@Override
public void onLoadProgress(String namespace, String key,
float progress) {
imageView.setImageResource(ms.overlay.R.drawable.stub);
}
@Override
public void onLoadComplete(String namespace, String key) {
Log.d(TAG, "IMAGE LOADED: " + key);
//TODO provoke a update list to display list correctly....
byte[] blob = null;
try {
blob = ns.get(key);
} catch (WinchError e) {
e.printStackTrace();
}
Bitmap bmp = BitmapFactory
.decodeByteArray(blob, 0, blob.length);
imageView.setImageBitmap(bmp);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment