mirror of
https://github.com/mihonapp/mihon.git
synced 2024-10-31 21:20:59 -04:00
30 lines
851 B
Kotlin
30 lines
851 B
Kotlin
|
package eu.kanade.tachiyomi.widget
|
||
|
|
||
|
import android.support.v4.view.PagerAdapter
|
||
|
import android.view.View
|
||
|
import android.view.ViewGroup
|
||
|
|
||
|
abstract class ViewPagerAdapter : PagerAdapter() {
|
||
|
|
||
|
protected abstract fun createView(container: ViewGroup, position: Int): View
|
||
|
|
||
|
protected open fun destroyView(container: ViewGroup, position: Int, view: View) {
|
||
|
}
|
||
|
|
||
|
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
||
|
val view = createView(container, position)
|
||
|
container.addView(view)
|
||
|
return view
|
||
|
}
|
||
|
|
||
|
override fun destroyItem(container: ViewGroup, position: Int, obj: Any) {
|
||
|
val view = obj as View
|
||
|
destroyView(container, position, view)
|
||
|
container.removeView(view)
|
||
|
}
|
||
|
|
||
|
override fun isViewFromObject(view: View, obj: Any): Boolean {
|
||
|
return view === obj
|
||
|
}
|
||
|
|
||
|
}
|