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) :
|
||||
MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||
|
||||
lateinit private var contactDrawable: Drawable
|
||||
private lateinit var contactDrawable: Drawable
|
||||
var config = activity.config
|
||||
var startNameWithSurname: Boolean
|
||||
var showContactThumbnails: 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 {
|
||||
initDrawables()
|
||||
|
@ -192,10 +193,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||
view.apply {
|
||||
contact_name.text = contact.getFullName(startNameWithSurname)
|
||||
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?.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)
|
||||
|
||||
if (showContactThumbnails) {
|
||||
|
|
|
@ -31,8 +31,12 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
|||
private val textColor = config.textColor
|
||||
private val contactDrawable = activity.resources.getColoredDrawableWithColor(R.drawable.ic_person, textColor)
|
||||
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 var smallPadding = activity.resources.getDimension(R.dimen.small_margin).toInt()
|
||||
private var bigPadding = activity.resources.getDimension(R.dimen.normal_margin).toInt()
|
||||
|
||||
init {
|
||||
contacts.forEachIndexed { index, contact ->
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
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 {
|
||||
contact_checkbox.beVisibleIf(showCheckbox)
|
||||
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.setTextColor(textColor)
|
||||
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
|
||||
|
||||
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
||||
contact_number?.setTextColor(textColor)
|
||||
contact_number?.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, smallPadding, 0)
|
||||
|
||||
contact_frame.setOnClickListener {
|
||||
if (itemClick != null) {
|
||||
itemClick.invoke(contact)
|
||||
|
@ -102,6 +111,8 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
|||
}
|
||||
}
|
||||
|
||||
contact_tmb.beVisibleIf(showContactThumbnails)
|
||||
if (showContactThumbnails) {
|
||||
if (contact.photoUri.isNotEmpty()) {
|
||||
val options = RequestOptions()
|
||||
.signature(ObjectKey(contact.photoUri))
|
||||
|
@ -114,6 +125,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, val contacts: List<Con
|
|||
contact_tmb.setImageDrawable(contactDrawable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemView
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<RelativeLayout
|
||||
android:id="@+id/contact_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="@dimen/contact_item_height"
|
||||
android:paddingRight="@dimen/normal_margin">
|
||||
|
||||
<ImageView
|
||||
|
@ -41,22 +41,19 @@
|
|||
android:id="@+id/contact_number"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/contact_name"
|
||||
android:layout_below="@+id/contact_name"
|
||||
android:layout_toLeftOf="@+id/contact_checkbox"
|
||||
android:layout_toRightOf="@+id/contact_tmb"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="0123 456 789"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/contact_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/contact_tmb"
|
||||
android:layout_height="@dimen/contact_item_height"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/contact_tmb"
|
||||
android:clickable="false"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
|
|
|
@ -25,27 +25,20 @@
|
|||
<TextView
|
||||
android:id="@+id/contact_name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@+id/contact_tmb"
|
||||
android:layout_alignTop="@+id/contact_tmb"
|
||||
android:layout_height="@dimen/contact_item_height"
|
||||
android:layout_toLeftOf="@+id/contact_checkbox"
|
||||
android:layout_toRightOf="@+id/contact_tmb"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="John Doe"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/contact_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/contact_tmb"
|
||||
android:layout_height="@dimen/contact_item_height"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/contact_tmb"
|
||||
android:clickable="false"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
android:layout_toRightOf="@+id/contact_tmb"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="John Doe"/>
|
||||
|
||||
|
@ -44,7 +42,6 @@
|
|||
android:layout_below="@+id/contact_name"
|
||||
android:layout_toRightOf="@+id/contact_tmb"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="0123 456 789"/>
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
tools:text="John Doe"/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue