use of com.codename1.ui.List in project CodenameOne by codenameone.
the class ImageDownloadService method postResponse.
/**
* {@inheritDoc}
*/
protected void postResponse() {
// trigger an exception in case of an invalid image
result.getWidth();
Image image = result;
if (toScale != null && toScale.getWidth() != image.getWidth() && toScale.getHeight() != image.getHeight()) {
image = scaleImage(image, toScale, maintainAspectRatio);
}
final Image i = image;
if (parentLabel != null) {
final Dimension pref = parentLabel.getPreferredSize();
if (parentLabel.getComponentForm() != null) {
Display.getInstance().callSerially(new Runnable() {
public void run() {
if (isDownloadToStyles()) {
parentLabel.getUnselectedStyle().setBgImage(i);
parentLabel.getSelectedStyle().setBgImage(i);
parentLabel.getPressedStyle().setBgImage(i);
} else {
parentLabel.setIcon(i);
}
Dimension newPref = parentLabel.getPreferredSize();
// sized image in place or has a hardcoded preferred size.
if (pref.getWidth() != newPref.getWidth() || pref.getHeight() != newPref.getHeight()) {
parentLabel.getComponentForm().revalidate();
}
}
});
} else {
Display.getInstance().callSerially(new Runnable() {
public void run() {
if (isDownloadToStyles()) {
parentLabel.getUnselectedStyle().setBgImage(i);
parentLabel.getSelectedStyle().setBgImage(i);
parentLabel.getPressedStyle().setBgImage(i);
} else {
parentLabel.setIcon(i);
}
}
});
}
parentLabel.repaint();
return;
} else {
if (targetList != null) {
setEntryInListModel(targetOffset, image);
// revalidate only once to avoid multiple revalidate refreshes during scroll
if (targetList.getParent() != null) {
if (alwaysRevalidate) {
targetList.getParent().revalidate();
} else {
if (targetList.getClientProperty("$imgDSReval") == null) {
targetList.putClientProperty("$imgDSReval", Boolean.TRUE);
targetList.getParent().revalidate();
} else {
targetList.repaint();
}
}
}
}
}
// if this is a list cell renderer component
fireResponseListener(new NetworkEvent(this, result));
}
use of com.codename1.ui.List in project CodenameOne by codenameone.
the class FaceBookAccess method getFaceBookObjectItems.
/**
* Get a list of FaceBook objects for a given id
*
* @param faceBookId the id to preform the query upon
* @param itemsConnection the type of the query
* @param feed
* @param params
* @param callback the callback that should be updated when the data arrives
*/
public void getFaceBookObjectItems(String faceBookId, String itemsConnection, final DefaultListModel feed, Hashtable params, final ActionListener callback) throws IOException {
checkAuthentication();
final FacebookRESTService con = new FacebookRESTService(token, faceBookId, itemsConnection, false);
con.setResponseDestination(feed);
con.addResponseListener(new Listener(con, callback));
if (params != null) {
Enumeration keys = params.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
con.addArgument(key, (String) params.get(key));
}
}
if (slider != null) {
SliderBridge.bindProgress(con, slider);
}
for (int i = 0; i < responseCodeListeners.size(); i++) {
con.addResponseCodeListener((ActionListener) responseCodeListeners.elementAt(i));
}
current = con;
NetworkManager.getInstance().addToQueue(con);
}
use of com.codename1.ui.List in project CodenameOne by codenameone.
the class BlackBerryImplementation method sendMessage.
public void sendMessage(String[] recipients, String subject, Message msg) {
Folder[] folders = Session.getDefaultInstance().getStore().list(Folder.SENT);
net.rim.blackberry.api.mail.Message message = new net.rim.blackberry.api.mail.Message(folders[0]);
try {
Address[] toAdds = new Address[recipients.length];
for (int i = 0; i < recipients.length; i++) {
Address address = new Address(recipients[i], "");
toAdds[i] = address;
}
message.addRecipients(net.rim.blackberry.api.mail.Message.RecipientType.TO, toAdds);
message.setSubject(subject);
} catch (Exception e) {
EventLog.getInstance().logErrorEvent("err " + e.getMessage());
}
try {
if (msg.getAttachment() != null && msg.getAttachment().length() > 0) {
Multipart content = new Multipart();
TextBodyPart tbp = new TextBodyPart(content, msg.getContent());
content.addBodyPart(tbp);
InputStream stream = com.codename1.io.FileSystemStorage.getInstance().openInputStream(msg.getAttachment());
byte[] buf;
buf = IOUtilities.streamToBytes(stream);
stream.close();
String name = msg.getAttachment();
name = name.substring(name.lastIndexOf(getFileSystemSeparator()) + 1, name.length());
SupportedAttachmentPart sap = new SupportedAttachmentPart(content, msg.getAttachmentMimeType(), name, buf);
content.addBodyPart(sap);
message.setContent(content);
} else {
message.setContent(msg.getContent());
}
app.setWaitingForReply(true);
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(message));
} catch (Exception ex) {
EventLog.getInstance().logErrorEvent("err " + ex.getMessage());
}
}
use of com.codename1.ui.List in project CodenameOne by codenameone.
the class GoogleImpl method onConnected.
public void onConnected(Bundle bundle) {
List<SuccessCallback<GoogleApiClient>> callbacks;
synchronized (onConnectedCallbacks) {
if (!onConnectedCallbacks.isEmpty()) {
callbacks = new ArrayList<SuccessCallback<GoogleApiClient>>(onConnectedCallbacks);
onConnectedCallbacks.clear();
} else {
callbacks = new ArrayList<SuccessCallback<GoogleApiClient>>();
}
}
GoogleApiClient client = mGoogleApiClient;
for (SuccessCallback<GoogleApiClient> cb : callbacks) {
cb.onSucess(client);
}
}
use of com.codename1.ui.List in project CodenameOne by codenameone.
the class RangeBarChart method drawChartValuesText.
/**
* The graphical representation of the series values as text.
*
* @param canvas the canvas to paint to
* @param series the series to be painted
* @param renderer the series renderer
* @param paint the paint to be used for drawing
* @param points the array of points to be used for drawing the series
* @param seriesIndex the index of the series currently being drawn
* @param startIndex the start index of the rendering points
*/
protected void drawChartValuesText(Canvas canvas, XYSeries series, XYSeriesRenderer renderer, Paint paint, List<Float> points, int seriesIndex, int startIndex) {
int seriesNr = mDataset.getSeriesCount();
float halfDiffX = getHalfDiffX(points, points.size(), seriesNr);
int start = 0;
if (startIndex > 0) {
start = 2;
}
for (int i = start; i < points.size(); i += 4) {
int index = startIndex + i / 2;
float x = points.get(i);
if (mType == Type.DEFAULT) {
x += seriesIndex * 2 * halfDiffX - (seriesNr - 1.5f) * halfDiffX;
}
if (!isNullValue(series.getY(index + 1)) && points.size() > i + 3) {
// draw the maximum value
drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(index + 1)), x, points.get(i + 3) - renderer.getChartValuesSpacing(), paint, 0);
}
if (!isNullValue(series.getY(index)) && points.size() > i + 1) {
// draw the minimum value
drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(index)), x, points.get(i + 1) + renderer.getChartValuesTextSize() + renderer.getChartValuesSpacing() - 3, paint, 0);
}
}
}
Aggregations