aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-22 00:58:52 +0100
committerlookshe <github@lookshe.org>2016-03-22 00:58:52 +0100
commit4085f2a80e00e24a73206389cb1e8f30385e9952 (patch)
tree2cb25205f26167d69b02b6efa6d500dbd4c34564
parentde3894f77c58579608fbe116c2dc5f36dcecbc8f (diff)
parent02f958ce7687eeff0eaae7da372bad4b65f78596 (diff)
Merge branch 'trz/rename' into trz/rebase
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java16
2 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index ad2c0b99..ce00fb0c 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1271,7 +1271,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
callback.onMoreMessagesLoaded(0, conversation);
}
} else {
- Logging.d("mam", ((!conversation.hasMessagesLeftOnServer()) ? "no" : "") + " more messages left on server, mam " + ((account.getXmppConnection().getFeatures().mam()) ? "" : "not") + " activated, account is " + ((account.isOnlineAndConnected()) ? "" : "not") + " online or connected)");
+ Logging.d("mam", ((!conversation.hasMessagesLeftOnServer()) ? "no" : "")
+ + " more messages left on server, mam "
+ + ((account.isOnlineAndConnected() && account.getXmppConnection().getFeatures().mam()) ? "" : "not")
+ + " activated, account is " + ((account.isOnlineAndConnected()) ? "" : "not")
+ + " online or connected)");
callback.onMoreMessagesLoaded(0, conversation);
callback.informUser(R.string.no_more_history_on_server);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java
index 5ef2eea7..0cbde814 100644
--- a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java
+++ b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java
@@ -10,6 +10,7 @@ import java.util.List;
import de.thedevstack.android.logcat.Logging;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.MessageArchiveService;
@@ -24,10 +25,12 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
private List<Message> messageList;
private ConversationFragment fragment;
private ConversationMoreMessagesLoadedListener listener;
+ private SwipyRefreshLayout swipeLayout;
public ConversationSwipeRefreshListener(List<Message> messageList, SwipyRefreshLayout swipeLayout, ConversationFragment fragment, ListView messagesView, MessageAdapter messageListAdapter) {
this.messageList = messageList;
this.fragment = fragment;
+ this.swipeLayout = swipeLayout;
this.listener = new ConversationMoreMessagesLoadedListener(swipeLayout, messageList, fragment, messagesView, messageListAdapter);
}
@@ -35,6 +38,8 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
public void onRefresh(SwipyRefreshLayoutDirection direction) {
Logging.d(Config.LOGTAG, "Refresh swipe container");
Logging.d(Config.LOGTAG, "Refresh direction " + direction);
+ final ConversationActivity activity = (ConversationActivity) fragment.getActivity();
+ if (activity.getSelectedConversation().getAccount().getStatus() != Account.State.DISABLED) {
synchronized (this.messageList) {
long timestamp;
if (SwipyRefreshLayoutDirection.TOP == direction) { // Load history -> messages sent/received before first message in database
@@ -43,12 +48,11 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
} else {
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) { // load messages sent/received between last received or last session establishment and now
+ if (activity.getSelectedConversation().getAccount().isOnlineAndConnected()) {
Logging.d("mam", "loading missing messages from mam (last session establishing or last received message)");
- final ConversationActivity activity = (ConversationActivity) fragment.getActivity();
long lastSessionEstablished = this.getTimestampOfLastSessionEstablished(activity.getSelectedConversation());
long lastReceivedMessage = this.getTimestampOfLastReceivedOrTransmittedMessage();
long startTimestamp = Math.min(lastSessionEstablished, lastReceivedMessage);
@@ -61,8 +65,16 @@ public class ConversationSwipeRefreshListener implements SwipyRefreshLayout.OnRe
this.listener.informUser(R.string.no_more_history_on_server);
}
this.listener.informUser(R.string.fetching_history_from_server);
+ } else {
+ this.listener.informUser(R.string.not_connected_try_again);
+ swipeLayout.setRefreshing(false);
}
}
+ }
+ } else {
+ this.listener.informUser(R.string.this_account_is_disabled);
+ swipeLayout.setRefreshing(false);
+ }
Logging.d(Config.LOGTAG, "End Refresh swipe container");
}