use of com.biglybt.ui.swt.imageloader.ImageLoader.ImageDownloaderListener in project BiglyBT by BiglySoftware.
the class SBC_SearchResultsView method getIconSupport.
private Image getIconSupport(Engine engine, ImageLoadListener result) {
String icon = engine.getIcon();
Image img = null;
if (icon != null) {
Object[] x = image_map.get(icon);
if (x == null) {
Set<ImageLoadListener> waiters = new HashSet<>();
final Object[] f_x = new Object[] { null, waiters, SystemTime.getMonotonousTime() };
waiters.add(result);
image_map.put(icon, f_x);
image_loader.getUrlImage(icon, new Point(0, Utils.adjustPXForDPI(16)), new ImageDownloaderListener() {
@Override
public void imageDownloaded(Image image, boolean returnedImmediately) {
f_x[0] = image;
Set<ImageLoadListener> set = (Set<ImageLoadListener>) f_x[1];
for (ImageLoadListener result : set) {
result.imageLoaded(image);
}
f_x[1] = null;
}
});
// in case synchronously set
img = (Image) f_x[0];
} else {
if (x[1] instanceof Set) {
((Set<ImageLoadListener>) x[1]).add(result);
} else {
img = (Image) x[0];
if (img == null) {
if (SystemTime.getMonotonousTime() - (Long) x[2] > 120 * 1000) {
image_map.remove(icon);
}
}
}
}
}
return (img);
}
use of com.biglybt.ui.swt.imageloader.ImageLoader.ImageDownloaderListener in project BiglyBT by BiglySoftware.
the class ColumnActivityType method cellPaint.
// @see com.biglybt.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, com.biglybt.pif.ui.tables.TableCell)
@Override
public void cellPaint(GC gc, final TableCellSWT cell) {
ActivitiesEntry entry = (ActivitiesEntry) cell.getDataSource();
Image imgIcon;
String iconID = entry.getIconID();
if (iconID != null) {
ImageLoader imageLoader = ImageLoader.getInstance();
if (iconID.startsWith("http")) {
imgIcon = imageLoader.getUrlImage(iconID, new ImageDownloaderListener() {
@Override
public void imageDownloaded(Image image, String key, boolean returnedImmediately) {
if (returnedImmediately) {
return;
}
cell.invalidate();
}
});
if (imgIcon == null) {
return;
}
} else {
imgIcon = imageLoader.getImage(iconID);
}
if (ImageLoader.isRealImage(imgIcon)) {
Rectangle cellBounds = cell.getBounds();
Rectangle imgBounds = imgIcon.getBounds();
gc.drawImage(imgIcon, cellBounds.x + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y + ((cellBounds.height - imgBounds.height) / 2));
}
imageLoader.releaseImage(iconID);
}
}
Aggregations