This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch(Display.getInstance().getSMSSupport()) { | |
case Display.SMS_NOT_SUPPORTED: | |
return; | |
case Display.SMS_SEAMLESS: | |
showUIDialogToEditMessageData(); | |
Display.getInstance().sendSMS(phone, data); | |
return; | |
default: | |
Display.getInstance().sendSMS(phone, data); | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Message m = new Message("Body of message"); | |
m.getAttachments().put(textAttachmentUri, "text/plain"); | |
m.getAttachments().put(imageAttachmentUri, "image/png"); | |
Display.getInstance().sendMessage(new String[] {"[email protected]"}, "Subject of message", m); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Message m = new Message("<html><body>Check out <a href=\"https://www.codenameone.com/\">Codename One</a></body></html>"); | |
m.setMimeType(Message.MIME_HTML); | |
// notice that we provide a plain text alternative as well in the send method | |
boolean success = m.sendMessageViaCloudSync("Codename One", "[email protected]", "Name Of User", "Message Subject", | |
"Check out Codename One at https://www.codenameone.com/"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("Contacts", new BoxLayout(BoxLayout.Y_AXIS)); | |
hi.add(new InfiniteProgress()); | |
int size = Display.getInstance().convertToPixels(5, true); | |
FontImage fi = FontImage.createFixed("" + FontImage.MATERIAL_PERSON, FontImage.getMaterialDesignFont(), 0xff, size, size); | |
Display.getInstance().scheduleBackgroundTask(() -> { | |
Contact[] contacts = Display.getInstance().getAllContacts(true, true, false, true, false, false); | |
Display.getInstance().callSerially(() -> { | |
hi.removeAll(); | |
for(Contact c : contacts) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("L10N", new TableLayout(16, 2)); | |
L10NManager l10n = L10NManager.getInstance(); | |
hi.add("format(double)").add(l10n.format(11.11)). | |
add("format(int)").add(l10n.format(33)). | |
add("formatCurrency").add(l10n.formatCurrency(53.267)). | |
add("formatDateLongStyle").add(l10n.formatDateLongStyle(new Date())). | |
add("formatDateShortStyle").add(l10n.formatDateShortStyle(new Date())). | |
add("formatDateTime").add(l10n.formatDateTime(new Date())). | |
add("formatDateTimeMedium").add(l10n.formatDateTimeMedium(new Date())). | |
add("formatDateTimeShort").add(l10n.formatDateTimeShort(new Date())). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("Download Progress", new BorderLayout()); | |
Slider progress = new Slider(); | |
Button download = new Button("Download"); | |
download.addActionListener((e) -> { | |
ConnectionRequest cr = new ConnectionRequest("https://www.codenameone.com/img/blog/new_icon.png", false); | |
SliderBridge.bindProgress(cr, progress); | |
NetworkManager.getInstance().addToQueueAndWait(cr); | |
if(cr.getResponseCode() == 200) { | |
hi.add(BorderLayout.CENTER, new ScaleImageLabel(EncodedImage.create(cr.getResponseData()))); | |
hi.revalidate(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XMLParser parser = new XMLParser(); | |
Element elem = parser.parse(reader); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Form hi = new Form("JSON Parsing", new BoxLayout(BoxLayout.Y_AXIS)); | |
JSONParser json = new JSONParser(); | |
try(Reader r = new InputStreamReader(Display.getInstance().getResourceAsStream(getClass(), "/anapioficeandfire.json"), "UTF-8")) { | |
Map<String, Object> data = json.parseJSON(r); | |
java.util.List<Map<String, Object>> content = (java.util.List<Map<String, Object>>)data.get("root"); // <1> | |
for(Map<String, Object> obj : content) { // <2> | |
String url = (String)obj.get("url"); | |
String name = (String)obj.get("name"); | |
java.util.List<String> titles = (java.util.List<String>)obj.get("titles"); // <3> | |
if(name == null || name.length() == 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"url": "http://www.anapioficeandfire.com/api/characters/13", | |
"name": "Chayle", | |
"culture": "", | |
"born": "", | |
"died": "In 299 AC, at Winterfell", | |
"titles": [ | |
"Septon" | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JSONParser parser = new JSONParser(); | |
Hashtable response = parser.parse(reader); |