Skip to content

Instantly share code, notes, and snippets.

@jsaund
Created September 7, 2016 05:06
Show Gist options
  • Save jsaund/6fb06bd980ec700cbf0f45c04e9b2f1d to your computer and use it in GitHub Desktop.
Save jsaund/6fb06bd980ec700cbf0f45c04e9b2f1d to your computer and use it in GitHub Desktop.
public class ImageFetcherActivity extends AppCompactActivity {
class WorkerThread extends Thread {
void fetchImage(String url) {
// network logic to create and execute request
handler.post(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(image);
}
});
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
// prepare the view, maybe setContentView, etc
new WorkerThread().fetchImage(imageUrl);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment