diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-03-14 22:40:11 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-03-14 22:40:11 +0100 |
commit | 9690b1baf34c9363d92bb9df6b4cba53e08dd7de (patch) | |
tree | 33c99676f876db8cca0c4347d8e7c136f535dadb /src/main/java/de/pixart/messenger/ui | |
parent | f0e7a905e3dfafa81b536af7c1447fe9c90ff8a1 (diff) |
fix jump to bottom while scrolling
possibly caused by datebubbles
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 6e39a0358..b52c94753 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -46,6 +46,7 @@ import net.java.otr4j.session.SessionStatus; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Locale; import java.util.UUID; @@ -125,8 +126,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa private TextView snackbarAction; private Toast messageLoaderToast; SimpleDateFormat sdf = new SimpleDateFormat("EEEE, dd. MMM yyyy", Locale.getDefault()); - String first = sdf.format(System.currentTimeMillis()); - String today = sdf.format(System.currentTimeMillis()); private OnScrollListener mOnScrollListener = new OnScrollListener() { @@ -1304,29 +1303,23 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } protected void updateDateBubbles() { - synchronized (this.messageList) { - int max = this.messageList.size(); - if (max == 0 || (max <= 1 && showLoadMoreMessages(conversation))) { - this.messageList.add(0, Message.createDateMessage(conversation, getString(R.string.start_chatting))); - } else if ((max > 0 && !showLoadMoreMessages(conversation)) || (max > 1 && showLoadMoreMessages(conversation))) { - for (int i = (max - 1); i > 0; --i) { - String last = sdf.format(this.messageList.get(i).getTimeSent()); - String date = first; - if (!last.equals(first)) { - if (i < (max - 1)) { - if (today.equals(first)) { - date = getString(R.string.today); - } - this.messageList.add(i + 1, Message.createDateMessage(conversation, date)); - } - } + String first = null; + String today = sdf.format(System.currentTimeMillis()); + int max = this.messageList.size(); + if (max == 0 || (max <= 1 && showLoadMoreMessages(conversation))) { + this.messageList.add(0, Message.createDateMessage(conversation, getString(R.string.start_chatting))); + } else if ((max > 0 && !showLoadMoreMessages(conversation)) || (max > 1 && showLoadMoreMessages(conversation))) { + for (int i = 0; i < this.messageList.size(); i++) { + Date date = new Date(this.messageList.get(i).getTimeSent()); + String last = sdf.format(date); + if (first == null || !first.equals(last)) { first = last; + String dateString = first; + if (today.equals(first)) { + dateString = getString(R.string.today); + } + this.messageList.add(i, Message.createDateMessage(conversation, dateString)); } - String date = sdf.format(this.messageList.get(0).getTimeSent()); - if (today.equals(date)) { - date = getString(R.string.today); - } - this.messageList.add(0, Message.createDateMessage(conversation, date)); } } } |