aboutsummaryrefslogtreecommitdiff
path: root/about/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
Diffstat (limited to 'about/src/main/kotlin/ca/allanwang')
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt9
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt23
2 files changed, 17 insertions, 15 deletions
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 8ae445d..4873f6e 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
@@ -32,23 +32,24 @@ import ca.allanwang.kau.xml.FaqItem
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.IItem
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<*>>() {
+ fastAdapter.getSelectExtension().isSelectable = true
+ fastAdapter.addEventHook(object : ClickEventHook<IItem<*>>() {
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? =
(viewHolder as? ViewHolder)?.questionContainer
- override fun onClick(v: View, position: Int, adapter: FastAdapter<IItem<*>>, item: IItem<*>) {
+ override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<IItem<*>>, item: IItem<*>) {
if (item !is FaqIItem) return
item.isExpanded = !item.isExpanded
v.parentViewGroup.findViewById<CollapsibleTextView>(R.id.faq_item_answer)
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 dbff49a..445d435 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt
@@ -30,26 +30,27 @@ 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.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
- }
- }
+ fastAdapter.getSelectExtension().isSelectable = true
+ fastAdapter.onClickListener = { v, _, item, _ ->
+ if (item !is LibraryIItem)
+ false
+ else
+ with(item.lib) {
+ v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite)
+ true
+ }
+ }
}
}