MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / run

Method run

CodenameOne/src/com/codename1/share/SMSShare.java:78–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76 Display.getInstance().startThread(new Runnable() {
77
78 @Override
79 public void run() {
80 String[] ids = ContactsManager.getAllContacts();
81 if (ids == null || ids.length == 0) {
82 Display.getInstance().callSerially(new Runnable() {
83 @Override
84 public void run() {
85 Dialog.show("Failed to Share", "No Contacts Found", "Ok", null);
86 currentForm.showBack();
87 }
88 });
89 return;
90 }
91 ContactsModel model = new ContactsModel(ids);
92 final List contacts = new List(model);
93 contacts.setRenderer(createListRenderer());
94 Display.getInstance().callSerially(new Runnable() {
95
96 @Override
97 public void run() {
98
99 contacts.addActionListener(new ActionListener() {
100
101 @Override
102 public void actionPerformed(ActionEvent evt) {
103 final ShareForm[] f = new ShareForm[1];
104 final Hashtable contact = (Hashtable) contacts.getSelectedItem();
105
106 f[0] = new ShareForm(contactsForm, "Send SMS", (String) contact.get("phone"), toShare,
107 new ActionListener() {
108
109 @Override
110 public void actionPerformed(ActionEvent evt) {
111 try {
112 Display.getInstance().sendSMS(f[0].getTo(), f[0].getMessage());
113 } catch (IOException ex) {
114 Log.e(ex);
115 System.out.println("failed to send sms to " + contact.get("phone"));
116 }
117 finish();
118 }
119 });
120 f[0].show();
121
122 }
123 });
124 contactsForm.addComponent(BorderLayout.CENTER, contacts);
125 Command back = new Command("Back") {
126
127 @Override
128 public void actionPerformed(ActionEvent evt) {
129 currentForm.showBack();
130 }
131
132 };
133 contactsForm.addCommand(back);
134 contactsForm.setBackCommand(back);
135 contactsForm.revalidate();

Callers

nothing calls this directly

Calls 12

getAllContactsMethod · 0.95
getInstanceMethod · 0.95
showMethod · 0.95
setRendererMethod · 0.95
createListRendererMethod · 0.95
callSeriallyMethod · 0.65
addActionListenerMethod · 0.65
addComponentMethod · 0.65
revalidateMethod · 0.65
showBackMethod · 0.45
addCommandMethod · 0.45
setBackCommandMethod · 0.45

Tested by

no test coverage detected