blob: e617aaa140dac27c9ac3447d43cb77e4b5642553 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package ca.allanwang.kau.iitems
/**
* Created by Allan Wang on 2017-06-27.
*/
import android.os.Build
import android.support.v7.widget.CardView
import android.support.v7.widget.RecyclerView
import android.text.Html
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import ca.allanwang.kau.R
import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.gone
import ca.allanwang.kau.utils.visible
import com.mikepenz.aboutlibraries.entity.Library
import com.mikepenz.fastadapter.items.AbstractItem
/**
* Created by mikepenz on 28.12.15.
*/
class LibraryIItem(val lib: Library) : AbstractItem<LibraryIItem, LibraryIItem.ViewHolder>() {
override fun getType(): Int = R.id.kau_item_about_library
override fun getLayoutRes(): Int = R.layout.kau_about_iitem_library
override fun isSelectable(): Boolean = false
override fun bindView(holder: ViewHolder, payloads: MutableList<Any>?) {
super.bindView(holder, payloads)
with(holder) {
name.text = lib.libraryName
creator.text = lib.author
description.text = if (lib.libraryDescription.isBlank()) lib.libraryDescription
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
Html.fromHtml(lib.libraryDescription, Html.FROM_HTML_MODE_LEGACY)
else Html.fromHtml(lib.libraryDescription)
bottomDivider.gone()
bottomContainer.gone()
if (lib.libraryVersion?.isNotBlank() ?: false) {
bottomDivider.visible()
bottomContainer.visible()
version.text = lib.libraryVersion
}
if (lib.license?.licenseName?.isNotBlank() ?: false) {
bottomDivider.visible()
bottomContainer.visible()
license.text = lib.license?.licenseName
}
}
}
override fun unbindView(holder: ViewHolder) {
super.unbindView(holder)
with (holder) {
name.text = null
creator.text = null
description.text = null
}
}
override fun getViewHolder(v: View): ViewHolder = ViewHolder(v)
class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
val card: CardView by bindView(R.id.lib_item_card)
val name: TextView by bindView(R.id.lib_item_name)
val creator: TextView by bindView(R.id.lib_item_author)
val description: TextView by bindView(R.id.lib_item_description)
val version: TextView by bindView(R.id.lib_item_version)
val license: TextView by bindView(R.id.lib_item_license)
val bottomContainer: LinearLayout by bindView(R.id.lib_item_bottom_container)
val divider: View by bindView(R.id.lib_item_top_divider)
val bottomDivider: View by bindView(R.id.lib_item_bottom_divider)
}
}
|