|
|
@ -5,7 +5,6 @@ import android.view.KeyEvent |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.activity.viewModels |
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
import androidx.fragment.app.Fragment |
|
|
|
import androidx.recyclerview.widget.RecyclerView |
|
|
|
|
|
|
|
import androidx.viewpager2.adapter.FragmentStateAdapter |
|
|
|
import androidx.viewpager2.adapter.FragmentStateAdapter |
|
|
|
import androidx.viewpager2.widget.ViewPager2 |
|
|
|
import androidx.viewpager2.widget.ViewPager2 |
|
|
|
import com.google.android.material.bottomnavigation.BottomNavigationView |
|
|
|
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.ui.widget.dialog.TextDialog |
|
|
|
import io.legado.app.utils.observeEvent |
|
|
|
import io.legado.app.utils.observeEvent |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import java.lang.reflect.Field |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(), |
|
|
|
class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(), |
|
|
@ -73,7 +71,6 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(), |
|
|
|
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity) |
|
|
|
bottomNavigationView.setOnNavigationItemReselectedListener(this@MainActivity) |
|
|
|
bottomNavigationView.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS |
|
|
|
bottomNavigationView.menu.findItem(R.id.menu_rss).isVisible = AppConfig.isShowRSS |
|
|
|
} |
|
|
|
} |
|
|
|
resetViewPager2TouchSlop() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onPostCreate(savedInstanceState: Bundle?) { |
|
|
|
override fun onPostCreate(savedInstanceState: Bundle?) { |
|
|
@ -90,22 +87,6 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(), |
|
|
|
}, 3000) |
|
|
|
}, 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) { |
|
|
|
override fun onNavigationItemSelected(item: MenuItem): Boolean = with(binding) { |
|
|
|
when (item.itemId) { |
|
|
|
when (item.itemId) { |
|
|
|
R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false) |
|
|
|
R.id.menu_bookshelf -> viewPagerMain.setCurrentItem(0, false) |
|
|
|