String thumbnailUrl = PlatformTorrentUtils.getContentThumbnailUrl(torrent);
//System.out.println("thumburl= " + thumbnailUrl);
if (thumbnailUrl != null && imageLoaderThumb.imageExists(thumbnailUrl)) {
//System.out.println("return thumburl");
Image image = imageLoaderThumb.getImage(thumbnailUrl);
l.contentImageLoaded(image, true);
return new Image[] { image };
}
String hash = null;
try {
hash = torrent.getHashWrapper().toBase32String();
} catch (TOTorrentException e) {
}
if (hash == null) {
l.contentImageLoaded(null, true);
return null;
}
final String id = "Thumbnail." + hash;
Image image = imageLoaderThumb.imageAdded(id) ? imageLoaderThumb.getImage(id) : null;
//System.out.println("image = " + image);
if (image != null && !image.isDisposed()) {
l.contentImageLoaded(image, true);
return new Image[] { image };
}
final byte[] imageBytes = PlatformTorrentUtils.getContentThumbnail(torrent);
//System.out.println("imageBytes = " + imageBytes);
if (imageBytes != null) {
image = (Image) Utils.execSWTThreadWithObject("thumbcreator",
new AERunnableObject() {
public Object runSupport() {
ByteArrayInputStream bis = new ByteArrayInputStream(imageBytes);
Image image = new Image(Display.getDefault(), bis);
return image;
}
}, 500);
}
/**
if ((image == null || image.isDisposed()) && thumbnailUrl != null) {
//System.out.println("get image from " + thumbnailUrl);
image = imageLoader.getUrlImage(thumbnailUrl,
new ImageDownloaderListener() {
public void imageDownloaded(Image image, boolean returnedImmediately) {
l.contentImageLoaded(image, returnedImmediately);
//System.out.println("got image from thumburl");
}
});
//System.out.println("returning " + image + " (url loading)");
return image == null ? null : new Image[] { image };
}
**/
if (image == null || image.isDisposed()) {
//System.out.println("build image from files");
DownloadManager dm = DataSourceUtils.getDM(datasource);
/*
* Try to get an image from the OS
*/