public void commandAction(Command c, Displayable d) { if (c == cmdOk) { String jid = getString(tJid); if (jid != null) { String name = getString(tNick); String group = group(tGrpList.getSelectedIndex()); if (group == null) group = getString(tGroup); try { int gSel = tGrpList.getSelectedIndex(); if (gSel != tGrpList.size() - 1) { group = (gSel > 0) ? tGrpList.getString(gSel) : null; // nokia fix } } catch (Exception e) { } // nokia fix // сохранение контакта boolean ask[] = new boolean[1]; tAskSubscrCheckBox.getSelectedFlags(ask); roster.storeContact(jid, name, group, ask[0]); destroyView(); return; } } if (c == cmdCancel) destroyView(); }
private void updateChoise(String str, ChoiceGroup grp) { int sz = grp.size(); int set = sz - 1; for (int i = 0; i < sz; i++) { if (str.equals(grp.getString(i))) { set = i; break; } } if (grp.getSelectedIndex() != set) grp.setSelectedIndex(set, true); }
public void itemStateChanged(Item item) { if (item == tGrpList) { int index = tGrpList.getSelectedIndex(); if (index == tGrpList.size() - 1) { f.set(grpFIndex, tGroup); } // tGroup.setString(group(index)); } // if (item==tGroup) { // updateChoise(tGroup.getString(), tGrpList); // } if (item == tTranspList) { int index = tTranspList.getSelectedIndex(); if (index == tTranspList.size() - 1) return; String transport = tTranspList.getString(index); String jid = tJid.getString(); StringBuffer jidBuf = new StringBuffer(jid); int at = jid.indexOf('@'); if (at < 0) at = tJid.size(); jidBuf.setLength(at); jidBuf.append('@'); jidBuf.append(transport); tJid.setString(jidBuf.toString()); } if (item == tJid) { String s1 = tJid.getString(); int at = tJid.getString().indexOf('@'); try { updateChoise(s1.substring(at + 1), tTranspList); } catch (Exception e) { } } }
private String group(int index) { if (index == 0) return null; if (index == tGrpList.size() - 1) return null; return tGrpList.getString(index); }