diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-10-20 18:35:45 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-10-20 18:35:45 +0900 |
commit | 3b78ac8b44c82085ce36b3c8295d2975c904faa1 (patch) | |
tree | 2e52939e038d67a466d9a55b15642c92b0c7a0b7 /app/src/main/java/net | |
parent | 91b7a80ae0265fbfb09cdfcb8f7d45a784daefb3 (diff) | |
download | SmileEssence-3b78ac8b44c82085ce36b3c8295d2975c904faa1.tar.gz |
autoscroll
Diffstat (limited to 'app/src/main/java/net')
-rw-r--r-- | app/src/main/java/net/lacolaco/smileessence/view/page/TimelinePageFragment.kt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/page/TimelinePageFragment.kt b/app/src/main/java/net/lacolaco/smileessence/view/page/TimelinePageFragment.kt index 0a1e2719..7e921ed1 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/page/TimelinePageFragment.kt +++ b/app/src/main/java/net/lacolaco/smileessence/view/page/TimelinePageFragment.kt @@ -23,6 +23,15 @@ abstract class TimelinePageFragment<T : IdObject, out PI : PageInfo> : PageFragm tweets_recycler_view.layoutManager = layoutManager tweets_recycler_view.adapter = adapter tweets_recycler_view.itemAnimator = null + adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { + override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { + if (positionStart == 0 && itemCount == 1 && + layoutManager.findFirstVisibleItemPosition() == 0 && + (layoutManager.getChildAt(0) != null || layoutManager.getChildAt(0).top == 0)) { + tweets_recycler_view.scrollToPosition(0) + } + } + }) } abstract fun onBindItemView(item: T, itemView: View) |