use of com.codename1.ui.list.GenericListCellRenderer in project CodenameOne by codenameone.
the class SMSShare method createListRenderer.
private ListCellRenderer createListRenderer() {
MultiButton sel = createRendererMultiButton();
MultiButton unsel = createRendererMultiButton();
return new GenericListCellRenderer(sel, unsel);
}
use of com.codename1.ui.list.GenericListCellRenderer in project CodenameOne by codenameone.
the class ImageDownloadService method createImageToStorage.
/**
* Constructs an image request that will automatically populate the given list
* when the response arrives, it will cache the file locally as a file
* in the file storage.
* This assumes the GenericListCellRenderer style of
* list which relies on a map based model approach.
*
* @param url the image URL
* @param targetList the list that should be updated when the data arrives
* @param targetModel the model
* @param targetOffset the offset within the list to insert the image
* @param targetKey the key for the map in the target offset
* @param cacheId a unique identifier to be used to store the image into storage
* @param keep if set to true keeps the file in RAM once loaded
* @param scale the scale of the image to put in the List or null
*/
private static void createImageToStorage(final String url, final Component targetList, final ListModel targetModel, final int targetOffset, final String targetKey, final String cacheId, final boolean keep, final Dimension scale, final byte priority, final Image placeholderImage, final boolean maintainAspectRatio) {
if (Display.getInstance().isEdt()) {
Display.getInstance().scheduleBackgroundTask(new Runnable() {
public void run() {
createImageToStorage(url, targetList, targetModel, targetOffset, targetKey, cacheId, keep, scale, priority, placeholderImage, maintainAspectRatio);
}
});
return;
}
Image im = cacheImage(cacheId, keep, null, scale, placeholderImage, maintainAspectRatio);
ImageDownloadService i = new ImageDownloadService(url, targetList, targetOffset, targetKey);
i.targetModel = targetModel;
i.maintainAspectRatio = maintainAspectRatio;
if (im != null) {
i.setEntryInListModel(targetOffset, im);
targetList.repaint();
return;
}
// image not found on cache go and download from the url
i.cacheImages = true;
i.cacheId = cacheId;
i.keep = keep;
i.toScale = scale;
i.placeholder = placeholderImage;
i.setPriority(priority);
i.setFailSilently(true);
NetworkManager.getInstance().addToQueue(i);
}
Aggregations