diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index b3abb11e3..65ca55b42 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -5,7 +5,6 @@ import android.view.KeyEvent import android.view.MenuItem import androidx.activity.viewModels import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.bottomnavigation.BottomNavigationView @@ -31,7 +30,6 @@ import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.observeEvent import io.legado.app.utils.toastOnUi -import java.lang.reflect.Field class MainActivity : VMBaseActivity(), @@ -73,7 +71,6 @@ class MainActivity : VMBaseActivity(), bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity) bottomNavigationView.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS } - resetViewPager2TouchSlop() } override fun onPostCreate(savedInstanceState: Bundle?) { @@ -90,22 +87,6 @@ class MainActivity : VMBaseActivity(), }, 3000) } - /** - * 重新设置viewpager2的滑动灵敏度 - */ - private fun resetViewPager2TouchSlop() = kotlin.runCatching { - val recyclerViewField: Field = ViewPager2::class.java.getDeclaredField("mRecyclerView") - recyclerViewField.isAccessible = true - - val recyclerView = recyclerViewField.get(binding.viewPagerMain) as RecyclerView - - val touchSlopField: Field = RecyclerView::class.java.getDeclaredField("mTouchSlop") - touchSlopField.isAccessible = true - - val touchSlop = touchSlopField.get(recyclerView) as Int - touchSlopField.set(recyclerView, touchSlop * 4) - } - override fun onNavigationItemSelected(item: MenuItem): Boolean = with(binding) { when (item.itemId) { R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 390de88b0..7a7113054 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -10,9 +10,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.lifecycle.LiveData -import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.adapter.FragmentStateAdapter -import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayoutMediator import io.legado.app.R @@ -38,7 +36,6 @@ import io.legado.app.ui.main.MainViewModel import io.legado.app.ui.main.bookshelf.books.BooksFragment import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding -import java.lang.reflect.Field /** * 书架界面 @@ -66,23 +63,6 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b setSupportToolbar(binding.titleBar.toolbar) initView() initBookGroupData() - resetViewPager2TouchSlop() - } - - /** - * 重新设置viewpager2的滑动灵敏度 - */ - private fun resetViewPager2TouchSlop() = kotlin.runCatching { - val recyclerViewField: Field = ViewPager2::class.java.getDeclaredField("mRecyclerView") - recyclerViewField.isAccessible = true - - val recyclerView = recyclerViewField.get(binding.viewPagerBookshelf) as RecyclerView - - val touchSlopField: Field = RecyclerView::class.java.getDeclaredField("mTouchSlop") - touchSlopField.isAccessible = true - - val touchSlop = touchSlopField.get(recyclerView) as Int - touchSlopField.set(recyclerView, touchSlop * 4) } override fun onCompatCreateOptionsMenu(menu: Menu) {