aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-22 17:15:47 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-22 17:15:47 +0200
commite58f691a5e7588db6e95b1196f8633247a0922a8 (patch)
tree326631d9a0ebf0d580ba3ad30929dbc8ea4559e6 /src/main
parent1b4bae25fe4c4ff29ab1db532fa3f16e5232c583 (diff)
fixed read event when using fab scroll down
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java90
1 files changed, 47 insertions, 43 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 7bd20f3e5..3e4962cdb 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -211,30 +211,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
};
- private void toggleScrollDownButton() {
- toggleScrollDownButton(binding.messagesView);
- }
-
- private void toggleScrollDownButton(AbsListView listView) {
- if (conversation == null) {
- return;
- }
- if (scrolledToBottom(listView)) {
- lastMessageUuid = null;
- hideUnreadMessagesCount();
-
- } else {
- binding.scrollToBottomButton.setEnabled(true);
- binding.scrollToBottomButton.setVisibility(View.VISIBLE);
- if (lastMessageUuid == null) {
- lastMessageUuid = conversation.getLatestMessage().getUuid();
- }
- if (conversation.getReceivedMessagesCountSinceUuid(lastMessageUuid) > 0) {
- binding.unreadCountCustomView.setVisibility(View.VISIBLE);
- }
- }
- }
-
private OnScrollListener mOnScrollListener = new OnScrollListener() {
@Override
@@ -635,6 +611,49 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return null;
}
+ private static void hideSoftKeyboard(final Activity activity) {
+ InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ View view = activity.getCurrentFocus();
+ if (view != null && imm != null) {
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+ }
+
+ private static boolean scrolledToBottom(AbsListView listView) {
+ final int count = listView.getCount();
+ if (count == 0) {
+ return true;
+ } else if (listView.getLastVisiblePosition() == count - 1) {
+ final View lastChild = listView.getChildAt(listView.getChildCount() - 1);
+ return lastChild != null && lastChild.getBottom() <= listView.getHeight();
+ } else {
+ return false;
+ }
+ }
+
+ private void toggleScrollDownButton() {
+ toggleScrollDownButton(binding.messagesView);
+ }
+
+ private void toggleScrollDownButton(AbsListView listView) {
+ if (conversation == null) {
+ return;
+ }
+ if (scrolledToBottom(listView)) {
+ lastMessageUuid = null;
+ hideUnreadMessagesCount();
+ } else {
+ binding.scrollToBottomButton.setEnabled(true);
+ binding.scrollToBottomButton.setVisibility(View.VISIBLE);
+ if (lastMessageUuid == null) {
+ lastMessageUuid = conversation.getLatestMessage().getUuid();
+ }
+ if (conversation.getReceivedMessagesCountSinceUuid(lastMessageUuid) > 0) {
+ binding.unreadCountCustomView.setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
private int getIndexOf(String uuid, List<Message> messages) {
if (uuid == null) {
return messages.size() - 1;
@@ -1284,14 +1303,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
- private static void hideSoftKeyboard(final Activity activity) {
- InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
- View view = activity.getCurrentFocus();
- if (view != null && imm != null) {
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- }
-
private void quoteMessage(Message message) {
quoteText(MessageUtils.prepareQuote(message));
}
@@ -2131,7 +2142,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
this.reInitRequiredOnStart = true;
pendingExtras.push(extras);
}
- updateUnreadMessagesCount();
+ resetUnreadMessagesCount();
}
private void reInit(Conversation conversation) {
@@ -2177,6 +2188,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
Log.d(Config.LOGTAG, "scrolledToBottomAndNoPending=" + Boolean.toString(scrolledToBottomAndNoPending));
if (hasExtras || scrolledToBottomAndNoPending) {
+ resetUnreadMessagesCount();
synchronized (this.messageList) {
Log.d(Config.LOGTAG, "jump to first unread message");
final Message first = conversation.getFirstUnreadMessage();
@@ -2237,7 +2249,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return true;
}
- private void updateUnreadMessagesCount() {
+ private void resetUnreadMessagesCount() {
lastMessageUuid = null;
hideUnreadMessagesCount();
}
@@ -2254,6 +2266,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
private void setSelection(int pos) {
this.binding.messagesView.setSelection(pos);
this.binding.messagesView.post(() -> this.binding.messagesView.setSelection(pos));
+ this.binding.messagesView.post(this::fireReadEvent);
}
private boolean scrolledToBottom() {
@@ -2263,15 +2276,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return scrolledToBottom(this.binding.messagesView);
}
- private static boolean scrolledToBottom(AbsListView listView) {
- if (listView.getLastVisiblePosition() == listView.getCount() - 1) {
- final View lastChild = listView.getChildAt(listView.getChildCount() - 1);
- return lastChild != null && lastChild.getBottom() <= listView.getHeight();
- } else {
- return false;
- }
- }
-
private void processExtras(Bundle extras) {
final String downloadUuid = extras.getString(ConversationsActivity.EXTRA_DOWNLOAD_UUID);
final String text = extras.getString(ConversationsActivity.EXTRA_TEXT);