Quick & dirty avatar display (to be removed)
This commit is contained in:
parent
536d7c33fe
commit
ea51420c74
|
@ -0,0 +1,7 @@
|
||||||
|
package im.vector.riotredesign.core.glide;
|
||||||
|
|
||||||
|
import com.bumptech.glide.annotation.GlideModule;
|
||||||
|
import com.bumptech.glide.module.AppGlideModule;
|
||||||
|
|
||||||
|
@GlideModule
|
||||||
|
public final class MyAppGlideModule extends AppGlideModule {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package im.vector.riotredesign.core.utils
|
||||||
|
|
||||||
|
object Constants {
|
||||||
|
|
||||||
|
const val MEDIA_URL = "https://matrix.org/_matrix/media/v1/download/"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -7,14 +7,17 @@ import android.support.v7.widget.LinearLayoutManager
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import im.vector.matrix.android.api.Matrix
|
import im.vector.matrix.android.api.Matrix
|
||||||
import im.vector.matrix.android.api.session.events.model.EnrichedEvent
|
import im.vector.matrix.android.api.session.events.model.EnrichedEvent
|
||||||
import im.vector.matrix.android.api.session.room.Room
|
import im.vector.matrix.android.api.session.room.Room
|
||||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.extensions.avatarDrawable
|
import im.vector.riotredesign.core.extensions.avatarDrawable
|
||||||
|
import im.vector.riotredesign.core.glide.GlideApp
|
||||||
import im.vector.riotredesign.core.platform.RiotFragment
|
import im.vector.riotredesign.core.platform.RiotFragment
|
||||||
import im.vector.riotredesign.core.platform.ToolbarConfigurable
|
import im.vector.riotredesign.core.platform.ToolbarConfigurable
|
||||||
|
import im.vector.riotredesign.core.utils.Constants
|
||||||
import im.vector.riotredesign.core.utils.FragmentArgumentDelegate
|
import im.vector.riotredesign.core.utils.FragmentArgumentDelegate
|
||||||
import kotlinx.android.synthetic.main.fragment_room_detail.*
|
import kotlinx.android.synthetic.main.fragment_room_detail.*
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
|
@ -67,6 +70,14 @@ class RoomDetailFragment : RiotFragment() {
|
||||||
private fun renderRoomSummary(roomSummary: RoomSummary?) {
|
private fun renderRoomSummary(roomSummary: RoomSummary?) {
|
||||||
roomSummary?.let {
|
roomSummary?.let {
|
||||||
toolbarTitleView.text = it.displayName
|
toolbarTitleView.text = it.displayName
|
||||||
|
val avatarUrl = it.avatarUrl.replace("mxc://", Constants.MEDIA_URL)
|
||||||
|
GlideApp
|
||||||
|
.with(this)
|
||||||
|
.load(avatarUrl)
|
||||||
|
.placeholder(riotActivity.avatarDrawable(it.displayName))
|
||||||
|
.apply(RequestOptions.circleCropTransform())
|
||||||
|
.into(toolbarAvatarImageView)
|
||||||
|
|
||||||
toolbarAvatarImageView.setImageDrawable(riotActivity.avatarDrawable(it.displayName))
|
toolbarAvatarImageView.setImageDrawable(riotActivity.avatarDrawable(it.displayName))
|
||||||
if (it.topic.isNotEmpty()) {
|
if (it.topic.isNotEmpty()) {
|
||||||
toolbarSubtitleView.visibility = View.VISIBLE
|
toolbarSubtitleView.visibility = View.VISIBLE
|
||||||
|
|
|
@ -10,6 +10,7 @@ import im.vector.matrix.android.api.session.events.model.roomMember
|
||||||
import im.vector.matrix.android.api.session.room.model.MessageContent
|
import im.vector.matrix.android.api.session.room.model.MessageContent
|
||||||
import im.vector.riotredesign.core.extensions.avatarDrawable
|
import im.vector.riotredesign.core.extensions.avatarDrawable
|
||||||
import im.vector.riotredesign.core.extensions.localDateTime
|
import im.vector.riotredesign.core.extensions.localDateTime
|
||||||
|
import im.vector.riotredesign.core.utils.Constants
|
||||||
import im.vector.riotredesign.features.home.LoadingItemModel_
|
import im.vector.riotredesign.features.home.LoadingItemModel_
|
||||||
import org.threeten.bp.format.DateTimeFormatter
|
import org.threeten.bp.format.DateTimeFormatter
|
||||||
import org.threeten.bp.format.FormatStyle
|
import org.threeten.bp.format.FormatStyle
|
||||||
|
@ -71,12 +72,16 @@ class TimelineEventController(private val context: Context) : EpoxyController(
|
||||||
}
|
}
|
||||||
val showInformation = messagesDisplayedWithInformation.contains(event.root.eventId)
|
val showInformation = messagesDisplayedWithInformation.contains(event.root.eventId)
|
||||||
|
|
||||||
val avatarDrawable = context.avatarDrawable(roomMember.displayName ?: "")
|
|
||||||
|
val avatarUrl = roomMember.avatarUrl?.replace("mxc://", Constants.MEDIA_URL) ?: ""
|
||||||
|
|
||||||
TimelineMessageItem(
|
TimelineMessageItem(
|
||||||
message = messageContent.body,
|
message = messageContent.body,
|
||||||
|
avatarUrl = avatarUrl,
|
||||||
showInformation = showInformation,
|
showInformation = showInformation,
|
||||||
time = date.toLocalTime().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)),
|
time = date.toLocalTime().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)),
|
||||||
avatarDrawable = avatarDrawable,
|
fallbackAvatarDrawable = context.avatarDrawable(roomMember.displayName
|
||||||
|
?: ""),
|
||||||
memberName = roomMember.displayName
|
memberName = roomMember.displayName
|
||||||
)
|
)
|
||||||
.onBind { timeline?.loadAround(index) }
|
.onBind { timeline?.loadAround(index) }
|
||||||
|
|
|
@ -4,13 +4,16 @@ import android.graphics.drawable.Drawable
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.epoxy.KotlinModel
|
import im.vector.riotredesign.core.epoxy.KotlinModel
|
||||||
|
import im.vector.riotredesign.core.glide.GlideApp
|
||||||
|
|
||||||
data class TimelineMessageItem(
|
data class TimelineMessageItem(
|
||||||
val message: CharSequence? = null,
|
val message: CharSequence? = null,
|
||||||
val time: CharSequence? = null,
|
val time: CharSequence? = null,
|
||||||
val avatarDrawable: Drawable? = null,
|
val avatarUrl: String,
|
||||||
|
val fallbackAvatarDrawable: Drawable? = null,
|
||||||
val memberName: CharSequence? = null,
|
val memberName: CharSequence? = null,
|
||||||
val showInformation: Boolean = true
|
val showInformation: Boolean = true
|
||||||
) : KotlinModel(R.layout.item_event_message) {
|
) : KotlinModel(R.layout.item_event_message) {
|
||||||
|
@ -27,7 +30,13 @@ data class TimelineMessageItem(
|
||||||
memberNameView.visibility = View.VISIBLE
|
memberNameView.visibility = View.VISIBLE
|
||||||
timeView.visibility = View.VISIBLE
|
timeView.visibility = View.VISIBLE
|
||||||
|
|
||||||
avatarImageView.setImageDrawable(avatarDrawable)
|
GlideApp
|
||||||
|
.with(avatarImageView)
|
||||||
|
.load(avatarUrl)
|
||||||
|
.placeholder(fallbackAvatarDrawable)
|
||||||
|
.apply(RequestOptions.circleCropTransform())
|
||||||
|
.into(avatarImageView)
|
||||||
|
|
||||||
timeView.text = time
|
timeView.text = time
|
||||||
memberNameView.text = memberName
|
memberNameView.text = memberName
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import com.airbnb.epoxy.Typed2EpoxyController
|
import com.airbnb.epoxy.Typed2EpoxyController
|
||||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
||||||
import im.vector.riotredesign.core.extensions.avatarDrawable
|
import im.vector.riotredesign.core.extensions.avatarDrawable
|
||||||
|
import im.vector.riotredesign.core.utils.Constants
|
||||||
|
|
||||||
class RoomSummaryController(private val context: Context,
|
class RoomSummaryController(private val context: Context,
|
||||||
private val callback: Callback? = null
|
private val callback: Callback? = null
|
||||||
|
@ -51,10 +52,14 @@ class RoomSummaryController(private val context: Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildRoomModels(summaries: List<RoomSummary>, selected: RoomSummary?) {
|
private fun buildRoomModels(summaries: List<RoomSummary>, selected: RoomSummary?) {
|
||||||
|
|
||||||
summaries.forEach {
|
summaries.forEach {
|
||||||
|
val avatarUrl = it.avatarUrl.replace("mxc://", Constants.MEDIA_URL)
|
||||||
|
|
||||||
RoomSummaryItem(
|
RoomSummaryItem(
|
||||||
title = it.displayName,
|
title = it.displayName,
|
||||||
avatarDrawable = context.avatarDrawable(it.displayName),
|
avatarUrl = avatarUrl,
|
||||||
|
fallbackAvatarDrawable = context.avatarDrawable(it.displayName),
|
||||||
isSelected = it.roomId == selected?.roomId,
|
isSelected = it.roomId == selected?.roomId,
|
||||||
listener = { callback?.onRoomSelected(it) }
|
listener = { callback?.onRoomSelected(it) }
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,14 +3,17 @@ package im.vector.riotredesign.features.home.room.list
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import im.vector.riotredesign.R
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.epoxy.KotlinModel
|
import im.vector.riotredesign.core.epoxy.KotlinModel
|
||||||
|
import im.vector.riotredesign.core.glide.GlideApp
|
||||||
import im.vector.riotredesign.core.platform.CheckableFrameLayout
|
import im.vector.riotredesign.core.platform.CheckableFrameLayout
|
||||||
|
|
||||||
|
|
||||||
data class RoomSummaryItem(
|
data class RoomSummaryItem(
|
||||||
val title: CharSequence,
|
val title: CharSequence,
|
||||||
val avatarDrawable: Drawable,
|
val avatarUrl: String,
|
||||||
|
val fallbackAvatarDrawable: Drawable,
|
||||||
val isSelected: Boolean,
|
val isSelected: Boolean,
|
||||||
val listener: (() -> Unit)? = null
|
val listener: (() -> Unit)? = null
|
||||||
) : KotlinModel(R.layout.item_room) {
|
) : KotlinModel(R.layout.item_room) {
|
||||||
|
@ -23,6 +26,11 @@ data class RoomSummaryItem(
|
||||||
rootView.isChecked = isSelected
|
rootView.isChecked = isSelected
|
||||||
rootView.setOnClickListener { listener?.invoke() }
|
rootView.setOnClickListener { listener?.invoke() }
|
||||||
titleView.text = title
|
titleView.text = title
|
||||||
avatarImageView.setImageDrawable(avatarDrawable)
|
GlideApp
|
||||||
|
.with(avatarImageView)
|
||||||
|
.load(avatarUrl)
|
||||||
|
.placeholder(fallbackAvatarDrawable)
|
||||||
|
.apply(RequestOptions.circleCropTransform())
|
||||||
|
.into(avatarImageView)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue