diff options
author | Allan Wang <me@allanwang.ca> | 2021-04-17 15:32:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-17 15:32:32 -0700 |
commit | 12f4725a90762aeeca8936b6449445e800b2f09a (patch) | |
tree | 584d1347abf542361c327519942080c75c16a889 /about/src/main/kotlin/ca | |
parent | 3ec75195a25f6e502ceca7a89aa66f6313e263e6 (diff) | |
parent | 1057b6a113c7b2fa1320ce0378e34484f901ee2f (diff) | |
download | kau-12f4725a90762aeeca8936b6449445e800b2f09a.tar.gz kau-12f4725a90762aeeca8936b6449445e800b2f09a.tar.bz2 kau-12f4725a90762aeeca8936b6449445e800b2f09a.zip |
Merge pull request #261 from AllanWang/versions
Diffstat (limited to 'about/src/main/kotlin/ca')
-rw-r--r-- | about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt index 4fe97da..286d95e 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -23,6 +23,7 @@ import android.view.View import android.view.ViewGroup import androidx.viewpager.widget.PagerAdapter import androidx.viewpager.widget.ViewPager +import ca.allanwang.kau.about.databinding.KauActivityAboutBinding import ca.allanwang.kau.adapters.FastItemThemedAdapter import ca.allanwang.kau.adapters.ThemableIItemColors import ca.allanwang.kau.adapters.ThemableIItemColorsDelegate @@ -34,7 +35,6 @@ import ca.allanwang.kau.utils.dimenPixelSize import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.GenericItem -import kotlinx.android.synthetic.main.kau_activity_about.* /** * Created by Allan Wang on 2017-06-28. @@ -51,7 +51,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?) : KauBaseActivity(), ViewPager.OnPageChangeListener { val currentPage: Int - get() = about_pager.currentItem + get() = binding.aboutPager.currentItem /** * Holds some common configurations that may be added directly from the constructor @@ -77,31 +77,38 @@ abstract class AboutActivityBase(val rClass: Class<*>?) : defaultPanels } + private lateinit var binding: KauActivityAboutBinding + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setContentView(R.layout.kau_activity_about) + binding = KauActivityAboutBinding.inflate(layoutInflater) + setContentView(binding.root) + binding.init() + } + + private fun KauActivityAboutBinding.init() { pageStatus = IntArray(panels.size) pageStatus[0] = 2 // the first page is instantly visible if (configs.textColor != null) { - about_indicator.setColour(configs.textColor!!) + aboutIndicator.setColour(configs.textColor!!) } - with(about_pager) { + with(aboutPager) { adapter = AboutPagerAdapter() pageMargin = dimenPixelSize(R.dimen.kau_spacing_normal) offscreenPageLimit = panels.size - 1 addOnPageChangeListener(this@AboutActivityBase) } - about_indicator.setViewPager(about_pager) - about_draggable_frame.addListener(object : - ElasticDragDismissFrameLayout.SystemChromeFader(this) { + aboutIndicator.setViewPager(aboutPager) + aboutDraggableFrame.addListener(object : + ElasticDragDismissFrameLayout.SystemChromeFader(this@AboutActivityBase) { override fun onDragDismissed() { window.returnTransition = TransitionInflater.from(this@AboutActivityBase) - .inflateTransition(if (about_draggable_frame.translationY > 0) R.transition.kau_exit_slide_bottom else R.transition.kau_exit_slide_top) + .inflateTransition(if (aboutDraggableFrame.translationY > 0) R.transition.kau_exit_slide_bottom else R.transition.kau_exit_slide_top) panels[currentPage].recycler?.stopScroll() finishAfterTransition() } }) - panels.forEachIndexed { index, contract -> contract.loadItems(this, index) } + panels.forEachIndexed { index, contract -> contract.loadItems(this@AboutActivityBase, index) } } class Configs : ThemableIItemColors by ThemableIItemColorsDelegate() { |