2016-07-30 09:51:49 -04:00
|
|
|
package eu.kanade.tachiyomi.widget
|
|
|
|
|
2020-01-05 11:29:27 -05:00
|
|
|
import androidx.viewpager.widget.PagerAdapter
|
2016-07-30 09:51:49 -04:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-09-01 11:12:59 -04:00
|
|
|
interface PositionableView {
|
|
|
|
val item: Any
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|