mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Add marging around item
This commit is contained in:
parent
2404eeadf0
commit
bbf2f96288
3 changed files with 16 additions and 20 deletions
|
@ -16,9 +16,11 @@
|
|||
|
||||
package im.vector.riotredesign.core.epoxy
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.ProgressBar
|
||||
import com.airbnb.epoxy.ModelView
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.riotredesign.R
|
||||
|
||||
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)
|
||||
class LoadingItem(context: Context) : ProgressBar(context)
|
||||
@EpoxyModelClass(layout = R.layout.item_loading)
|
||||
abstract class LoadingItem : VectorEpoxyModel<LoadingItem.Holder>() {
|
||||
|
||||
class Holder : VectorEpoxyHolder()
|
||||
}
|
|
@ -30,7 +30,7 @@ import im.vector.matrix.android.api.session.room.model.RoomMember
|
|||
import im.vector.matrix.android.api.session.room.model.message.*
|
||||
import im.vector.matrix.android.api.session.room.timeline.Timeline
|
||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||
import im.vector.riotredesign.core.epoxy.LoadingItemModel_
|
||||
import im.vector.riotredesign.core.epoxy.LoadingItem_
|
||||
import im.vector.riotredesign.core.extensions.localDateTime
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.factory.TimelineItemFactory
|
||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.*
|
||||
|
@ -131,14 +131,14 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter,
|
|||
}
|
||||
|
||||
override fun buildModels() {
|
||||
LoadingItemModel_()
|
||||
LoadingItem_()
|
||||
.id("forward_loading_item")
|
||||
.addWhen(Timeline.Direction.FORWARDS)
|
||||
|
||||
val timelineModels = getModels()
|
||||
add(timelineModels)
|
||||
|
||||
LoadingItemModel_()
|
||||
LoadingItem_()
|
||||
.id("backward_loading_item")
|
||||
.addWhen(Timeline.Direction.BACKWARDS)
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter,
|
|||
}
|
||||
}
|
||||
|
||||
private fun LoadingItemModel_.addWhen(direction: Timeline.Direction) {
|
||||
private fun LoadingItem_.addWhen(direction: Timeline.Direction) {
|
||||
val shouldAdd = timeline?.hasMoreToLoad(direction) ?: false
|
||||
addIf(shouldAdd, this@TimelineEventController)
|
||||
}
|
||||
|
|
|
@ -76,18 +76,14 @@ class RoomDirectoryViewModel(initialState: PublicRoomsViewState,
|
|||
.liveRoomSummaries()
|
||||
.execute { async ->
|
||||
val joinedRoomIds = async.invoke()
|
||||
?.filter {
|
||||
// Keep only joined room
|
||||
it.membership == Membership.JOIN
|
||||
}
|
||||
?.map {
|
||||
it.roomId
|
||||
}
|
||||
// Keep only joined room
|
||||
?.filter { it.membership == Membership.JOIN }
|
||||
?.map { it.roomId }
|
||||
?.toList()
|
||||
?: emptyList()
|
||||
|
||||
|
||||
copy(joinedRoomsIds = joinedRoomIds,
|
||||
copy(
|
||||
joinedRoomsIds = joinedRoomIds,
|
||||
// Remove (newly) joined room id from the joining room list
|
||||
joiningRoomsIds = joiningRoomsIds.toMutableList().apply { removeAll(joinedRoomIds) }
|
||||
)
|
||||
|
@ -102,7 +98,6 @@ class RoomDirectoryViewModel(initialState: PublicRoomsViewState,
|
|||
this.roomDirectoryData = roomDirectoryData
|
||||
|
||||
reset()
|
||||
|
||||
load()
|
||||
}
|
||||
|
||||
|
@ -116,7 +111,6 @@ class RoomDirectoryViewModel(initialState: PublicRoomsViewState,
|
|||
currentFilter = filter
|
||||
|
||||
reset()
|
||||
|
||||
load()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue