aboutsummaryrefslogtreecommitdiff
path: root/about
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-07-27 21:17:30 -0700
committerGitHub <noreply@github.com>2019-07-27 21:17:30 -0700
commita3e5863c4f041fae446671ee7e9b84392656e119 (patch)
treef7b4f407bd1790de37c2b6280bec777697662eb0 /about
parentd94017e6f6df67e80604111028ea16f6c7f4e077 (diff)
parent0bab0561f071fca253b75fbcdae453dbd8790cab (diff)
downloadkau-a3e5863c4f041fae446671ee7e9b84392656e119.tar.gz
kau-a3e5863c4f041fae446671ee7e9b84392656e119.tar.bz2
kau-a3e5863c4f041fae446671ee7e9b84392656e119.zip
Merge pull request #206 from AllanWang/update/fastadapter
Update fastadapter to 4.x.x
Diffstat (limited to 'about')
-rw-r--r--about/build.gradle4
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt4
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt14
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt6
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt36
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt31
6 files changed, 55 insertions, 40 deletions
diff --git a/about/build.gradle b/about/build.gradle
index b970530..274ef5c 100644
--- a/about/build.gradle
+++ b/about/build.gradle
@@ -1,3 +1,5 @@
+import kau.Dependencies
+
apply from: '../android-lib.gradle'
android {
@@ -10,7 +12,7 @@ dependencies {
implementation project(':core-ui')
implementation project(':fastadapter')
- api kau.Dependencies.aboutLibraries
+ api Dependencies.aboutLibraries
}
apply from: '../artifacts.gradle'
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 79077c5..452d28c 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
@@ -33,7 +33,7 @@ import ca.allanwang.kau.utils.INVALID_ID
import ca.allanwang.kau.utils.dimenPixelSize
import com.mikepenz.aboutlibraries.Libs
import com.mikepenz.aboutlibraries.entity.Library
-import com.mikepenz.fastadapter.IItem
+import com.mikepenz.fastadapter.GenericItem
import kotlinx.android.synthetic.main.kau_activity_about.*
/**
@@ -128,7 +128,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde
* Open hook called just before the main page view is returned
* Feel free to add your own items to the adapter in here
*/
- open fun postInflateMainPage(adapter: FastItemThemedAdapter<IItem<*, *>>) {
+ open fun postInflateMainPage(adapter: FastItemThemedAdapter<GenericItem>) {
}
/**
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
index a5d9c17..ba7330c 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt
@@ -34,7 +34,7 @@ import ca.allanwang.kau.utils.string
import ca.allanwang.kau.utils.withMarginDecoration
import ca.allanwang.kau.xml.kauParseFaq
import com.mikepenz.aboutlibraries.Libs
-import com.mikepenz.fastadapter.IItem
+import com.mikepenz.fastadapter.GenericItem
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -48,11 +48,11 @@ interface AboutPanelContract {
/**
* Model list to be added to [adapter]
*/
- var items: List<IItem<*, *>>?
+ var items: List<GenericItem>
/**
* The adapter, will be late initialized as it depends on configs
*/
- var adapter: FastItemThemedAdapter<IItem<*, *>>
+ var adapter: FastItemThemedAdapter<GenericItem>
/**
* Reference to the recyclerview, will be used to stop scrolling upon exit
*/
@@ -90,9 +90,9 @@ interface AboutPanelContract {
abstract class AboutPanelRecycler : AboutPanelContract {
- override var items: List<IItem<*, *>>? = null
+ override var items: List<GenericItem> = emptyList()
- override lateinit var adapter: FastItemThemedAdapter<IItem<*, *>>
+ override lateinit var adapter: FastItemThemedAdapter<GenericItem>
override var recycler: RecyclerView? = null
@@ -116,7 +116,9 @@ abstract class AboutPanelRecycler : AboutPanelContract {
}
override fun addItems(activity: AboutActivityBase, position: Int) {
- if (items == null) return
+ if (items.isEmpty()) {
+ return
+ }
activity.pageStatus[position] = 2
postDelayed(300) { addItemsImpl(activity, position) }
}
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 b51c9c8..d51db46 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt
@@ -27,11 +27,13 @@ import ca.allanwang.kau.ui.views.CutoutView
*
* Just a cutout item with some defaults in [R.layout.kau_iitem_cutout]
*/
-class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem<CutoutIItem, CutoutIItem.ViewHolder>(
+class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem<CutoutIItem.ViewHolder>(
R.layout.kau_iitem_cutout, ::ViewHolder, R.id.kau_item_cutout
), ThemableIItem by ThemableIItemDelegate() {
- override fun isSelectable(): Boolean = false
+ override var isSelectable: Boolean
+ get() = false
+ set(_) {}
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
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 755ac81..977b7ff 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
@@ -30,31 +30,37 @@ import ca.allanwang.kau.utils.parentViewGroup
import ca.allanwang.kau.utils.setPaddingLeft
import ca.allanwang.kau.xml.FaqItem
import com.mikepenz.fastadapter.FastAdapter
-import com.mikepenz.fastadapter.IItem
+import com.mikepenz.fastadapter.GenericItem
import com.mikepenz.fastadapter.listeners.ClickEventHook
+import com.mikepenz.fastadapter.select.getSelectExtension
/**
* Created by Allan Wang on 2017-08-02.
*/
-class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolder>(
+class FaqIItem(val content: FaqItem) : KauIItem<FaqIItem.ViewHolder>(
R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq
), ThemableIItem by ThemableIItemDelegate() {
companion object {
- fun bindEvents(fastAdapter: FastAdapter<IItem<*, *>>) {
- fastAdapter.withSelectable(false)
- .withEventHook(object : ClickEventHook<IItem<*, *>>() {
+ fun bindEvents(fastAdapter: FastAdapter<GenericItem>) {
+ fastAdapter.getSelectExtension().isSelectable = true
+ fastAdapter.addEventHook(object : ClickEventHook<GenericItem>() {
- 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<IItem<*, *>>, item: IItem<*, *>) {
- if (item !is FaqIItem) return
- item.isExpanded = !item.isExpanded
- v.parentViewGroup.findViewById<CollapsibleTextView>(R.id.faq_item_answer)
- .setExpanded(item.isExpanded)
- }
- })
+ override fun onClick(
+ v: View,
+ position: Int,
+ fastAdapter: FastAdapter<GenericItem>,
+ item: GenericItem
+ ) {
+ if (item !is FaqIItem) return
+ item.isExpanded = !item.isExpanded
+ v.parentViewGroup.findViewById<CollapsibleTextView>(R.id.faq_item_answer)
+ .setExpanded(item.isExpanded)
+ }
+ })
}
}
@@ -69,7 +75,7 @@ class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolde
answer.setExpanded(isExpanded, false)
if (accentColor != null) answer.setLinkTextColor(accentColor!!)
answer.text = content.answer
- answer.post { answer.setPaddingLeft(16.dpToPx + number.width) }
+ answer.post { answer.setPaddingLeft(16.dpToPx + number.width) } // TODO not performant at all; and doesn't align across all items
bindTextColor(number, question)
bindTextColorSecondary(answer)
val bg2 = backgroundColor?.colorToForeground(0.1f)
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 33aac09..275945b 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
@@ -29,31 +29,34 @@ import ca.allanwang.kau.utils.startLink
import ca.allanwang.kau.utils.visible
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.fastadapter.FastAdapter
-import com.mikepenz.fastadapter.IItem
+import com.mikepenz.fastadapter.GenericItem
+import com.mikepenz.fastadapter.select.getSelectExtension
/**
* Created by Allan Wang on 2017-06-27.
*/
-class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem, LibraryIItem.ViewHolder>(
+class LibraryIItem(val lib: Library) : KauIItem<LibraryIItem.ViewHolder>(
R.layout.kau_iitem_library, ::ViewHolder, R.id.kau_item_library
), ThemableIItem by ThemableIItemDelegate() {
companion object {
- fun bindEvents(fastAdapter: FastAdapter<IItem<*, *>>) {
- fastAdapter.withSelectable(false)
- .withOnClickListener { v, _, item, _ ->
- if (item !is LibraryIItem)
- false
- else
- with(item.lib) {
- v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite)
- true
- }
- }
+ fun bindEvents(fastAdapter: FastAdapter<GenericItem>) {
+ fastAdapter.getSelectExtension().isSelectable = true
+ fastAdapter.onClickListener = { v, _, item, _ ->
+ if (item !is LibraryIItem)
+ false
+ else
+ with(item.lib) {
+ v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite)
+ true
+ }
+ }
}
}
- override fun isSelectable(): Boolean = false
+ override var isSelectable: Boolean
+ get() = false
+ set(_) {}
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)