mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-04-24 06:27:18 +02:00
fix #268, use a different image placeholder for business contacts
This commit is contained in:
parent
6de4f09319
commit
09b3f7f2f7
@ -36,6 +36,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||||
|
|
||||||
private lateinit var contactDrawable: Drawable
|
private lateinit var contactDrawable: Drawable
|
||||||
|
private lateinit var businessContactDrawable: Drawable
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var textToHighlight = highlightText
|
private var textToHighlight = highlightText
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||||||
|
|
||||||
fun initDrawables() {
|
fun initDrawables() {
|
||||||
contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person, textColor)
|
contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person, textColor)
|
||||||
|
businessContactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_business, textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateItems(newItems: ArrayList<Contact>, highlightText: String = "") {
|
fun updateItems(newItems: ArrayList<Contact>, highlightText: String = "") {
|
||||||
@ -265,12 +267,13 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||||||
contact_tmb.beVisibleIf(showContactThumbnails)
|
contact_tmb.beVisibleIf(showContactThumbnails)
|
||||||
|
|
||||||
if (showContactThumbnails) {
|
if (showContactThumbnails) {
|
||||||
|
val placeholderImage = if (contact.isABusinessContact()) businessContactDrawable else contactDrawable
|
||||||
when {
|
when {
|
||||||
contact.photoUri.isNotEmpty() -> {
|
contact.photoUri.isNotEmpty() -> {
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(ObjectKey(contact.photoUri))
|
.signature(ObjectKey(contact.photoUri))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.error(contactDrawable)
|
.error(placeholderImage)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
|
|
||||||
Glide.with(activity).load(contact.photoUri).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(contact_tmb)
|
Glide.with(activity).load(contact.photoUri).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(contact_tmb)
|
||||||
@ -279,12 +282,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(ObjectKey(contact.photo!!))
|
.signature(ObjectKey(contact.photo!!))
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.error(contactDrawable)
|
.error(placeholderImage)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
|
|
||||||
Glide.with(activity).load(contact.photo).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(contact_tmb)
|
Glide.with(activity).load(contact.photo).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(contact_tmb)
|
||||||
}
|
}
|
||||||
else -> contact_tmb.setImageDrawable(contactDrawable)
|
else -> contact_tmb.setImageDrawable(placeholderImage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,8 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m
|
|||||||
|
|
||||||
fun getHashToCompare() = getStringToCompare().hashCode()
|
fun getHashToCompare() = getStringToCompare().hashCode()
|
||||||
|
|
||||||
|
fun isABusinessContact() = prefix.isEmpty() && firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty() && suffix.isEmpty() && organization.isNotEmpty()
|
||||||
|
|
||||||
// do a more advanced phone number check here, compare numbers and and search query with dashes, spaces and everything but numbers removed
|
// do a more advanced phone number check here, compare numbers and and search query with dashes, spaces and everything but numbers removed
|
||||||
fun doesContainPhoneNumber(text: String): Boolean {
|
fun doesContainPhoneNumber(text: String): Boolean {
|
||||||
if (text.isNotEmpty()) {
|
if (text.isNotEmpty()) {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
android:id="@+id/contact_tmb"
|
android:id="@+id/contact_tmb"
|
||||||
android:layout_width="@dimen/normal_icon_size"
|
android:layout_width="@dimen/normal_icon_size"
|
||||||
android:layout_height="@dimen/normal_icon_size"
|
android:layout_height="@dimen/normal_icon_size"
|
||||||
|
android:layout_marginTop="@dimen/tiny_margin"
|
||||||
android:padding="@dimen/medium_margin"
|
android:padding="@dimen/medium_margin"
|
||||||
android:src="@drawable/ic_person"/>
|
android:src="@drawable/ic_person"/>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user