From 1fd81aceecd001b8c505625f8f00018955b67315 Mon Sep 17 00:00:00 2001 From: Floens Date: Fri, 14 Aug 2015 22:31:32 +0200 Subject: [PATCH] Fix scroll to bottom not working when the last seen indicator is enabled --- .../floens/chan/ui/adapter/PostAdapter.java | 4 --- .../chan/ui/layout/ThreadListLayout.java | 30 +++++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java b/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java index 12f98a8d..736a3731 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java @@ -183,10 +183,6 @@ public class PostAdapter extends RecyclerView.Adapter { notifyDataSetChanged(); } - public int getDisplaySize() { - return displayList.size(); - } - public int getUnfilteredDisplaySize() { int size = sourceList.size(); diff --git a/Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java b/Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java index 66708f3a..021f4f6c 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java @@ -276,7 +276,7 @@ public class ThreadListLayout extends LinearLayout implements ReplyLayout.ReplyL } if (query != null) { - int size = postAdapter.getDisplaySize(); + int size = postAdapter.getDisplayList().size(); searchStatus.setText(getContext().getString(R.string.search_results, size, getContext().getResources().getQuantityString(R.plurals.posts, size, size), query)); } @@ -368,20 +368,24 @@ public class ThreadListLayout extends LinearLayout implements ReplyLayout.ReplyL public void scrollTo(int displayPosition, boolean smooth) { if (displayPosition < 0) { - displayPosition = recyclerView.getAdapter().getItemCount() - 1; - } - - int scrollPosition = postAdapter.getScrollPosition(displayPosition); + if (smooth) { + recyclerView.smoothScrollToPosition(postAdapter.getItemCount() - 1); + } else { + recyclerView.scrollToPosition(postAdapter.getItemCount() - 1); + } + } else { + int scrollPosition = postAdapter.getScrollPosition(displayPosition); - int difference = Math.abs(scrollPosition - getTopAdapterPosition()); - if (difference > MAX_SMOOTH_SCROLL_DISTANCE) { - smooth = false; - } + int difference = Math.abs(scrollPosition - getTopAdapterPosition()); + if (difference > MAX_SMOOTH_SCROLL_DISTANCE) { + smooth = false; + } - if (smooth) { - recyclerView.smoothScrollToPosition(scrollPosition); - } else { - recyclerView.scrollToPosition(scrollPosition); + if (smooth) { + recyclerView.smoothScrollToPosition(scrollPosition); + } else { + recyclerView.scrollToPosition(scrollPosition); + } } }