migrate adapters to viewbinding
This commit is contained in:
parent
f962765108
commit
81ec7fc1de
|
@ -11,9 +11,9 @@ import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
|||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.databinding.ItemConferenceCallBinding
|
||||
import com.simplemobiletools.dialer.extensions.hasCapability
|
||||
import com.simplemobiletools.dialer.helpers.getCallContact
|
||||
import kotlinx.android.synthetic.main.item_conference_call.view.*
|
||||
|
||||
class ConferenceCallsAdapter(
|
||||
activity: SimpleActivity, recyclerView: MyRecyclerView, val data: ArrayList<Call>, itemClick: (Any) -> Unit
|
||||
|
@ -39,55 +39,63 @@ class ConferenceCallsAdapter(
|
|||
|
||||
override fun prepareActionMode(menu: Menu) {}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_conference_call, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return createViewHolder(ItemConferenceCallBinding.inflate(layoutInflater, parent, false).root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val call = data[position]
|
||||
holder.bindView(call, allowSingleClick = false, allowLongClick = false) { itemView, _ ->
|
||||
getCallContact(itemView.context, call) { callContact ->
|
||||
itemView.post {
|
||||
itemView.item_conference_call_name.text = callContact.name.ifEmpty { itemView.context.getString(R.string.unknown_caller) }
|
||||
SimpleContactsHelper(activity).loadContactImage(
|
||||
callContact.photoUri,
|
||||
itemView.item_conference_call_image,
|
||||
callContact.name,
|
||||
activity.getDrawable(R.drawable.ic_person_vector)
|
||||
)
|
||||
ItemConferenceCallBinding.bind(itemView).apply {
|
||||
getCallContact(itemView.context, call) { callContact ->
|
||||
root.post {
|
||||
itemConferenceCallName.text = callContact.name.ifEmpty { itemView.context.getString(R.string.unknown_caller) }
|
||||
SimpleContactsHelper(activity).loadContactImage(
|
||||
callContact.photoUri,
|
||||
itemConferenceCallImage,
|
||||
callContact.name,
|
||||
activity.getDrawable(R.drawable.ic_person_vector)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
val canSeparate = call.hasCapability(Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE)
|
||||
val canDisconnect = call.hasCapability(Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE)
|
||||
itemView.item_conference_call_split.isEnabled = canSeparate
|
||||
itemView.item_conference_call_split.alpha = if (canSeparate) 1.0f else LOWER_ALPHA
|
||||
itemView.item_conference_call_split.setOnClickListener {
|
||||
call.splitFromConference()
|
||||
data.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
if (data.size == 1) {
|
||||
activity.finish()
|
||||
|
||||
val canSeparate = call.hasCapability(Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE)
|
||||
val canDisconnect = call.hasCapability(Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE)
|
||||
itemConferenceCallSplit.isEnabled = canSeparate
|
||||
itemConferenceCallSplit.alpha = if (canSeparate) 1.0f else LOWER_ALPHA
|
||||
itemConferenceCallSplit.setOnClickListener {
|
||||
call.splitFromConference()
|
||||
data.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
if (data.size == 1) {
|
||||
activity.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
itemView.item_conference_call_split.setOnLongClickListener {
|
||||
if (!it.contentDescription.isNullOrEmpty()) {
|
||||
itemView.context.toast(it.contentDescription.toString())
|
||||
|
||||
itemConferenceCallSplit.setOnLongClickListener {
|
||||
if (!it.contentDescription.isNullOrEmpty()) {
|
||||
root.context.toast(it.contentDescription.toString())
|
||||
}
|
||||
true
|
||||
}
|
||||
true
|
||||
}
|
||||
itemView.item_conference_call_end.isEnabled = canDisconnect
|
||||
itemView.item_conference_call_end.alpha = if (canDisconnect) 1.0f else LOWER_ALPHA
|
||||
itemView.item_conference_call_end.setOnClickListener {
|
||||
call.disconnect()
|
||||
data.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
if (data.size == 1) {
|
||||
activity.finish()
|
||||
|
||||
itemConferenceCallEnd.isEnabled = canDisconnect
|
||||
itemConferenceCallEnd.alpha = if (canDisconnect) 1.0f else LOWER_ALPHA
|
||||
itemConferenceCallEnd.setOnClickListener {
|
||||
call.disconnect()
|
||||
data.removeAt(position)
|
||||
notifyItemRemoved(position)
|
||||
if (data.size == 1) {
|
||||
activity.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
itemView.item_conference_call_end.setOnLongClickListener {
|
||||
if (!it.contentDescription.isNullOrEmpty()) {
|
||||
itemView.context.toast(it.contentDescription.toString())
|
||||
|
||||
itemConferenceCallEnd.setOnLongClickListener {
|
||||
if (!it.contentDescription.isNullOrEmpty()) {
|
||||
root.context.toast(it.contentDescription.toString())
|
||||
}
|
||||
true
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
bindViewHolder(holder)
|
||||
|
@ -96,7 +104,9 @@ class ConferenceCallsAdapter(
|
|||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
Glide.with(activity).clear(holder.itemView.item_conference_call_image)
|
||||
ItemConferenceCallBinding.bind(holder.itemView).apply {
|
||||
Glide.with(activity).clear(itemConferenceCallImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,11 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
|||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.databinding.ItemContactWithoutNumberBinding
|
||||
import com.simplemobiletools.commons.databinding.ItemContactWithoutNumberGridBinding
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.FeatureLockedDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -128,11 +131,8 @@ class ContactsAdapter(
|
|||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val layout = when (viewType) {
|
||||
VIEW_TYPE_GRID -> R.layout.item_contact_without_number_grid
|
||||
else -> R.layout.item_contact_without_number
|
||||
}
|
||||
return createViewHolder(layout, parent)
|
||||
val binding = Binding.getByItemViewType(viewType).inflate(layoutInflater, parent, false)
|
||||
return createViewHolder(binding.root)
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
|
@ -142,7 +142,8 @@ class ContactsAdapter(
|
|||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val contact = contacts[position]
|
||||
holder.bindView(contact, true, allowLongClick) { itemView, layoutPosition ->
|
||||
setupView(itemView, contact, holder)
|
||||
val viewType = getItemViewType(position)
|
||||
setupView(Binding.getByItemViewType(viewType).bind(itemView), contact, holder)
|
||||
}
|
||||
bindViewHolder(holder)
|
||||
}
|
||||
|
@ -278,15 +279,17 @@ class ContactsAdapter(
|
|||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
Glide.with(activity).clear(holder.itemView.findViewById<ImageView>(R.id.item_contact_image))
|
||||
Binding.getByItemViewType(holder.itemViewType).bind(holder.itemView).apply {
|
||||
Glide.with(activity).clear(itemContactImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupView(view: View, contact: Contact, holder: ViewHolder) {
|
||||
view.apply {
|
||||
setupViewBackground(activity)
|
||||
findViewById<ConstraintLayout>(R.id.item_contact_frame).isSelected = selectedKeys.contains(contact.rawId)
|
||||
findViewById<TextView>(R.id.item_contact_name).apply {
|
||||
private fun setupView(binding: ItemViewBinding, contact: Contact, holder: ViewHolder) {
|
||||
binding.apply {
|
||||
root.setupViewBackground(activity)
|
||||
itemContactFrame.isSelected = selectedKeys.contains(contact.rawId)
|
||||
itemContactName.apply {
|
||||
setTextColor(textColor)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||
|
||||
|
@ -300,9 +303,8 @@ class ContactsAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
val dragIcon = findViewById<ImageView>(R.id.drag_handle_icon)
|
||||
if (enableDrag && textToHighlight.isEmpty()) {
|
||||
dragIcon.apply {
|
||||
dragHandleIcon.apply {
|
||||
beVisibleIf(selectedKeys.isNotEmpty())
|
||||
applyColorFilter(textColor)
|
||||
setOnTouchListener { _, event ->
|
||||
|
@ -313,14 +315,14 @@ class ContactsAdapter(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
dragIcon.apply {
|
||||
dragHandleIcon.apply {
|
||||
beGone()
|
||||
setOnTouchListener(null)
|
||||
}
|
||||
}
|
||||
|
||||
if (!activity.isDestroyed) {
|
||||
SimpleContactsHelper(context).loadContactImage(contact.photoUri, findViewById(R.id.item_contact_image), contact.getNameToDisplay())
|
||||
SimpleContactsHelper(root.context).loadContactImage(contact.photoUri, itemContactImage, contact.getNameToDisplay())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,4 +371,63 @@ class ContactsAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private sealed interface Binding {
|
||||
companion object {
|
||||
fun getByItemViewType(viewType: Int): Binding {
|
||||
return when (viewType) {
|
||||
VIEW_TYPE_GRID -> ItemContactGrid
|
||||
else -> ItemContact
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding
|
||||
|
||||
fun bind(view: View): ItemViewBinding
|
||||
|
||||
data object ItemContactGrid : Binding {
|
||||
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||
return ItemContactGridBindingAdapter(ItemContactWithoutNumberGridBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||
}
|
||||
|
||||
override fun bind(view: View): ItemViewBinding {
|
||||
return ItemContactGridBindingAdapter(ItemContactWithoutNumberGridBinding.bind(view))
|
||||
}
|
||||
}
|
||||
|
||||
data object ItemContact : Binding {
|
||||
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||
return ItemContactBindingAdapter(ItemContactWithoutNumberBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||
}
|
||||
|
||||
override fun bind(view: View): ItemViewBinding {
|
||||
return ItemContactBindingAdapter(ItemContactWithoutNumberBinding.bind(view))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private interface ItemViewBinding : ViewBinding {
|
||||
val itemContactName: TextView
|
||||
val itemContactImage: ImageView
|
||||
val itemContactFrame: ConstraintLayout
|
||||
val dragHandleIcon: ImageView
|
||||
}
|
||||
|
||||
private class ItemContactGridBindingAdapter(val binding: ItemContactWithoutNumberGridBinding) : ItemViewBinding {
|
||||
override val itemContactName = binding.itemContactName
|
||||
override val itemContactImage = binding.itemContactImage
|
||||
override val itemContactFrame = binding.itemContactFrame
|
||||
override val dragHandleIcon = binding.dragHandleIcon
|
||||
|
||||
override fun getRoot(): View = binding.root
|
||||
}
|
||||
|
||||
private class ItemContactBindingAdapter(val binding: ItemContactWithoutNumberBinding) : ItemViewBinding {
|
||||
override val itemContactName = binding.itemContactName
|
||||
override val itemContactImage = binding.itemContactImage
|
||||
override val itemContactFrame = binding.itemContactFrame
|
||||
override val dragHandleIcon = binding.dragHandleIcon
|
||||
|
||||
override fun getRoot(): View = binding.root
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,8 @@ import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
|||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
|
||||
import com.simplemobiletools.commons.models.contacts.ContactSource
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import kotlinx.android.synthetic.main.item_filter_contact_source.view.*
|
||||
import com.simplemobiletools.dialer.databinding.ItemFilterContactSourceBinding
|
||||
|
||||
class FilterContactSourcesAdapter(
|
||||
val activity: SimpleActivity,
|
||||
|
@ -45,8 +44,8 @@ class FilterContactSourcesAdapter(
|
|||
fun getSelectedContactSources() = contactSources.filter { selectedKeys.contains(it.hashCode()) }
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = activity.layoutInflater.inflate(R.layout.item_filter_contact_source, parent, false)
|
||||
return ViewHolder(view)
|
||||
val binding = ItemFilterContactSourceBinding.inflate(activity.layoutInflater, parent, false)
|
||||
return ViewHolder(binding.root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
|
@ -59,16 +58,16 @@ class FilterContactSourcesAdapter(
|
|||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
fun bindView(contactSource: ContactSource): View {
|
||||
val isSelected = selectedKeys.contains(contactSource.hashCode())
|
||||
itemView.apply {
|
||||
filter_contact_source_checkbox.isChecked = isSelected
|
||||
filter_contact_source_checkbox.setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
|
||||
ItemFilterContactSourceBinding.bind(itemView).apply {
|
||||
filterContactSourceCheckbox.isChecked = isSelected
|
||||
filterContactSourceCheckbox.setColors(activity.getProperTextColor(), activity.getProperPrimaryColor(), activity.getProperBackgroundColor())
|
||||
val countText = if (contactSource.count >= 0) " (${contactSource.count})" else ""
|
||||
val displayName = "${contactSource.publicName}$countText"
|
||||
filter_contact_source_checkbox.text = displayName
|
||||
filter_contact_source_holder.setOnClickListener { viewClicked(!isSelected, contactSource) }
|
||||
}
|
||||
filterContactSourceCheckbox.text = displayName
|
||||
filterContactSourceHolder.setOnClickListener { viewClicked(!isSelected, contactSource) }
|
||||
|
||||
return itemView
|
||||
return root
|
||||
}
|
||||
}
|
||||
|
||||
private fun viewClicked(select: Boolean, contactSource: ContactSource) {
|
||||
|
|
|
@ -19,12 +19,12 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.MainActivity
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.databinding.ItemRecentCallBinding
|
||||
import com.simplemobiletools.dialer.dialogs.ShowGroupedCallsDialog
|
||||
import com.simplemobiletools.dialer.extensions.*
|
||||
import com.simplemobiletools.dialer.helpers.RecentsHelper
|
||||
import com.simplemobiletools.dialer.interfaces.RefreshItemsListener
|
||||
import com.simplemobiletools.dialer.models.RecentCall
|
||||
import kotlinx.android.synthetic.main.item_recent_call.view.*
|
||||
|
||||
class RecentCallsAdapter(
|
||||
activity: SimpleActivity,
|
||||
|
@ -103,7 +103,9 @@ class RecentCallsAdapter(
|
|||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_recent_call, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return createViewHolder(ItemRecentCallBinding.inflate(layoutInflater, parent, false).root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val recentCall = recentCalls[position]
|
||||
|
@ -112,7 +114,8 @@ class RecentCallsAdapter(
|
|||
allowSingleClick = refreshItemsListener != null && !recentCall.isUnknownNumber,
|
||||
allowLongClick = refreshItemsListener != null && !recentCall.isUnknownNumber
|
||||
) { itemView, _ ->
|
||||
setupView(itemView, recentCall)
|
||||
val binding = ItemRecentCallBinding.bind(itemView)
|
||||
setupView(binding, recentCall)
|
||||
}
|
||||
bindViewHolder(holder)
|
||||
}
|
||||
|
@ -122,7 +125,9 @@ class RecentCallsAdapter(
|
|||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||
Glide.with(activity).clear(holder.itemView.item_recents_image)
|
||||
ItemRecentCallBinding.bind(holder.itemView).apply {
|
||||
Glide.with(activity).clear(itemRecentsImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,10 +282,10 @@ class RecentCallsAdapter(
|
|||
|
||||
private fun getSelectedPhoneNumber() = getSelectedItems().firstOrNull()?.phoneNumber
|
||||
|
||||
private fun setupView(view: View, call: RecentCall) {
|
||||
view.apply {
|
||||
private fun setupView(binding: ItemRecentCallBinding, call: RecentCall) {
|
||||
binding.apply {
|
||||
val currentFontSize = fontSize
|
||||
item_recents_holder.isSelected = selectedKeys.contains(call.id)
|
||||
itemRecentsHolder.isSelected = selectedKeys.contains(call.id)
|
||||
val name = findContactByCall(call)?.getNameToDisplay() ?: call.name
|
||||
var nameToShow = SpannableString(name)
|
||||
if (call.specificType.isNotEmpty()) {
|
||||
|
@ -300,37 +305,37 @@ class RecentCallsAdapter(
|
|||
nameToShow = SpannableString(nameToShow.toString().highlightTextPart(textToHighlight, properPrimaryColor))
|
||||
}
|
||||
|
||||
item_recents_name.apply {
|
||||
itemRecentsName.apply {
|
||||
text = nameToShow
|
||||
setTextColor(textColor)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, currentFontSize)
|
||||
}
|
||||
|
||||
item_recents_date_time.apply {
|
||||
itemRecentsDateTime.apply {
|
||||
text = call.startTS.formatDateOrTime(context, refreshItemsListener != null, false)
|
||||
setTextColor(if (call.type == Calls.MISSED_TYPE) redColor else textColor)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, currentFontSize * 0.8f)
|
||||
}
|
||||
|
||||
item_recents_duration.apply {
|
||||
itemRecentsDuration.apply {
|
||||
text = call.duration.getFormattedDuration()
|
||||
setTextColor(textColor)
|
||||
beVisibleIf(call.type != Calls.MISSED_TYPE && call.type != Calls.REJECTED_TYPE && call.duration > 0)
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_PX, currentFontSize * 0.8f)
|
||||
if (!showOverflowMenu) {
|
||||
item_recents_duration.setPadding(0, 0, durationPadding, 0)
|
||||
itemRecentsDuration.setPadding(0, 0, durationPadding, 0)
|
||||
}
|
||||
}
|
||||
|
||||
item_recents_sim_image.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
|
||||
item_recents_sim_id.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
|
||||
itemRecentsSimImage.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
|
||||
itemRecentsSimId.beVisibleIf(areMultipleSIMsAvailable && call.simID != -1)
|
||||
if (areMultipleSIMsAvailable && call.simID != -1) {
|
||||
item_recents_sim_image.applyColorFilter(textColor)
|
||||
item_recents_sim_id.setTextColor(textColor.getContrastColor())
|
||||
item_recents_sim_id.text = call.simID.toString()
|
||||
itemRecentsSimImage.applyColorFilter(textColor)
|
||||
itemRecentsSimId.setTextColor(textColor.getContrastColor())
|
||||
itemRecentsSimId.text = call.simID.toString()
|
||||
}
|
||||
|
||||
SimpleContactsHelper(context).loadContactImage(call.photoUri, item_recents_image, call.name)
|
||||
SimpleContactsHelper(root.context).loadContactImage(call.photoUri, itemRecentsImage, call.name)
|
||||
|
||||
val drawable = when (call.type) {
|
||||
Calls.OUTGOING_TYPE -> outgoingCallIcon
|
||||
|
@ -338,15 +343,15 @@ class RecentCallsAdapter(
|
|||
else -> incomingCallIcon
|
||||
}
|
||||
|
||||
item_recents_type.setImageDrawable(drawable)
|
||||
itemRecentsType.setImageDrawable(drawable)
|
||||
|
||||
overflow_menu_icon.beVisibleIf(showOverflowMenu)
|
||||
overflow_menu_icon.drawable.apply {
|
||||
overflowMenuIcon.beVisibleIf(showOverflowMenu)
|
||||
overflowMenuIcon.drawable.apply {
|
||||
mutate()
|
||||
setTint(activity.getProperTextColor())
|
||||
}
|
||||
overflow_menu_icon.setOnClickListener {
|
||||
showPopupMenu(overflow_menu_anchor, call)
|
||||
overflowMenuIcon.setOnClickListener {
|
||||
showPopupMenu(overflowMenuAnchor, call)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package com.simplemobiletools.dialer.adapters
|
||||
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
import com.simplemobiletools.dialer.R
|
||||
import com.simplemobiletools.dialer.activities.SimpleActivity
|
||||
import com.simplemobiletools.dialer.databinding.ItemSpeedDialBinding
|
||||
import com.simplemobiletools.dialer.interfaces.RemoveSpeedDialListener
|
||||
import com.simplemobiletools.dialer.models.SpeedDial
|
||||
import kotlinx.android.synthetic.main.item_speed_dial.view.speed_dial_label
|
||||
|
||||
class SpeedDialAdapter(
|
||||
activity: SimpleActivity, var speedDialValues: List<SpeedDial>, private val removeListener: RemoveSpeedDialListener,
|
||||
|
@ -45,12 +44,15 @@ class SpeedDialAdapter(
|
|||
|
||||
override fun onActionModeDestroyed() {}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_speed_dial, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return createViewHolder(ItemSpeedDialBinding.inflate(layoutInflater, parent, false).root)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val speedDial = speedDialValues[position]
|
||||
holder.bindView(speedDial, true, true) { itemView, layoutPosition ->
|
||||
setupView(itemView, speedDial)
|
||||
val binding = ItemSpeedDialBinding.bind(itemView)
|
||||
setupView(binding, speedDial)
|
||||
}
|
||||
bindViewHolder(holder)
|
||||
}
|
||||
|
@ -65,12 +67,12 @@ class SpeedDialAdapter(
|
|||
finishActMode()
|
||||
}
|
||||
|
||||
private fun setupView(view: View, speedDial: SpeedDial) {
|
||||
view.apply {
|
||||
private fun setupView(binding: ItemSpeedDialBinding, speedDial: SpeedDial) {
|
||||
binding.apply {
|
||||
var displayName = "${speedDial.id}. "
|
||||
displayName += if (speedDial.isValid()) speedDial.displayName else ""
|
||||
|
||||
speed_dial_label.apply {
|
||||
speedDialLabel.apply {
|
||||
text = displayName
|
||||
isSelected = selectedKeys.contains(speedDial.hashCode())
|
||||
setTextColor(textColor)
|
||||
|
|
|
@ -19,7 +19,7 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
|
|||
val view = activity.layoutInflater.inflate(layout, container, false)
|
||||
container.addView(view)
|
||||
|
||||
(view as MyViewPagerFragment).apply {
|
||||
(view as MyViewPagerFragment<*>).apply {
|
||||
setupFragment(activity)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue