diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-23 23:15:47 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-28 13:52:59 +0000 |
| commit | 02bfcae9b7298c72026347d0ec95df02a4a1aacb (patch) | |
| tree | 818041aee865466c6153d50b92fbc8fb7a4a94e8 /android/src | |
| parent | 4aeada6c481fcb48afc5ea0e9611943ff76d6cdb (diff) | |
| download | mullvadvpn-02bfcae9b7298c72026347d0ec95df02a4a1aacb.tar.xz mullvadvpn-02bfcae9b7298c72026347d0ec95df02a4a1aacb.zip | |
Allow sub-classes to request a cell footer
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Cell.kt | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Cell.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Cell.kt index 4affaa84db..2d40426ca4 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Cell.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/Cell.kt @@ -23,7 +23,7 @@ open class Cell : LinearLayout { setTypeface(null, Typeface.BOLD) } - private var footer: TextView? = null + protected var footer: TextView? = null set(value) { field = value?.apply { val horizontalPadding = @@ -59,14 +59,13 @@ open class Cell : LinearLayout { var onClickListener: (() -> Unit)? = null - constructor(context: Context) : super(context) {} - - constructor(context: Context, attributes: AttributeSet) : super(context, attributes) { - loadAttributes(attributes) + constructor(context: Context, footer: TextView? = null) : super(context) { + this.footer = footer } - constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : - super(context, attributes, defaultStyleAttribute) { + constructor(context: Context, attributes: AttributeSet, footer: TextView? = null) : + super(context, attributes) { + this.footer = footer loadAttributes(attributes) } @@ -74,8 +73,20 @@ open class Cell : LinearLayout { context: Context, attributes: AttributeSet, defaultStyleAttribute: Int, - defaultStyleResource: Int + footer: TextView? = null + ) : super(context, attributes, defaultStyleAttribute) { + this.footer = footer + loadAttributes(attributes) + } + + constructor( + context: Context, + attributes: AttributeSet, + defaultStyleAttribute: Int, + defaultStyleResource: Int, + footer: TextView? = null ) : super(context, attributes, defaultStyleAttribute, defaultStyleResource) { + this.footer = footer loadAttributes(attributes) } @@ -90,8 +101,12 @@ open class Cell : LinearLayout { context.theme.obtainStyledAttributes(attributes, R.styleable.Cell, 0, 0).apply { try { - footer = getString(R.styleable.Cell_footer)?.let { footerText -> - TextView(context).apply { text = footerText } + getString(R.styleable.Cell_footer)?.let { footerText -> + if (footer == null) { + footer = TextView(context) + } + + footer?.text = footerText } } finally { recycle() |
