优化
This commit is contained in:
@@ -156,6 +156,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
AppLog.put("书架更新出错", it)
|
AppLog.put("书架更新出错", it)
|
||||||
}.conflate().collect { list ->
|
}.conflate().collect { list ->
|
||||||
binding.tvEmptyMsg.isGone = list.isNotEmpty()
|
binding.tvEmptyMsg.isGone = list.isNotEmpty()
|
||||||
|
binding.refreshLayout.isEnabled = list.isNotEmpty()
|
||||||
booksAdapter.setItems(list)
|
booksAdapter.setItems(list)
|
||||||
recoverPositionState()
|
recoverPositionState()
|
||||||
delay(100)
|
delay(100)
|
||||||
|
|||||||
+11
-1
@@ -3,7 +3,11 @@ package io.legado.app.ui.widget.recycler.scroller
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.RelativeLayout
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
|
|
||||||
@@ -149,7 +153,13 @@ class FastScrollRecyclerView : RecyclerView {
|
|||||||
override fun onAttachedToWindow() {
|
override fun onAttachedToWindow() {
|
||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
mFastScroller.attachRecyclerView(this)
|
mFastScroller.attachRecyclerView(this)
|
||||||
val parent = parent
|
var parent = parent
|
||||||
|
while (parent != null) {
|
||||||
|
when (parent) {
|
||||||
|
is ConstraintLayout, is CoordinatorLayout, is FrameLayout, is RelativeLayout -> break
|
||||||
|
else -> parent = parent.parent
|
||||||
|
}
|
||||||
|
}
|
||||||
if (parent is ViewGroup && parent.indexOfChild(mFastScroller) == -1) {
|
if (parent is ViewGroup && parent.indexOfChild(mFastScroller) == -1) {
|
||||||
parent.addView(mFastScroller)
|
parent.addView(mFastScroller)
|
||||||
mFastScroller.setLayoutParams(parent)
|
mFastScroller.setLayoutParams(parent)
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<io.legado.app.ui.widget.TitleBar
|
<io.legado.app.ui.widget.TitleBar
|
||||||
android:id="@+id/title_bar"
|
android:id="@+id/title_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:title="@string/bookshelf_management"
|
|
||||||
app:contentInsetStartWithNavigation="0dp"
|
app:contentInsetStartWithNavigation="0dp"
|
||||||
app:contentLayout="@layout/view_search"
|
app:contentLayout="@layout/view_search"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:title="@string/bookshelf_management" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/title_bar"
|
android:scrollbars="none"
|
||||||
app:layout_constraintBottom_toTopOf="@id/select_action_bar" />
|
app:layout_constraintBottom_toTopOf="@id/select_action_bar"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/title_bar" />
|
||||||
|
|
||||||
<io.legado.app.ui.widget.SelectActionBar
|
<io.legado.app.ui.widget.SelectActionBar
|
||||||
android:id="@+id/select_action_bar"
|
android:id="@+id/select_action_bar"
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/refresh_layout"
|
android:id="@+id/refresh_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
|
||||||
android:id="@+id/rv_bookshelf"
|
android:id="@+id/rv_bookshelf"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbars="none"
|
||||||
tools:listitem="@layout/item_bookshelf_list" />
|
tools:listitem="@layout/item_bookshelf_list" />
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
@@ -21,11 +22,11 @@
|
|||||||
android:id="@+id/tv_empty_msg"
|
android:id="@+id/tv_empty_msg"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/bookshelf_empty"
|
android:text="@string/bookshelf_empty"
|
||||||
|
android:visibility="gone"
|
||||||
tools:text="TextView" />
|
tools:text="TextView" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user