Created
January 18, 2020 12:35
-
-
Save krossovochkin/9f1190311910df185a3771540f49a314 to your computer and use it in GitHub Desktop.
Theme_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyTextView | |
@JvmOverloads | |
constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : AppCompatTextView(context, attrs, defStyleAttr), | |
ThemeManager.ThemeChangedListener { | |
override fun onFinishInflate() { | |
super.onFinishInflate() | |
ThemeManager.addListener(this) | |
} | |
override fun onAttachedToWindow() { | |
super.onAttachedToWindow() | |
ThemeManager.addListener(this) | |
} | |
override fun onDetachedFromWindow() { | |
super.onDetachedFromWindow() | |
ThemeManager.removeListener(this) | |
} | |
override fun onThemeChanged(theme: ThemeManager.Theme) { | |
setTextColor( | |
ContextCompat.getColor( | |
context, | |
theme.textViewTheme.textColor | |
) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment