Created
September 23, 2009 20:52
-
-
Save konklone/192269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Handler handler = new Handler(); | |
final Runnable updateThread = new Runnable() { | |
public void run() { | |
ImageView picture = (ImageView) LegislatorProfile.this.findViewById(R.id.picture); | |
picture.setImageDrawable(avatar); | |
} | |
}; | |
public void loadImage() { | |
Thread loadingThread = new Thread() { | |
public void run() { | |
String url = "http://govpix.appspot.com/" + Uri.encode(picName); | |
InputStream stream = (InputStream) fetchObject(url); | |
if (stream != null) | |
avatar = Drawable.createFromStream(stream, "src"); | |
else | |
avatar = getResources().getDrawable(R.drawable.no_photo); | |
handler.post(updateThread); | |
} | |
}; | |
loadingThread.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment