From 352fe36980b7bf86958d6ceba2bf8bce01346a77 Mon Sep 17 00:00:00 2001 From: Ash Date: Sat, 8 Oct 2022 21:06:37 +0800 Subject: [PATCH] Fix list view scroll position on click next article button --- .../me/ash/reader/ui/page/home/reading/ReadingViewModel.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/me/ash/reader/ui/page/home/reading/ReadingViewModel.kt b/app/src/main/java/me/ash/reader/ui/page/home/reading/ReadingViewModel.kt index 80b67de..0d55cfc 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/reading/ReadingViewModel.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/reading/ReadingViewModel.kt @@ -37,6 +37,12 @@ class ReadingViewModel @Inject constructor( if (it.feed.isFullContent) internalRenderFullContent() else renderDescriptionContent() } + // java.lang.NullPointerException: Attempt to invoke virtual method + // 'boolean androidx.compose.ui.node.LayoutNode.getNeedsOnPositionedDispatch$ui_release()' + // on a null object reference + if (_readingUiState.value.listState.firstVisibleItemIndex != 0) { + _readingUiState.value.listState.scrollToItem(0) + } hideLoading() } }