forked from upstream-mirrors/quik
Add isInEditMode support for AvatarView
This commit is contained in:
@@ -50,8 +50,11 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
if (!isInEditMode) {
|
||||||
|
appComponent.inject(this)
|
||||||
|
}
|
||||||
|
|
||||||
View.inflate(context, R.layout.avatar_view, this)
|
View.inflate(context, R.layout.avatar_view, this)
|
||||||
appComponent.inject(this)
|
|
||||||
|
|
||||||
setBackgroundResource(R.drawable.circle)
|
setBackgroundResource(R.drawable.circle)
|
||||||
clipToOutline = true
|
clipToOutline = true
|
||||||
@@ -59,28 +62,31 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
|
|
||||||
override fun onAttachedToWindow() {
|
override fun onAttachedToWindow() {
|
||||||
super.onAttachedToWindow()
|
super.onAttachedToWindow()
|
||||||
colors.theme
|
|
||||||
.autoDisposable(scope())
|
|
||||||
.subscribe { color -> background.setTint(color) }
|
|
||||||
|
|
||||||
colors.textPrimaryOnTheme
|
if (!isInEditMode) {
|
||||||
.autoDisposable(scope())
|
colors.theme
|
||||||
.subscribe { color -> icon.setTint(color) }
|
.autoDisposable(scope())
|
||||||
|
.subscribe { color -> background.setTint(color) }
|
||||||
|
|
||||||
clicks()
|
colors.textPrimaryOnTheme
|
||||||
.autoDisposable(scope())
|
.autoDisposable(scope())
|
||||||
.subscribe {
|
.subscribe { color -> icon.setTint(color) }
|
||||||
if (contact?.lookupKey.isNullOrEmpty()) {
|
|
||||||
contact?.numbers?.firstOrNull()?.let { number ->
|
clicks()
|
||||||
navigator.addContact(number.address)
|
.autoDisposable(scope())
|
||||||
|
.subscribe {
|
||||||
|
if (contact?.lookupKey.isNullOrEmpty()) {
|
||||||
|
contact?.numbers?.firstOrNull()?.let { number ->
|
||||||
|
navigator.addContact(number.address)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val key = contact?.lookupKey
|
||||||
|
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, key)
|
||||||
|
ContactsContract.QuickContact.showQuickContact(context, this@AvatarView, uri,
|
||||||
|
ContactsContract.QuickContact.MODE_MEDIUM, null)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
val key = contact?.lookupKey
|
|
||||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, key)
|
|
||||||
ContactsContract.QuickContact.showQuickContact(context, this@AvatarView, uri,
|
|
||||||
ContactsContract.QuickContact.MODE_MEDIUM, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFinishInflate() {
|
override fun onFinishInflate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user