mihon/app/src/main/java/eu/kanade/tachiyomi/widget/ViewPagerAdapter.kt
arkon 78689e7443
Migrate to AndroidX (#2424)
* Migrate to AndroidX (automatic conversion by Android Studio)

* AndroidX dependency code updates

* Fix source preference reparenting

* fixes the androidx prefererences icon spacing issue

(cherry picked from commit b76a15d960ec2cdf771be16377db0348b66b3179)

* Fix source preference screen heading size/list padding

Co-authored-by: Carlos <cargo8005@gmail.com>
2020-01-05 11:29:27 -05:00

35 lines
916 B
Kotlin

package eu.kanade.tachiyomi.widget
import androidx.viewpager.widget.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
}
interface PositionableView {
val item: Any
}
}