diff options
Diffstat (limited to 'about/src/main')
4 files changed, 25 insertions, 19 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 6b57825..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,33 +35,31 @@ 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. * * Floating About Activity Panel for your app - * This contains all the necessary layouts, and can be extended and configured using the [configBuilder] + * This contains all the necessary layouts, and can be extended and configured using [buildConfigs] * The [rClass] is necessary to generate the list of libraries used in your app, and should point to your app's * R.string::class.java * If you don't need auto detect, you can pass null instead * Note that for the auto detection to work, the R fields must be excluded from Proguard * Manual lib listings and other extra modifications can be done so by overriding the open functions */ -abstract class AboutActivityBase( - val rClass: Class<*>?, - private val configBuilder: Configs.() -> Unit = {} -) : +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 * Applied lazily since it needs the context to fetch resources */ - val configs: Configs by lazy { Configs().apply { configBuilder() } } + val configs: Configs by lazy { Configs().apply { buildConfigs() } } + + open fun Configs.buildConfigs() = Unit /** * Holds that status of each page @@ -78,31 +77,38 @@ abstract class AboutActivityBase( 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() { diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt index d92f6a7..2a1588c 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt @@ -35,7 +35,7 @@ class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem<CutoutIItem get() = false set(_) {} - override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { + override fun bindView(holder: ViewHolder, payloads: List<Any>) { super.bindView(holder, payloads) with(holder) { if (accentColor != null && themeEnabled) cutout.foregroundColor = accentColor!! diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 977b7ff..ddb9a18 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -67,7 +67,7 @@ class FaqIItem(val content: FaqItem) : KauIItem<FaqIItem.ViewHolder>( private var isExpanded = false @SuppressLint("SetTextI18n") - override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { + override fun bindView(holder: ViewHolder, payloads: List<Any>) { super.bindView(holder, payloads) with(holder) { number.text = "${content.number}." diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index cd53f55..c64fe4e 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -59,7 +59,7 @@ class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem.ViewHolder>( get() = false set(_) {} - override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { + override fun bindView(holder: ViewHolder, payloads: List<Any>) { super.bindView(holder, payloads) with(holder) { name.text = lib.libraryName |