pull/981/head
gedoor 4 years ago
parent 35db345a5d
commit 14f9bc8f14
  1. 8
      app/src/main/java/io/legado/app/lib/theme/ATH.kt
  2. 4
      app/src/main/java/io/legado/app/ui/widget/recycler/ItemTouchCallback.kt

@ -16,7 +16,7 @@ import android.widget.ScrollView
import androidx.annotation.ColorInt
import androidx.appcompat.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.bottomnavigation.BottomNavigationView
import io.legado.app.R
import io.legado.app.help.AppConfig
@ -219,9 +219,9 @@ object ATH {
}
}
fun setEdgeEffectColor(viewPager: ViewPager?, @ColorInt color: Int) {
fun setEdgeEffectColor(viewPager: ViewPager2?, @ColorInt color: Int) {
try {
val clazz = ViewPager::class.java
val clazz = ViewPager2::class.java
for (name in arrayOf("mLeftEdge", "mRightEdge")) {
val field = clazz.getDeclaredField(name)
field.isAccessible = true
@ -280,7 +280,7 @@ object ATH {
fun applyEdgeEffectColor(view: View?) {
when (view) {
is RecyclerView -> view.edgeEffectFactory = DEFAULT_EFFECT_FACTORY
is ViewPager -> setEdgeEffectColor(view, ThemeStore.primaryColor(view.context))
is ViewPager2 -> setEdgeEffectColor(view, ThemeStore.primaryColor(view.context))
is ScrollView -> setEdgeEffectColor(view, ThemeStore.primaryColor(view.context))
}
}

@ -6,17 +6,14 @@ import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.viewpager.widget.ViewPager
/**
* Created by GKF on 2018/3/16.
*/
@Suppress("MemberVisibilityCanBePrivate")
class ItemTouchCallback(private val callback: Callback) : ItemTouchHelper.Callback() {
private var swipeRefreshLayout: SwipeRefreshLayout? = null
private var viewPager: ViewPager? = null
/**
* 是否可以拖拽
@ -107,7 +104,6 @@ class ItemTouchCallback(private val callback: Callback) : ItemTouchHelper.Callba
super.onSelectedChanged(viewHolder, actionState)
val swiping = actionState == ItemTouchHelper.ACTION_STATE_DRAG
swipeRefreshLayout?.isEnabled = !swiping
viewPager?.requestDisallowInterceptTouchEvent(swiping)
}
override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder) {

Loading…
Cancel
Save