hide the thumbnail at Favorite selector when appropriate
This commit is contained in:
parent
7063b9ffd2
commit
d1152fb657
|
@ -31,13 +31,14 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||||
val isFavoritesFragment: Boolean, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
val isFavoritesFragment: Boolean, recyclerView: MyRecyclerView, fastScroller: FastScroller, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||||
|
|
||||||
lateinit private var contactDrawable: Drawable
|
private lateinit var contactDrawable: Drawable
|
||||||
var config = activity.config
|
var config = activity.config
|
||||||
var startNameWithSurname: Boolean
|
var startNameWithSurname: Boolean
|
||||||
var showContactThumbnails: Boolean
|
var showContactThumbnails: Boolean
|
||||||
var showPhoneNumbers: Boolean
|
var showPhoneNumbers: Boolean
|
||||||
var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
|
|
||||||
var bigPadding = activity.resources.getDimension(R.dimen.normal_margin).toInt()
|
private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
|
||||||
|
private var bigPadding = activity.resources.getDimension(R.dimen.normal_margin).toInt()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
initDrawables()
|
initDrawables()
|
||||||
|
@ -192,10 +193,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||||
view.apply {
|
view.apply {
|
||||||
contact_name.text = contact.getFullName(startNameWithSurname)
|
contact_name.text = contact.getFullName(startNameWithSurname)
|
||||||
contact_name.setTextColor(textColor)
|
contact_name.setTextColor(textColor)
|
||||||
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, 0, 0)
|
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
|
||||||
|
|
||||||
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
||||||
contact_number?.setTextColor(textColor)
|
contact_number?.setTextColor(textColor)
|
||||||
contact_number?.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, 0, 0)
|
contact_number?.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, smallPadding, 0)
|
||||||
|
|
||||||
contact_tmb.beVisibleIf(showContactThumbnails)
|
contact_tmb.beVisibleIf(showContactThumbnails)
|
||||||
|
|
||||||
if (showContactThumbnails) {
|
if (showContactThumbnails) {
|
||||||
|
|
|
@ -31,8 +31,12 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
||||||
private val textColor = config.textColor
|
private val textColor = config.textColor
|
||||||
private val contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person, textColor)
|
private val contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person, textColor)
|
||||||
private val startNameWithSurname = config.startNameWithSurname
|
private val startNameWithSurname = config.startNameWithSurname
|
||||||
|
private val showContactThumbnails = config.showContactThumbnails
|
||||||
private val itemLayout = if (config.showPhoneNumbers) R.layout.item_add_favorite_with_number else R.layout.item_add_favorite_without_number
|
private val itemLayout = if (config.showPhoneNumbers) R.layout.item_add_favorite_with_number else R.layout.item_add_favorite_without_number
|
||||||
|
|
||||||
|
private var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
|
||||||
|
private var bigPadding = activity.resources.getDimension(R.dimen.normal_margin).toInt()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
contacts.forEachIndexed { index, contact ->
|
contacts.forEachIndexed { index, contact ->
|
||||||
if (selectedContacts.contains(contact.id.toString())) {
|
if (selectedContacts.contains(contact.id.toString())) {
|
||||||
|
@ -76,7 +80,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val eventType = contacts[position]
|
val eventType = contacts[position]
|
||||||
itemViews.put(position, holder.bindView(eventType, startNameWithSurname, contactDrawable, config))
|
itemViews.put(position, holder.bindView(eventType, startNameWithSurname, contactDrawable, config, showContactThumbnails, smallPadding, bigPadding))
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
toggleItemSelection(selectedPositions.contains(position), position)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +88,8 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
||||||
|
|
||||||
class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val showCheckbox: Boolean,
|
class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val showCheckbox: Boolean,
|
||||||
val itemClick: ((Contact) -> Unit)?) : RecyclerView.ViewHolder(view) {
|
val itemClick: ((Contact) -> Unit)?) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(contact: Contact, startNameWithSurname: Boolean, contactDrawable: Drawable, config: Config): View {
|
fun bindView(contact: Contact, startNameWithSurname: Boolean, contactDrawable: Drawable, config: Config, showContactThumbnails: Boolean,
|
||||||
|
smallPadding: Int, bigPadding: Int): View {
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
contact_checkbox.beVisibleIf(showCheckbox)
|
contact_checkbox.beVisibleIf(showCheckbox)
|
||||||
contact_checkbox.setColors(config.textColor, context.getAdjustedPrimaryColor(), config.backgroundColor)
|
contact_checkbox.setColors(config.textColor, context.getAdjustedPrimaryColor(), config.backgroundColor)
|
||||||
|
@ -92,8 +97,12 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
||||||
|
|
||||||
contact_name.text = contact.getFullName(startNameWithSurname)
|
contact_name.text = contact.getFullName(startNameWithSurname)
|
||||||
contact_name.setTextColor(textColor)
|
contact_name.setTextColor(textColor)
|
||||||
|
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
|
||||||
|
|
||||||
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
||||||
contact_number?.setTextColor(textColor)
|
contact_number?.setTextColor(textColor)
|
||||||
|
contact_number?.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, smallPadding, 0)
|
||||||
|
|
||||||
contact_frame.setOnClickListener {
|
contact_frame.setOnClickListener {
|
||||||
if (itemClick != null) {
|
if (itemClick != null) {
|
||||||
itemClick.invoke(contact)
|
itemClick.invoke(contact)
|
||||||
|
@ -102,16 +111,19 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact.photoUri.isNotEmpty()) {
|
contact_tmb.beVisibleIf(showContactThumbnails)
|
||||||
val options = RequestOptions()
|
if (showContactThumbnails) {
|
||||||
.signature(ObjectKey(contact.photoUri))
|
if (contact.photoUri.isNotEmpty()) {
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
val options = RequestOptions()
|
||||||
.error(contactDrawable)
|
.signature(ObjectKey(contact.photoUri))
|
||||||
.centerCrop()
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.error(contactDrawable)
|
||||||
|
.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)
|
||||||
} else {
|
} else {
|
||||||
contact_tmb.setImageDrawable(contactDrawable)
|
contact_tmb.setImageDrawable(contactDrawable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/contact_holder"
|
android:id="@+id/contact_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/contact_item_height"
|
||||||
android:paddingRight="@dimen/normal_margin">
|
android:paddingRight="@dimen/normal_margin">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -41,22 +41,19 @@
|
||||||
android:id="@+id/contact_number"
|
android:id="@+id/contact_number"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignLeft="@+id/contact_name"
|
||||||
android:layout_below="@+id/contact_name"
|
android:layout_below="@+id/contact_name"
|
||||||
android:layout_toLeftOf="@+id/contact_checkbox"
|
android:layout_toLeftOf="@+id/contact_checkbox"
|
||||||
android:layout_toRightOf="@+id/contact_tmb"
|
android:layout_toRightOf="@+id/contact_tmb"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
|
||||||
android:paddingRight="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
tools:text="0123 456 789"/>
|
tools:text="0123 456 789"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
android:id="@+id/contact_checkbox"
|
android:id="@+id/contact_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/contact_item_height"
|
||||||
android:layout_alignBottom="@+id/contact_tmb"
|
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignTop="@+id/contact_tmb"
|
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center_vertical"/>
|
android:gravity="center_vertical"/>
|
||||||
|
|
||||||
|
|
|
@ -25,27 +25,20 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_name"
|
android:id="@+id/contact_name"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="@dimen/contact_item_height"
|
||||||
android:layout_alignBottom="@+id/contact_tmb"
|
|
||||||
android:layout_alignTop="@+id/contact_tmb"
|
|
||||||
android:layout_toLeftOf="@+id/contact_checkbox"
|
android:layout_toLeftOf="@+id/contact_checkbox"
|
||||||
android:layout_toRightOf="@+id/contact_tmb"
|
android:layout_toRightOf="@+id/contact_tmb"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
|
||||||
android:paddingRight="@dimen/small_margin"
|
|
||||||
android:paddingTop="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/bigger_text_size"
|
android:textSize="@dimen/bigger_text_size"
|
||||||
tools:text="John Doe"/>
|
tools:text="John Doe"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
android:id="@+id/contact_checkbox"
|
android:id="@+id/contact_checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/contact_item_height"
|
||||||
android:layout_alignBottom="@+id/contact_tmb"
|
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignTop="@+id/contact_tmb"
|
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center_vertical"/>
|
android:gravity="center_vertical"/>
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
android:layout_toRightOf="@+id/contact_tmb"
|
android:layout_toRightOf="@+id/contact_tmb"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
|
||||||
android:paddingTop="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
tools:text="John Doe"/>
|
tools:text="John Doe"/>
|
||||||
|
|
||||||
|
@ -44,7 +42,6 @@
|
||||||
android:layout_below="@+id/contact_name"
|
android:layout_below="@+id/contact_name"
|
||||||
android:layout_toRightOf="@+id/contact_tmb"
|
android:layout_toRightOf="@+id/contact_tmb"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/normal_text_size"
|
android:textSize="@dimen/normal_text_size"
|
||||||
tools:text="0123 456 789"/>
|
tools:text="0123 456 789"/>
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/small_margin"
|
|
||||||
android:paddingTop="@dimen/small_margin"
|
|
||||||
android:textSize="@dimen/bigger_text_size"
|
android:textSize="@dimen/bigger_text_size"
|
||||||
tools:text="John Doe"/>
|
tools:text="John Doe"/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue