aboutsummaryrefslogtreecommitdiff
path: root/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-24 01:17:31 -0500
committerGitHub <noreply@github.com>2018-12-24 01:17:31 -0500
commitfb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b (patch)
treecc6d67461b6caa256043b9482f7646831d528a08 /about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
parenta380adea1052d39f23c9c4d432a9380ce347d6c4 (diff)
downloadkau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.gz
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.bz2
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.zip
Enhancement/ktlint (#179)
* Add spotless dependency * Apply ktlint * Add license headers
Diffstat (limited to 'about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt')
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt41
1 files changed, 28 insertions, 13 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 5f5d0c6..755ac81 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt
@@ -1,11 +1,26 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.about
import android.annotation.SuppressLint
-import androidx.recyclerview.widget.RecyclerView
import android.text.method.LinkMovementMethod
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
import ca.allanwang.kau.iitems.KauIItem
@@ -22,23 +37,24 @@ import com.mikepenz.fastadapter.listeners.ClickEventHook
* Created by Allan Wang on 2017-08-02.
*/
class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolder>(
- R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq
+ 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<*, *>>() {
+ .withEventHook(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, 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, 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)
+ }
+ })
}
}
@@ -83,5 +99,4 @@ class FaqIItem(val content: FaqItem) : KauIItem<LibraryIItem, FaqIItem.ViewHolde
answer.movementMethod = LinkMovementMethod.getInstance()
}
}
-
-} \ No newline at end of file
+}