aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java66
1 files changed, 48 insertions, 18 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 398cf0e42..ab0c53078 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -65,6 +65,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -969,7 +970,16 @@ public abstract class XmppActivity extends ActionBarActivity {
Account mAccount = xmppConnectionService.getAccounts().get(0);
String user = Jid.ofEscaped(mAccount.getJid()).getLocal();
String domain = Jid.ofEscaped(mAccount.getJid()).getDomain();
- String inviteURL = AdHocInviteUri(mAccount);
+ String inviteURL;
+ try {
+ inviteURL = new getAdHocInviteUri(mAccount).execute().get();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ inviteURL = Config.inviteUserURL + user + "/" + domain;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ inviteURL = Config.inviteUserURL + user + "/" + domain;
+ }
if (inviteURL == null) {
inviteURL = Config.inviteUserURL + user + "/" + domain;
}
@@ -1004,7 +1014,16 @@ public abstract class XmppActivity extends ActionBarActivity {
Account mAccount = xmppConnectionService.findAccountByJid(Jid.of(selection).asBareJid());
String user = Jid.of(mAccount.getJid()).getLocal();
String domain = Jid.of(mAccount.getJid()).getDomain();
- String inviteURL = AdHocInviteUri(mAccount);
+ String inviteURL;
+ try {
+ inviteURL = new getAdHocInviteUri(mAccount).execute().get();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ inviteURL = Config.inviteUserURL + user + "/" + domain;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ inviteURL = Config.inviteUserURL + user + "/" + domain;
+ }
if (inviteURL == null) {
inviteURL = Config.inviteUserURL + user + "/" + domain;
}
@@ -1031,24 +1050,35 @@ public abstract class XmppActivity extends ActionBarActivity {
return features.adhocinvite;
}
- private String AdHocInviteUri(Account account) {
- if (AdHocInvite(account)) {
- int counter = 0;
- XmppConnection.Features features = account.getXmppConnection().getFeatures();
- account.getXmppConnection().getAdHocInviteUrl(Jid.ofDomain(account.getJid().getDomain()));
- while (features.adhocinviteURI == null && counter <= 10) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // Process exception
- }
- counter++;
+ private class getAdHocInviteUri extends AsyncTask<Account, Void, String> {
+
+ private Account account;
+
+ public getAdHocInviteUri(Account a) {
+ this.account = a;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ }
+
+ @Override
+ protected String doInBackground(Account... params) {
+ if (AdHocInvite(account)) {
+ XmppConnection.Features features = account.getXmppConnection().getFeatures();
+ account.getXmppConnection().getAdHocInviteUrl(Jid.ofDomain(account.getJid().getDomain()));
+ String uri = features.adhocinviteURI;
+ features.adhocinviteURI = null;
+ return uri;
}
- String uri = features.adhocinviteURI;
- features.adhocinviteURI = null;
- return uri;
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(String result) {
+ super.onPostExecute(result);
}
- return null;
}
private void createIssue() {