mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 08:57:48 +01:00
Remove unused viewstatepageradapter dependency
This commit is contained in:
parent
a2d53c439e
commit
2ca62c4eda
3 changed files with 7 additions and 74 deletions
|
@ -247,7 +247,6 @@ dependencies {
|
|||
implementation(libs.androidprocessbutton)
|
||||
implementation(libs.flexible.adapter.core)
|
||||
implementation(libs.flexible.adapter.ui)
|
||||
implementation(libs.viewstatepageradapter)
|
||||
implementation(libs.photoview)
|
||||
implementation(libs.directionalviewpager) {
|
||||
exclude(group = "androidx.viewpager", module = "viewpager")
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.nightlynexus.viewstatepageradapter.ViewStatePagerAdapter
|
||||
import java.util.Stack
|
||||
|
||||
abstract class RecyclerViewPagerAdapter : ViewStatePagerAdapter() {
|
||||
|
||||
private val pool = HashMap<Int, Stack<View>>()
|
||||
|
||||
var recycle = true
|
||||
set(value) {
|
||||
if (!value) pool.clear()
|
||||
field = value
|
||||
}
|
||||
|
||||
protected abstract fun getViewType(position: Int): Int
|
||||
|
||||
protected abstract fun inflateView(container: ViewGroup, viewType: Int): View
|
||||
|
||||
protected abstract fun bindView(view: View, position: Int)
|
||||
|
||||
protected open fun recycleView(view: View, position: Int) {}
|
||||
|
||||
override fun createView(container: ViewGroup, position: Int): View {
|
||||
val viewType = getViewType(position)
|
||||
val view = if (pool[viewType] != null && pool[viewType]!!.isNotEmpty()) {
|
||||
pool[viewType]!!.pop().setViewPagerPositionParam(position)
|
||||
} else {
|
||||
inflateView(container, viewType)
|
||||
}
|
||||
bindView(view, position)
|
||||
return view
|
||||
}
|
||||
|
||||
override fun destroyView(container: ViewGroup, position: Int, view: View) {
|
||||
recycleView(view, position)
|
||||
val viewType = getViewType(position)
|
||||
if (pool[viewType] == null) pool[viewType] = Stack<View>()
|
||||
if (recycle) pool[viewType]!!.push(view)
|
||||
}
|
||||
|
||||
/**
|
||||
* Making sure that this ViewPager child view has the correct "position" layout param
|
||||
* after being recycled.
|
||||
*/
|
||||
private fun View.setViewPagerPositionParam(position: Int): View {
|
||||
val params = layoutParams
|
||||
if (params is ViewPager.LayoutParams) {
|
||||
if (!params.isDecor) {
|
||||
try {
|
||||
val positionField = ViewPager.LayoutParams::class.java.getDeclaredField("position")
|
||||
positionField.isAccessible = true
|
||||
positionField.setInt(params, position)
|
||||
layoutParams = params
|
||||
} catch (e: NoSuchFieldException) {
|
||||
} catch (e: IllegalAccessException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
|
@ -63,7 +63,6 @@ material = "com.google.android.material:material:1.7.0-alpha03"
|
|||
androidprocessbutton = "com.github.dmytrodanylyk.android-process-button:library:1.0.4"
|
||||
flexible-adapter-core = "com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533"
|
||||
flexible-adapter-ui = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui:c8013533"
|
||||
viewstatepageradapter = "com.nightlynexus.viewstatepageradapter:viewstatepageradapter:1.1.0"
|
||||
photoview = "com.github.chrisbanes:PhotoView:2.3.0"
|
||||
directionalviewpager = "com.github.tachiyomiorg:DirectionalViewPager:1.0.0"
|
||||
insetter = "dev.chrisbanes.insetter:insetter:0.6.1"
|
||||
|
@ -81,18 +80,18 @@ acra-http = "ch.acra:acra-http:5.9.6"
|
|||
firebase-analytics = "com.google.firebase:firebase-analytics-ktx:21.1.0"
|
||||
|
||||
aboutLibraries-gradle = { module = "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin", version.ref = "aboutlib_version" }
|
||||
aboutLibraries-compose = { module = "com.mikepenz:aboutlibraries-compose", version.ref ="aboutlib_version" }
|
||||
aboutLibraries-compose = { module = "com.mikepenz:aboutlibraries-compose", version.ref = "aboutlib_version" }
|
||||
|
||||
shizuku-api = { module = "dev.rikka.shizuku:api", version.ref = "shizuku_version" }
|
||||
shizuku-provider = { module = "dev.rikka.shizuku:provider", version.ref = "shizuku_version" }
|
||||
|
||||
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref ="leakcanary" }
|
||||
leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android", version.ref ="leakcanary" }
|
||||
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" }
|
||||
leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android", version.ref = "leakcanary" }
|
||||
|
||||
sqldelight-android-driver = { module = "com.squareup.sqldelight:android-driver", version.ref ="sqldelight" }
|
||||
sqldelight-coroutines = { module = "com.squareup.sqldelight:coroutines-extensions-jvm", version.ref ="sqldelight" }
|
||||
sqldelight-android-paging = { module = "com.squareup.sqldelight:android-paging3-extensions", version.ref ="sqldelight" }
|
||||
sqldelight-gradle = { module="com.squareup.sqldelight:gradle-plugin", version.ref ="sqldelight" }
|
||||
sqldelight-android-driver = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
sqldelight-coroutines = { module = "com.squareup.sqldelight:coroutines-extensions-jvm", version.ref = "sqldelight" }
|
||||
sqldelight-android-paging = { module = "com.squareup.sqldelight:android-paging3-extensions", version.ref = "sqldelight" }
|
||||
sqldelight-gradle = { module = "com.squareup.sqldelight:gradle-plugin", version.ref = "sqldelight" }
|
||||
|
||||
junit = "org.junit.jupiter:junit-jupiter:5.9.0"
|
||||
|
||||
|
|
Loading…
Reference in a new issue