mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 04:59:34 +01:00
Fix up adapter & coloring of the X button
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
00abcd9c48
commit
e88b49b506
@ -91,7 +91,7 @@ open class ContactPresenter<T : Any>(context: Context, onElementClick: ((Page, H
|
||||
holder.itemView.participantNameTextView.text = context.getString(R.string.nc_guest)
|
||||
}
|
||||
|
||||
holder.itemView.clearImageView?.load(Images().getImageWithBackground(context, R.drawable.ic_baseline_clear_24, R.color.white))
|
||||
holder.itemView.clearImageView?.load(Images().getImageWithBackground(context, R.drawable.ic_baseline_clear_24, R.color.bg_selected_participant_clear_icon, R.color.white))
|
||||
|
||||
when (participant?.source) {
|
||||
"users" -> {
|
||||
|
@ -96,6 +96,38 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
||||
selectedParticipantsRecyclerView.initRecyclerView(LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false), selectedParticipantsAdapter, true)
|
||||
}
|
||||
|
||||
selectedParticipantsAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onChanged() {
|
||||
super.onChanged()
|
||||
toggleSelectedParticipantsViewVisibility()
|
||||
}
|
||||
|
||||
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
||||
super.onItemRangeRemoved(positionStart, itemCount)
|
||||
toggleSelectedParticipantsViewVisibility()
|
||||
}
|
||||
|
||||
override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) {
|
||||
super.onItemRangeMoved(fromPosition, toPosition, itemCount)
|
||||
toggleSelectedParticipantsViewVisibility()
|
||||
}
|
||||
|
||||
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||
super.onItemRangeInserted(positionStart, itemCount)
|
||||
toggleSelectedParticipantsViewVisibility()
|
||||
}
|
||||
|
||||
override fun onItemRangeChanged(positionStart: Int, itemCount: Int) {
|
||||
super.onItemRangeChanged(positionStart, itemCount)
|
||||
toggleSelectedParticipantsViewVisibility()
|
||||
}
|
||||
|
||||
override fun onItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?) {
|
||||
super.onItemRangeChanged(positionStart, itemCount, payload)
|
||||
toggleSelectedParticipantsViewVisibility()
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.apply {
|
||||
selectedParticipantsLiveData.observe(this@ContactsView) { participants ->
|
||||
view.selectedParticipantsRecyclerView.isVisible = participants.isNotEmpty()
|
||||
@ -110,6 +142,11 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
||||
return view
|
||||
}
|
||||
|
||||
private fun toggleSelectedParticipantsViewVisibility() {
|
||||
view?.selectedParticipantsRecyclerView?.isVisible = selectedParticipantsAdapter.itemCount > 0
|
||||
view?.divider?.isVisible = selectedParticipantsAdapter.itemCount > 0
|
||||
}
|
||||
|
||||
private fun onElementClick(page: Page, holder: Presenter.Holder, element: Element<T>) {
|
||||
if (element.data is Participant?) {
|
||||
val participant = element.data as Participant?
|
||||
@ -121,7 +158,11 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
||||
viewModel.selectParticipant(it)
|
||||
}
|
||||
it.selected = !isElementSelected
|
||||
participantsAdapter.notifyItemChanged(holder.adapterPosition, ElementPayload.SELECTION_TOGGLE)
|
||||
if (element.type == ParticipantElementType.PARTICIPANT_SELECTED.ordinal) {
|
||||
participantsAdapter.notifyItemRangeChanged(0, participantsAdapter.itemCount, ElementPayload.SELECTION_TOGGLE)
|
||||
} else {
|
||||
participantsAdapter.notifyItemChanged(holder.adapterPosition, ElementPayload.SELECTION_TOGGLE)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -70,9 +70,9 @@ class Images {
|
||||
}
|
||||
}
|
||||
|
||||
fun getImageWithBackground(context: Context, drawableId: Int, foregroundColorTint: Int? = null): Bitmap {
|
||||
fun getImageWithBackground(context: Context, drawableId: Int, backgroundDrawableId: Int = R.color.bg_message_list_incoming_bubble, foregroundColorTint: Int? = null): Bitmap {
|
||||
val layers = arrayOfNulls<Drawable>(2)
|
||||
layers[0] = context.getDrawable(R.color.bg_message_list_incoming_bubble)
|
||||
layers[0] = context.getDrawable(backgroundDrawableId)
|
||||
var scale = 0.25f
|
||||
if (drawableId == R.drawable.ic_baseline_email_24 || drawableId == R.drawable.ic_link_white_24px) {
|
||||
scale = 0.5f
|
||||
|
@ -64,6 +64,7 @@
|
||||
<color name="bg_dark_mention_chips">#333333</color>
|
||||
|
||||
|
||||
<color name="bg_selected_participant_clear_icon">#484848</color>
|
||||
<color name="bg_message_list_incoming_bubble">#EFEFEF</color>
|
||||
<color name="bg_message_list_outcoming_bubble">@color/colorPrimary</color>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user