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) {
|
if (!xmppConnectionServiceBound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Jid accountJid;
|
final Account account = getSelectedAccount(spinner);
|
||||||
try {
|
if (account == null) {
|
||||||
if (Config.DOMAIN_LOCK != null) {
|
dialog.dismiss();
|
||||||
accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
|
|
||||||
} else {
|
|
||||||
accountJid = Jid.fromString((String) spinner.getSelectedItem());
|
|
||||||
}
|
|
||||||
} catch (final InvalidJidException e) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Jid conferenceJid;
|
final Jid conferenceJid;
|
||||||
|
@ -426,12 +421,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
jid.setError(getString(R.string.invalid_jid));
|
jid.setError(getString(R.string.invalid_jid));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Account account = xmppConnectionService
|
|
||||||
.findAccountByJid(accountJid);
|
|
||||||
if (account == null) {
|
|
||||||
dialog.dismiss();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (bookmarkCheckBox.isChecked()) {
|
if (bookmarkCheckBox.isChecked()) {
|
||||||
if (account.hasBookmarkFor(conferenceJid)) {
|
if (account.hasBookmarkFor(conferenceJid)) {
|
||||||
jid.setError(getString(R.string.bookmark_already_exists));
|
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) {
|
protected void switchToConversation(Contact contact) {
|
||||||
Conversation conversation = xmppConnectionService
|
Conversation conversation = xmppConnectionService
|
||||||
.findOrCreateConversation(contact.getAccount(),
|
.findOrCreateConversation(contact.getAccount(),
|
||||||
|
|
Loading…
Reference in a new issue