diff options
author | lookshe <github@lookshe.org> | 2015-08-16 18:59:59 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2015-08-16 19:14:01 +0200 |
commit | caefd38f96a3a9d8cf51ea2a672daf76c7e237b6 (patch) | |
tree | 871ebd005c3dd8a0f30b06ce447410009ad7ffb8 /src/main/java/eu | |
parent | 9181767ac682e38d248f35136a5b7f308f0c72dd (diff) |
moved merged files to correct location
Diffstat (limited to 'src/main/java/eu')
2 files changed, 0 insertions, 166 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java deleted file mode 100644 index 2154f8d8..00000000 --- a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationMoreMessagesLoadedListener.java +++ /dev/null @@ -1,118 +0,0 @@ -package eu.siacs.conversations.ui.listeners; - -import android.support.v4.widget.SwipeRefreshLayout; -import android.view.View; -import android.widget.ListView; -import android.widget.Toast; - -import java.util.List; - -import eu.siacs.conversations.entities.Conversation; -import eu.siacs.conversations.entities.Message; -import eu.siacs.conversations.services.XmppConnectionService; -import eu.siacs.conversations.ui.ConversationActivity; -import eu.siacs.conversations.ui.ConversationFragment; -import eu.siacs.conversations.ui.adapter.MessageAdapter; - -/** - * This listener updates the UI when messages are loaded from the server. - */ -public class ConversationMoreMessagesLoadedListener implements XmppConnectionService.OnMoreMessagesLoaded { - private SwipeRefreshLayout swipeLayout; - private List<Message> messageList; - private ConversationFragment fragment; - private ListView messagesView; - private MessageAdapter messageListAdapter; - private Toast messageLoaderToast; - - public ConversationMoreMessagesLoadedListener(SwipeRefreshLayout 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; - } - - @Override - public void onMoreMessagesLoaded(final int c, final Conversation conversation) { - ConversationActivity activity = (ConversationActivity) fragment.getActivity(); - if (activity.getSelectedConversation() != conversation) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - swipeLayout.setRefreshing(false); - } - }); - return; - } - if (0 == c) { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - swipeLayout.setRefreshing(false); - } - }); - } - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - final int oldPosition = messagesView.getFirstVisiblePosition(); - int pos = 0; - View v = messagesView.getChildAt(0); - final int pxOffset = (v == null) ? 0 : v.getTop(); - if (-1 < oldPosition && messageList.size() > oldPosition) { - Message message = messageList.get(oldPosition); - String uuid = message != null ? message.getUuid() : null; - pos = getIndexOf(uuid, messageList); - } - conversation.populateWithMessages(messageList); - fragment.updateStatusMessages(); - messageListAdapter.notifyDataSetChanged(); - messagesView.setSelectionFromTop(pos, pxOffset); - - if (messageLoaderToast != null) { - messageLoaderToast.cancel(); - } - swipeLayout.setRefreshing(false); - } - }); - } - - @Override - public void informUser(final int resId) { - final ConversationActivity activity = (ConversationActivity) fragment.getActivity(); - - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (messageLoaderToast != null) { - messageLoaderToast.cancel(); - } - messageLoaderToast = Toast.makeText(activity, resId, Toast.LENGTH_LONG); - messageLoaderToast.show(); - } - }); - - } - - private int getIndexOf(String uuid, List<Message> messages) { - if (uuid == null) { - return 0; - } - for(int i = 0; i < messages.size(); ++i) { - if (uuid.equals(messages.get(i).getUuid())) { - return i; - } else { - Message next = messages.get(i); - while(next != null && next.wasMergedIntoPrevious()) { - if (uuid.equals(next.getUuid())) { - return i; - } - next = next.next(); - } - - } - } - return 0; - } -} diff --git a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java b/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java deleted file mode 100644 index 09a8d730..00000000 --- a/src/main/java/eu/siacs/conversations/ui/listeners/ConversationSwipeRefreshListener.java +++ /dev/null @@ -1,48 +0,0 @@ -package eu.siacs.conversations.ui.listeners; - -import android.support.v4.widget.SwipeRefreshLayout; -import android.util.Log; -import android.view.View; -import android.widget.ListView; -import android.widget.Toast; - -import java.util.List; - -import eu.siacs.conversations.Config; -import eu.siacs.conversations.entities.Conversation; -import eu.siacs.conversations.entities.Message; -import eu.siacs.conversations.services.XmppConnectionService; -import eu.siacs.conversations.ui.ConversationActivity; -import eu.siacs.conversations.ui.ConversationFragment; -import eu.siacs.conversations.ui.adapter.MessageAdapter; - -/** - * This listener starts loading messages from the server. - */ -public class ConversationSwipeRefreshListener implements SwipeRefreshLayout.OnRefreshListener { - private List<Message> messageList; - private ConversationFragment fragment; - private ConversationMoreMessagesLoadedListener listener; - - public ConversationSwipeRefreshListener(List<Message> messageList, SwipeRefreshLayout swipeLayout, ConversationFragment fragment, ListView messagesView, MessageAdapter messageListAdapter) { - this.messageList = messageList; - this.fragment = fragment; - this.listener = new ConversationMoreMessagesLoadedListener(swipeLayout, messageList, fragment, messagesView, messageListAdapter); - } - - @Override - public void onRefresh() { - Log.d(Config.LOGTAG, "Refresh swipe container"); - synchronized (this.messageList) { - long timestamp; - if (messageList.isEmpty()) { - timestamp = System.currentTimeMillis(); - } else { - timestamp = this.messageList.get(0).getTimeSent(); - } - ConversationActivity activity = (ConversationActivity) fragment.getActivity(); - activity.xmppConnectionService.loadMoreMessages(activity.getSelectedConversation(), timestamp, this.listener); - } - Log.d(Config.LOGTAG, "End Refresh swipe container"); - } -} |