(final String toShare)
| 66 | |
| 67 | /// {@inheritDoc} |
| 68 | @Override |
| 69 | public void share(final String toShare) { |
| 70 | final Form currentForm = Display.getInstance().getCurrent(); |
| 71 | final Form contactsForm = new Form("Contacts"); |
| 72 | contactsForm.setScrollable(false); |
| 73 | contactsForm.setLayout(new BorderLayout()); |
| 74 | contactsForm.addComponent(BorderLayout.CENTER, new Label("Please wait...")); |
| 75 | contactsForm.show(); |
| 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") { |
nothing calls this directly
no test coverage detected