show scroll down button instantly when scrolling up

This commit is contained in:
Daniel Gultsch 2018-03-30 10:58:07 +02:00
parent 419e7f5ea6
commit d27d9d9366
2 changed files with 8 additions and 10 deletions

View File

@ -12,7 +12,4 @@
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
#Sat Feb 17 18:50:27 CST 2018
systemProp.http.proxyHost=127.0.0.1
org.gradle.jvmargs=-Xmx2048M org.gradle.jvmargs=-Xmx2048M
systemProp.http.proxyPort=1080

View File

@ -187,11 +187,15 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}; };
private void toggleScrollDownButton() { private void toggleScrollDownButton() {
toggleScrollDownButton(binding.messagesView, binding.messagesView.getCount()); toggleScrollDownButton(binding.messagesView);
} }
private void toggleScrollDownButton(AbsListView listView, int count) { private void toggleScrollDownButton(AbsListView listView) {
if (listView.getLastVisiblePosition() < count - 5) { if (scrolledToBottom(listView)) {
lastMessageUuid = null;
hideUnreadMessagesCount();
} else {
binding.scrollToBottomButton.setEnabled(true); binding.scrollToBottomButton.setEnabled(true);
binding.scrollToBottomButton.setVisibility(View.VISIBLE); binding.scrollToBottomButton.setVisibility(View.VISIBLE);
if (lastMessageUuid == null) { if (lastMessageUuid == null) {
@ -200,9 +204,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
if (conversation.getReceivedMessagesCountSinceUuid(lastMessageUuid) > 0) { if (conversation.getReceivedMessagesCountSinceUuid(lastMessageUuid) > 0) {
binding.unreadCountCustomView.setVisibility(View.VISIBLE); binding.unreadCountCustomView.setVisibility(View.VISIBLE);
} }
} else if (scrolledToBottom(listView)){
lastMessageUuid = null;
hideUnreadMessagesCount();
} }
} }
@ -215,7 +216,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
@Override @Override
public void onScroll(final AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(final AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
toggleScrollDownButton(view, totalItemCount); toggleScrollDownButton(view);
synchronized (ConversationFragment.this.messageList) { synchronized (ConversationFragment.this.messageList) {
if (firstVisibleItem < 5 && conversation != null && conversation.messagesLoaded.compareAndSet(true, false) && messageList.size() > 0) { if (firstVisibleItem < 5 && conversation != null && conversation.messagesLoaded.compareAndSet(true, false) && messageList.size() > 0) {
long timestamp; long timestamp;