aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/ui
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationMoreMessagesLoadedListener.java13
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationMoreMessagesLoadedListener.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationMoreMessagesLoadedListener.java
index 774e72ba..859a6069 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationMoreMessagesLoadedListener.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationMoreMessagesLoadedListener.java
@@ -29,16 +29,24 @@ public class ConversationMoreMessagesLoadedListener implements XmppConnectionSer
The current loading status
*/
private boolean loadingMessages = false;
+ /**
+ * Whether the user is loading only history messages or not.
+ * History messages are messages which are older than the oldest in the database.
+ */
+ private boolean loadHistory = true;
public ConversationMoreMessagesLoadedListener(SwipyRefreshLayout swipeLayout, List<Message> messageList, ConversationFragment fragment, ListView messagesView, MessageAdapter messageListAdapter) {
this.swipeLayout = swipeLayout;
this.messageList = messageList;
-
this.fragment = fragment;
this.messagesView = messagesView;
this.messageListAdapter = messageListAdapter;
}
+ public void setLoadHistory(boolean value) {
+ this.loadHistory = value;
+ }
+
public void setLoadingInProgress() {
this.loadingMessages = true;
}
@@ -62,6 +70,9 @@ public class ConversationMoreMessagesLoadedListener implements XmppConnectionSer
}
// No new messages are loaded
if (0 == c) {
+ if (this.loadHistory) {
+ conversation.setHasMessagesLeftOnServer(false);
+ }
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java
index c6e00bed..bd616691 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/listeners/ConversationSwipeRefreshListener.java
@@ -43,6 +43,7 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
timestamp = this.messageList.get(0).getTimeSent(); // works only because of the ordering (last msg = first msg in list)
}
ConversationActivity activity = (ConversationActivity) fragment.getActivity();
+ this.listener.setLoadHistory(true);
activity.xmppConnectionService.loadMoreMessages(activity.getSelectedConversation(), timestamp, this.listener);
} else if (SwipyRefreshLayoutDirection.BOTTOM == direction) {
Logging.d("mam", "loading missing messages from mam (last session establishing or last received message)");
@@ -53,6 +54,7 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
long startTimestamp = Math.min(lastSessionEstablished, lastReceivedMessage);
MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(activity.getSelectedConversation(), startTimestamp, System.currentTimeMillis());
if (query != null) {
+ this.listener.setLoadHistory(false);
query.setCallback(this.listener);
} else {
activity.runOnUiThread(new Runnable() {