From d540934915da26ab2cec4c897e973be35e0bfe24 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 9 Sep 2018 11:59:24 -0400 Subject: Clean up kotterknife (#161) * Remove bindview implementations internally * Remove more bindView calls * Make config private in ElasticRecyclerActivity * Fix recyclerview * Update adapter * Improve swipe destroy and add direction to swipe finish --- .../ca/allanwang/kau/about/AboutActivityBase.kt | 19 +++++++------------ .../main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt | 3 +-- .../main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 18 ++++++++++-------- .../kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 17 ++++++++--------- 4 files changed, 26 insertions(+), 31 deletions(-) (limited to 'about/src/main/kotlin') 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 dddb0b9..f4ee4c5 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -13,14 +13,13 @@ import ca.allanwang.kau.adapters.ThemableIItemColors import ca.allanwang.kau.adapters.ThemableIItemColorsDelegate import ca.allanwang.kau.internal.KauBaseActivity import ca.allanwang.kau.ui.widgets.ElasticDragDismissFrameLayout -import ca.allanwang.kau.ui.widgets.InkPageIndicator import ca.allanwang.kau.utils.AnimHolder import ca.allanwang.kau.utils.INVALID_ID -import ca.allanwang.kau.utils.bindView import ca.allanwang.kau.utils.dimenPixelSize import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.IItem +import kotlinx.android.synthetic.main.kau_activity_about.* /** * Created by Allan Wang on 2017-06-28. @@ -35,12 +34,8 @@ import com.mikepenz.fastadapter.IItem */ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilder: Configs.() -> Unit = {}) : KauBaseActivity(), ViewPager.OnPageChangeListener { - private val draggableFrame: ElasticDragDismissFrameLayout by bindView(R.id.about_draggable_frame) - private val pager: ViewPager by bindView(R.id.about_pager) - private val indicator: InkPageIndicator by bindView(R.id.about_indicator) - val currentPage: Int - get() = pager.currentItem + get() = about_pager.currentItem /** * Holds some common configurations that may be added directly from the constructor @@ -67,18 +62,18 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde setContentView(R.layout.kau_activity_about) pageStatus = IntArray(panels.size) pageStatus[0] = 2 //the first page is instantly visible - if (configs.textColor != null) indicator.setColour(configs.textColor!!) - with(pager) { + if (configs.textColor != null) about_indicator.setColour(configs.textColor!!) + with(about_pager) { adapter = AboutPagerAdapter() pageMargin = dimenPixelSize(R.dimen.kau_spacing_normal) offscreenPageLimit = panels.size - 1 addOnPageChangeListener(this@AboutActivityBase) } - indicator.setViewPager(pager) - draggableFrame.addListener(object : ElasticDragDismissFrameLayout.SystemChromeFader(this) { + about_indicator.setViewPager(about_pager) + about_draggable_frame.addListener(object : ElasticDragDismissFrameLayout.SystemChromeFader(this) { override fun onDragDismissed() { window.returnTransition = TransitionInflater.from(this@AboutActivityBase) - .inflateTransition(if (draggableFrame.translationY > 0) R.transition.kau_exit_slide_bottom else R.transition.kau_exit_slide_top) + .inflateTransition(if (about_draggable_frame.translationY > 0) R.transition.kau_exit_slide_bottom else R.transition.kau_exit_slide_top) panels[currentPage].recycler?.stopScroll() finishAfterTransition() } 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 448d27f..37c13d8 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt @@ -6,7 +6,6 @@ import ca.allanwang.kau.adapters.ThemableIItem import ca.allanwang.kau.adapters.ThemableIItemDelegate import ca.allanwang.kau.iitems.KauIItem import ca.allanwang.kau.ui.views.CutoutView -import ca.allanwang.kau.utils.bindView /** * Created by Allan Wang on 2017-06-28. @@ -36,7 +35,7 @@ class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem>() { - override fun onBind(viewHolder: RecyclerView.ViewHolder): View? - = (viewHolder as? ViewHolder)?.questionContainer + override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = (viewHolder as? ViewHolder)?.questionContainer override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*, *>) { if (item !is FaqIItem) return @@ -71,11 +73,11 @@ class FaqIItem(val content: FaqItem) : KauIItem