use async message loading only when called from UI
This commit is contained in:
parent
0229a1605e
commit
0904ba42f8
|
@ -192,7 +192,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||
|
||||
public boolean execute(Account account) {
|
||||
if (jid != null) {
|
||||
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid, true);
|
||||
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, jid, true, false);
|
||||
if (!conversation.getMucOptions().online()) {
|
||||
conversation.getMucOptions().setPassword(password);
|
||||
mXmppConnectionService.databaseBackend.updateConversation(conversation);
|
||||
|
@ -415,7 +415,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||
}
|
||||
|
||||
if ((body != null || pgpEncrypted != null || axolotlEncrypted != null || oobUrl != null) && !isMucStatusMessage) {
|
||||
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query);
|
||||
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query, false);
|
||||
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
|
||||
|
||||
if (serverMsgId == null) {
|
||||
|
|
|
@ -253,7 +253,7 @@ public class PresenceParser extends AbstractParser implements
|
|||
} else {
|
||||
contact.setOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
|
||||
final Conversation conversation = mXmppConnectionService.findOrCreateConversation(
|
||||
account, contact.getJid().toBareJid(), false);
|
||||
account, contact.getJid().toBareJid(), false, false);
|
||||
final String statusMessage = packet.findChildContent("status");
|
||||
if (statusMessage != null
|
||||
&& !statusMessage.isEmpty()
|
||||
|
|
|
@ -1413,7 +1413,7 @@ public class XmppConnectionService extends Service {
|
|||
if (conversation != null) {
|
||||
conversation.setBookmark(bookmark);
|
||||
} else if (bookmark.autojoin() && bookmark.getJid() != null && autojoin) {
|
||||
conversation = findOrCreateConversation(account, bookmark.getJid(), true, true);
|
||||
conversation = findOrCreateConversation(account, bookmark.getJid(), true, true, false);
|
||||
conversation.setBookmark(bookmark);
|
||||
}
|
||||
}
|
||||
|
@ -1681,15 +1681,15 @@ public class XmppConnectionService extends Service {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Conversation findOrCreateConversation(Account account, Jid jid, boolean muc) {
|
||||
return this.findOrCreateConversation(account,jid,muc,false);
|
||||
public Conversation findOrCreateConversation(Account account, Jid jid, boolean muc, final boolean async) {
|
||||
return this.findOrCreateConversation(account,jid,muc,false, async);
|
||||
}
|
||||
|
||||
public Conversation findOrCreateConversation(final Account account, final Jid jid, final boolean muc, final boolean joinAfterCreate) {
|
||||
return this.findOrCreateConversation(account, jid, muc, joinAfterCreate, null);
|
||||
public Conversation findOrCreateConversation(final Account account, final Jid jid, final boolean muc, final boolean joinAfterCreate, final boolean async) {
|
||||
return this.findOrCreateConversation(account, jid, muc, joinAfterCreate, null, async);
|
||||
}
|
||||
|
||||
public Conversation findOrCreateConversation(final Account account, final Jid jid, final boolean muc, final boolean joinAfterCreate, final MessageArchiveService.Query query) {
|
||||
public Conversation findOrCreateConversation(final Account account, final Jid jid, final boolean muc, final boolean joinAfterCreate, final MessageArchiveService.Query query, final boolean async) {
|
||||
synchronized (this.conversations) {
|
||||
Conversation conversation = find(account, jid);
|
||||
if (conversation != null) {
|
||||
|
@ -1728,7 +1728,7 @@ public class XmppConnectionService extends Service {
|
|||
loadMessagesFromDb = false;
|
||||
}
|
||||
final Conversation c = conversation;
|
||||
mDatabaseExecutor.execute(new Runnable() {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (loadMessagesFromDb) {
|
||||
|
@ -1752,7 +1752,12 @@ public class XmppConnectionService extends Service {
|
|||
joinMuc(c);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
if (async) {
|
||||
mDatabaseExecutor.execute(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
this.conversations.add(conversation);
|
||||
updateConversationUi();
|
||||
return conversation;
|
||||
|
@ -2454,7 +2459,7 @@ public class XmppConnectionService extends Service {
|
|||
return false;
|
||||
}
|
||||
final Jid jid = Jid.fromParts(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null);
|
||||
final Conversation conversation = findOrCreateConversation(account, jid, true, false);
|
||||
final Conversation conversation = findOrCreateConversation(account, jid, true, false, true);
|
||||
joinMuc(conversation, new OnConferenceJoined() {
|
||||
@Override
|
||||
public void onConferenceJoined(final Conversation conversation) {
|
||||
|
|
|
@ -482,7 +482,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
|
||||
protected void startConversation(User user) {
|
||||
if (user.getRealJid() != null) {
|
||||
Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(),user.getRealJid().toBareJid(),false);
|
||||
Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(),user.getRealJid().toBareJid(),false,true);
|
||||
switchToConversation(conversation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
|
|||
|
||||
try {
|
||||
conversation = xmppConnectionService
|
||||
.findOrCreateConversation(account, Jid.fromString(share.contact), false);
|
||||
.findOrCreateConversation(account, Jid.fromString(share.contact), false,true);
|
||||
} catch (final InvalidJidException e) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
protected void openConversationForContact(Contact contact) {
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(contact.getAccount(),
|
||||
contact.getJid(), false);
|
||||
contact.getJid(), false, true);
|
||||
switchToConversation(conversation);
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
Toast.makeText(this, R.string.invalid_jid, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
Conversation conversation = xmppConnectionService.findOrCreateConversation(bookmark.getAccount(), jid, true, true);
|
||||
Conversation conversation = xmppConnectionService.findOrCreateConversation(bookmark.getAccount(), jid, true, true, true);
|
||||
conversation.setBookmark(bookmark);
|
||||
if (!bookmark.autojoin() && getPreferences().getBoolean("autojoin", true)) {
|
||||
bookmark.setAutojoin(true);
|
||||
|
@ -513,7 +513,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
account.getBookmarks().add(bookmark);
|
||||
xmppConnectionService.pushBookmarks(account);
|
||||
final Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(account, conferenceJid, true, true);
|
||||
.findOrCreateConversation(account, conferenceJid, true, true, true);
|
||||
conversation.setBookmark(bookmark);
|
||||
dialog.dismiss();
|
||||
mCurrentDialog = null;
|
||||
|
@ -521,7 +521,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
}
|
||||
} else {
|
||||
final Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(account,conferenceJid, true, true);
|
||||
.findOrCreateConversation(account,conferenceJid, true, true, true);
|
||||
dialog.dismiss();
|
||||
mCurrentDialog = null;
|
||||
switchToConversation(conversation);
|
||||
|
@ -582,7 +582,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
|||
protected void switchToConversation(Contact contact, String body) {
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(contact.getAccount(),
|
||||
contact.getJid(),false);
|
||||
contact.getJid(),false,true);
|
||||
switchToConversation(conversation, body, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class ExceptionHelper {
|
|||
Conversation conversation = null;
|
||||
try {
|
||||
conversation = service.findOrCreateConversation(finalAccount,
|
||||
Jid.fromString(Config.BUG_REPORTS), false);
|
||||
Jid.fromString(Config.BUG_REPORTS), false, true);
|
||||
} catch (final InvalidJidException ignored) {
|
||||
}
|
||||
Message message = new Message(conversation, report
|
||||
|
|
|
@ -313,7 +313,7 @@ public class JingleConnection implements Transferable {
|
|||
this.mJingleStatus = JINGLE_STATUS_INITIATED;
|
||||
Conversation conversation = this.mXmppConnectionService
|
||||
.findOrCreateConversation(account,
|
||||
packet.getFrom().toBareJid(), false);
|
||||
packet.getFrom().toBareJid(), false, false);
|
||||
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
||||
this.message.setStatus(Message.STATUS_RECEIVED);
|
||||
this.mStatus = Transferable.STATUS_OFFER;
|
||||
|
|
Loading…
Reference in a new issue