forked from GitHub-Mirror/riotX-android
Add blank item to use pagedlist load around method
This commit is contained in:
parent
6d9907563e
commit
eda88030a3
@ -1,19 +0,0 @@
|
|||||||
package im.vector.riotredesign.features.home
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.support.v4.content.ContextCompat
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
|
||||||
import im.vector.matrix.android.api.session.room.model.RoomSummary
|
|
||||||
import im.vector.riotredesign.R
|
|
||||||
import im.vector.riotredesign.core.extensions.firstCharAsString
|
|
||||||
|
|
||||||
class RoomSummaryViewHelper(private val roomSummary: RoomSummary) {
|
|
||||||
|
|
||||||
fun avatarDrawable(context: Context): Drawable {
|
|
||||||
val avatarColor = ContextCompat.getColor(context, R.color.pale_teal)
|
|
||||||
return TextDrawable.builder().buildRound(roomSummary.displayName.firstCharAsString().toUpperCase(), avatarColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
package im.vector.riotredesign.features.home.room.detail
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import com.airbnb.epoxy.ModelView
|
||||||
|
|
||||||
|
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
|
||||||
|
class BlankItem(context: Context) : FrameLayout(context)
|
@ -53,6 +53,10 @@ class TimelineEventController(private val context: Context) : EpoxyController(
|
|||||||
val event = data[index]
|
val event = data[index]
|
||||||
val nextEvent = if (index + 1 < data.size) data[index + 1] else null
|
val nextEvent = if (index + 1 < data.size) data[index + 1] else null
|
||||||
|
|
||||||
|
val date = event.root.localDateTime()
|
||||||
|
val nextDate = nextEvent?.root?.localDateTime()
|
||||||
|
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
|
||||||
|
|
||||||
if (event.root.type == EventType.MESSAGE) {
|
if (event.root.type == EventType.MESSAGE) {
|
||||||
val messageContent = event.root.content<MessageContent>()
|
val messageContent = event.root.content<MessageContent>()
|
||||||
val roomMember = event.roomMember()
|
val roomMember = event.roomMember()
|
||||||
@ -60,10 +64,6 @@ class TimelineEventController(private val context: Context) : EpoxyController(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val date = event.root.localDateTime()
|
|
||||||
val nextDate = nextEvent?.root?.localDateTime()
|
|
||||||
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
|
|
||||||
|
|
||||||
val nextRoomMember = nextEvent?.roomMember()
|
val nextRoomMember = nextEvent?.roomMember()
|
||||||
if (addDaySeparator || nextRoomMember != roomMember) {
|
if (addDaySeparator || nextRoomMember != roomMember) {
|
||||||
messagesDisplayedWithInformation.add(event.root.eventId)
|
messagesDisplayedWithInformation.add(event.root.eventId)
|
||||||
@ -80,12 +80,15 @@ class TimelineEventController(private val context: Context) : EpoxyController(
|
|||||||
.onBind { timeline?.loadAround(index) }
|
.onBind { timeline?.loadAround(index) }
|
||||||
.id(event.root.eventId)
|
.id(event.root.eventId)
|
||||||
.addTo(this)
|
.addTo(this)
|
||||||
|
} else {
|
||||||
|
BlankItemModel_()
|
||||||
if (addDaySeparator) {
|
.id(event.root.eventId)
|
||||||
val formattedDay = date.toLocalDate().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM))
|
.onBind { _, _, _ -> timeline?.loadAround(index) }
|
||||||
TimelineDaySeparatorItem(formattedDay).id(formattedDay).addTo(this)
|
.addTo(this)
|
||||||
}
|
}
|
||||||
|
if (addDaySeparator) {
|
||||||
|
val formattedDay = date.toLocalDate().format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM))
|
||||||
|
TimelineDaySeparatorItem(formattedDay).id(formattedDay).addTo(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user