open class TextView(context: Context, array: AttributeSet?) : TextViewMedium(context, array) {
companion object {
private val typefaceMap = mutableMapOf<String, Typeface>()
fun getTypeface(context: Context, typefaceName: String): Typeface {
return if (typefaceMap.containsKey(typefaceName)) {
typefaceMap[typefaceName]?: Typeface.DEFAULT
} else {
val typeFace = Typeface.createFromAsset(context.applicationContext.assets, typefaceName)
typefaceMap[typefaceName] = typeFace
typeFace
}
}
}
}
open class TextViewMedium(context: Context, array: AttributeSet?) :
androidx.appcompat.widget.AppCompatTextView(context, array) {
init {
typeface = TextView.getTypeface(context, "Roboto-Medium.ttf")
}
}