parent
71f06f74c0
commit
7715d421f6
@ -1,47 +0,0 @@ |
|||||||
package net.pokeranalytics.android.ui.view |
|
||||||
|
|
||||||
import android.content.Context |
|
||||||
import android.util.AttributeSet |
|
||||||
import androidx.appcompat.widget.AppCompatTextView |
|
||||||
import net.pokeranalytics.android.calculus.TextFormat |
|
||||||
|
|
||||||
/** |
|
||||||
* Extended TextView to display a TextFormat object |
|
||||||
*/ |
|
||||||
class FormattedTextView: AppCompatTextView { |
|
||||||
|
|
||||||
var textFormat: TextFormat? = null |
|
||||||
set(value) { |
|
||||||
field = value |
|
||||||
updateUI() |
|
||||||
} |
|
||||||
|
|
||||||
constructor(context: Context?) : super(context) { |
|
||||||
init(null) |
|
||||||
} |
|
||||||
|
|
||||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { |
|
||||||
init(attrs) |
|
||||||
} |
|
||||||
|
|
||||||
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { |
|
||||||
init(attrs) |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Init class |
|
||||||
*/ |
|
||||||
private fun init(attrs: AttributeSet?) { |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Update the UI to manage currency format & color management |
|
||||||
*/ |
|
||||||
private fun updateUI() { |
|
||||||
textFormat?.let { |
|
||||||
setTextColor(it.getColor(context)) |
|
||||||
text = it.text |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<resources> |
|
||||||
<declare-styleable name="FormattedTextView"> |
|
||||||
<attr name="isCurrency" format="boolean" /> |
|
||||||
<attr name="amount" format="float" /> |
|
||||||
</declare-styleable> |
|
||||||
</resources> |
|
||||||
Loading…
Reference in new issue