Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Created December 30, 2016 09:32
Show Gist options
  • Select an option

  • Save FreeFly19/3992b559d522474f4c8c71af477dd349 to your computer and use it in GitHub Desktop.

Select an option

Save FreeFly19/3992b559d522474f4c8c71af477dd349 to your computer and use it in GitHub Desktop.
class ImageDownloadTask implements Runnable {
private URL imageURL;
public void run() {
for(int i = 0; i < 3; i++) {
if(isImageDownloaded()) break; // return
}
}
private boolean isImageDownloaded() {
try {
downloadImage();
return true;
} catch(Exception e) {
return false;
}
}
private downloadImage() throws Exception {
// Your implementation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment