|
|
@ -7,7 +7,6 @@ import androidx.lifecycle.Observer |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.DiffUtil |
|
|
|
import androidx.recyclerview.widget.GridLayoutManager |
|
|
|
import androidx.recyclerview.widget.GridLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.BaseFragment |
|
|
|
import io.legado.app.base.BaseFragment |
|
|
@ -75,21 +74,6 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), |
|
|
|
booksAdapter = BooksAdapterGrid(requireContext(),this) |
|
|
|
booksAdapter = BooksAdapterGrid(requireContext(),this) |
|
|
|
} |
|
|
|
} |
|
|
|
rv_bookshelf.adapter = booksAdapter |
|
|
|
rv_bookshelf.adapter = booksAdapter |
|
|
|
booksAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() { |
|
|
|
|
|
|
|
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { |
|
|
|
|
|
|
|
super.onItemRangeInserted(positionStart, itemCount) |
|
|
|
|
|
|
|
if (positionStart == 0) { |
|
|
|
|
|
|
|
rv_bookshelf.scrollToPosition(0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { |
|
|
|
|
|
|
|
super.onItemRangeMoved(fromPosition, toPosition, itemCount) |
|
|
|
|
|
|
|
if (toPosition == 0) { |
|
|
|
|
|
|
|
rv_bookshelf.scrollToPosition(0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun upRecyclerData() { |
|
|
|
private fun upRecyclerData() { |
|
|
|