diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-02-20 22:38:51 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-02-20 22:38:51 +0100 |
commit | 8b681105d19743b7417d3837f616b022de268330 (patch) | |
tree | a6af0653629f501cda7c1547473b18caaf28667c /src/main/java/de/pixart/messenger/ui/ConversationFragment.java | |
parent | 1c14932e8449e40e4cb12427cae7e51791f68595 (diff) |
improve RichPreview
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ConversationFragment.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 12b1a5059..975e4f768 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -173,8 +173,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke public Uri mPendingEditorContent = null; public FragmentConversationBinding binding; protected MessageAdapter messageListAdapter; - protected Message lastHistoryMessage = null; - SimpleDateFormat sdf = new SimpleDateFormat("EEEE, dd. MMM yyyy", Locale.getDefault()); private String lastMessageUuid = null; private Conversation conversation; private Toast messageLoaderToast; @@ -682,21 +680,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return -1; } - private ScrollState getScrollPosition(int pos, View view) { - final ListView listView = this.binding.messagesView; - if (listView.getCount() == 0 || listView.getLastVisiblePosition() == listView.getCount() - 1) { - return null; - } else { - //final int pos = listView.getFirstVisiblePosition(); - //final View view = listView.getChildAt(0); - if (view == null) { - return null; - } else { - return new ScrollState(pos, view.getTop()); - } - } - } - private ScrollState getScrollPosition() { final ListView listView = this.binding == null ? null : this.binding.messagesView; if (listView == null || listView.getCount() == 0 || listView.getLastVisiblePosition() == listView.getCount() - 1) { @@ -2958,75 +2941,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return true; } - public Message searchHistory(String query) { - return searchHistory(query, null); - } - - public Message searchHistory(String query, Boolean ascendingSearch) { - return searchHistory(query, lastHistoryMessage, ascendingSearch); - } - - /** - * Search through history from message basis either ascending or descending - * - * @param query search term - * @param basis message to start from. If null, start from last recent message - * @param ascendingSearch do we want to ascend or descend in our search? - * If this is null, ascend to first match and return. - * @return match or null - */ - public Message searchHistory(String query, Message basis, Boolean ascendingSearch) { - int entryIndex; - Message message; - lastHistoryMessage = basis; - if (messageList.size() == 0) { - return null; - } - if (basis == null) { - entryIndex = messageList.size() - 1; - } else { - int in = getIndexOf(basis.getUuid(), messageList); - entryIndex = (in != -1 ? in : messageList.size() - 1); - } - - int firstMatchIndex = entryIndex; - boolean entryIndexWasMatch = true; - do { - message = messageList.get(firstMatchIndex); - if (message.getType() == Message.TYPE_TEXT && messageContainsQuery(message, query)) { - lastHistoryMessage = message; - break; - } - entryIndexWasMatch = false; - firstMatchIndex = (messageList.size() + firstMatchIndex - 1) % messageList.size(); - } while (entryIndex != firstMatchIndex); - - if (!entryIndexWasMatch && entryIndex == firstMatchIndex) { - //No matches - return null; - } - - if (ascendingSearch != null) { - int direction = ascendingSearch ? -1 : 1; - int nextMatchIndex = firstMatchIndex; - do { - nextMatchIndex = (messageList.size() + nextMatchIndex + direction) % messageList.size(); - message = messageList.get(nextMatchIndex); - if (message.getType() == Message.TYPE_TEXT && messageContainsQuery(message, query)) { - lastHistoryMessage = message; - break; - } - } while (nextMatchIndex != entryIndex); - } - - if (lastHistoryMessage != null) { - int pos = getIndexOf(lastHistoryMessage.getUuid(), messageList); - setScrollPosition(getScrollPosition(pos, getView()), null); - this.binding.messagesView.setSelection(pos); - } - return lastHistoryMessage; - } - private boolean messageContainsQuery(Message m, String q) { return m != null && m.getMergedBody().toString().toLowerCase().contains(q.toLowerCase()); } |