aboutsummaryrefslogtreecommitdiff
path: root/about/src
diff options
context:
space:
mode:
Diffstat (limited to 'about/src')
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt27
1 files changed, 16 insertions, 11 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 4873f6e..96b9884 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
@@ -37,7 +37,7 @@ import com.mikepenz.fastadapter.select.getSelectExtension
/**
* Created by Allan Wang on 2017-08-02.
*/
-class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>(
+class FaqIItem(val content: FaqItem) : KauIItem<FaqIItem.ViewHolder>(
R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq
), ThemableIItem by ThemableIItemDelegate() {
@@ -46,16 +46,21 @@ class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>(
fastAdapter.getSelectExtension().isSelectable = true
fastAdapter.addEventHook(object : ClickEventHook<IItem<*>>() {
- 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, fastAdapter: 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<IItem<*>>,
+ item: IItem<*>
+ ) {
+ if (item !is FaqIItem) return
+ item.isExpanded = !item.isExpanded
+ v.parentViewGroup.findViewById<CollapsibleTextView>(R.id.faq_item_answer)
+ .setExpanded(item.isExpanded)
+ }
+ })
}
}
@@ -70,7 +75,7 @@ class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>(
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)