Add isInEditMode support for AvatarView

This commit is contained in:
Moez Bhatti
2018-03-05 17:51:21 -05:00
parent 545319756e
commit a45c49c54b
@@ -50,8 +50,11 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
} }
init { init {
View.inflate(context, R.layout.avatar_view, this) if (!isInEditMode) {
appComponent.inject(this) appComponent.inject(this)
}
View.inflate(context, R.layout.avatar_view, this)
setBackgroundResource(R.drawable.circle) setBackgroundResource(R.drawable.circle)
clipToOutline = true clipToOutline = true
@@ -59,6 +62,8 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
override fun onAttachedToWindow() { override fun onAttachedToWindow() {
super.onAttachedToWindow() super.onAttachedToWindow()
if (!isInEditMode) {
colors.theme colors.theme
.autoDisposable(scope()) .autoDisposable(scope())
.subscribe { color -> background.setTint(color) } .subscribe { color -> background.setTint(color) }
@@ -82,6 +87,7 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
} }
} }
} }
}
override fun onFinishInflate() { override fun onFinishInflate() {
super.onFinishInflate() super.onFinishInflate()