2020-04-28 19:57:49 -04:00
|
|
|
package eu.kanade.tachiyomi.widget
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
|
|
|
import eu.kanade.tachiyomi.databinding.CommonTabbedSheetBinding
|
|
|
|
|
|
|
|
abstract class TabbedBottomSheetDialog(private val activity: Activity) : BottomSheetDialog(activity) {
|
|
|
|
|
|
|
|
init {
|
|
|
|
val binding: CommonTabbedSheetBinding = CommonTabbedSheetBinding.inflate(activity.layoutInflater)
|
|
|
|
|
|
|
|
val adapter = LibrarySettingsSheetAdapter()
|
2020-05-28 18:15:24 -04:00
|
|
|
binding.pager.offscreenPageLimit = 2
|
2020-04-28 19:57:49 -04:00
|
|
|
binding.pager.adapter = adapter
|
|
|
|
binding.tabs.setupWithViewPager(binding.pager)
|
|
|
|
|
|
|
|
setContentView(binding.root)
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract fun getTabViews(): List<View>
|
|
|
|
|
|
|
|
abstract fun getTabTitles(): List<Int>
|
|
|
|
|
|
|
|
private inner class LibrarySettingsSheetAdapter : ViewPagerAdapter() {
|
|
|
|
|
|
|
|
override fun createView(container: ViewGroup, position: Int): View {
|
|
|
|
return getTabViews()[position]
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getCount(): Int {
|
|
|
|
return getTabViews().size
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun getPageTitle(position: Int): CharSequence {
|
|
|
|
return activity.resources!!.getString(getTabTitles()[position])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|