diff options
author | Allan Wang <allanwang@google.com> | 2019-07-27 17:56:41 -0700 |
---|---|---|
committer | Allan Wang <allanwang@google.com> | 2019-07-27 17:56:41 -0700 |
commit | 99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01 (patch) | |
tree | 2910c610362ca7e94c69ea7ae949aa1f1616ca42 /about/src/main/kotlin/ca/allanwang | |
parent | 50c8012e2fe88d6b275d1a3269033590962caa7f (diff) | |
download | kau-99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01.tar.gz kau-99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01.tar.bz2 kau-99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01.zip |
Migrate some items
Diffstat (limited to 'about/src/main/kotlin/ca/allanwang')
-rw-r--r-- | about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 9 | ||||
-rw-r--r-- | about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 23 |
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 + } + } } } |