inject ui callback into running mam query

This commit is contained in:
iNPUTmice 2014-12-20 12:52:08 +01:00
parent 675bac7255
commit 88f43643bf
3 changed files with 6 additions and 4 deletions

View file

@ -151,10 +151,13 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
} }
} }
public boolean queryInProgress(Conversation conversation) { public boolean queryInProgress(Conversation conversation, XmppConnectionService.OnMoreMessagesLoaded callback) {
synchronized (this.queries) { synchronized (this.queries) {
for(Query query : queries) { for(Query query : queries) {
if (query.conversation == conversation) { if (query.conversation == conversation) {
if (!query.hasCallback() && callback != null) {
query.setCallback(callback);
}
return true; return true;
} }
} }

View file

@ -963,7 +963,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void loadMoreMessages(final Conversation conversation, final long timestamp, final OnMoreMessagesLoaded callback) { public void loadMoreMessages(final Conversation conversation, final long timestamp, final OnMoreMessagesLoaded callback) {
Log.d(Config.LOGTAG,"load more messages for "+conversation.getName() + " prior to "+MessageGenerator.getTimestamp(timestamp)); Log.d(Config.LOGTAG,"load more messages for "+conversation.getName() + " prior to "+MessageGenerator.getTimestamp(timestamp));
if (XmppConnectionService.this.getMessageArchiveService().queryInProgress(conversation)) { if (XmppConnectionService.this.getMessageArchiveService().queryInProgress(conversation,callback)) {
return; return;
} }
new Thread(new Runnable() { new Thread(new Runnable() {

View file

@ -769,8 +769,7 @@ public class ConversationFragment extends Fragment {
return; return;
} else { } else {
if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) { if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) {
this.messageList.add(i + 1, this.messageList.add(i + 1,Message.createStatusMessage(conversation));
Message.createStatusMessage(conversation));
return; return;
} }
} }