add convenience to get an account object from a spinner
This commit is contained in:
parent
62a88a4db8
commit
eacc7ed1e6
|
@ -409,14 +409,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
if (!xmppConnectionServiceBound) {
|
||||
return;
|
||||
}
|
||||
final Jid accountJid;
|
||||
try {
|
||||
if (Config.DOMAIN_LOCK != null) {
|
||||
accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
|
||||
} else {
|
||||
accountJid = Jid.fromString((String) spinner.getSelectedItem());
|
||||
}
|
||||
} catch (final InvalidJidException e) {
|
||||
final Account account = getSelectedAccount(spinner);
|
||||
if (account == null) {
|
||||
dialog.dismiss();
|
||||
return;
|
||||
}
|
||||
final Jid conferenceJid;
|
||||
|
@ -426,12 +421,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
jid.setError(getString(R.string.invalid_jid));
|
||||
return;
|
||||
}
|
||||
final Account account = xmppConnectionService
|
||||
.findAccountByJid(accountJid);
|
||||
if (account == null) {
|
||||
dialog.dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
if (bookmarkCheckBox.isChecked()) {
|
||||
if (account.hasBookmarkFor(conferenceJid)) {
|
||||
jid.setError(getString(R.string.bookmark_already_exists));
|
||||
|
@ -468,6 +458,20 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
});
|
||||
}
|
||||
|
||||
private Account getSelectedAccount(Spinner spinner) {
|
||||
Jid jid;
|
||||
try {
|
||||
if (Config.DOMAIN_LOCK != null) {
|
||||
jid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
|
||||
} else {
|
||||
jid = Jid.fromString((String) spinner.getSelectedItem());
|
||||
}
|
||||
} catch (final InvalidJidException e) {
|
||||
return null;
|
||||
}
|
||||
return xmppConnectionService.findAccountByJid(jid);
|
||||
}
|
||||
|
||||
protected void switchToConversation(Contact contact) {
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(contact.getAccount(),
|
||||
|
|
Loading…
Reference in a new issue