Add marging around item

This commit is contained in:
Benoit Marty 2019-05-24 15:57:28 +02:00
parent 2404eeadf0
commit bbf2f96288
3 changed files with 16 additions and 20 deletions

View file

@ -16,9 +16,11 @@
package im.vector.riotredesign.core.epoxy package im.vector.riotredesign.core.epoxy
import android.content.Context import com.airbnb.epoxy.EpoxyModelClass
import android.widget.ProgressBar import im.vector.riotredesign.R
import com.airbnb.epoxy.ModelView
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT) @EpoxyModelClass(layout = R.layout.item_loading)
class LoadingItem(context: Context) : ProgressBar(context) abstract class LoadingItem : VectorEpoxyModel<LoadingItem.Holder>() {
class Holder : VectorEpoxyHolder()
}

View file

@ -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.model.message.*
import im.vector.matrix.android.api.session.room.timeline.Timeline import im.vector.matrix.android.api.session.room.timeline.Timeline
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent 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.core.extensions.localDateTime
import im.vector.riotredesign.features.home.room.detail.timeline.factory.TimelineItemFactory import im.vector.riotredesign.features.home.room.detail.timeline.factory.TimelineItemFactory
import im.vector.riotredesign.features.home.room.detail.timeline.helper.* import im.vector.riotredesign.features.home.room.detail.timeline.helper.*
@ -131,14 +131,14 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter,
} }
override fun buildModels() { override fun buildModels() {
LoadingItemModel_() LoadingItem_()
.id("forward_loading_item") .id("forward_loading_item")
.addWhen(Timeline.Direction.FORWARDS) .addWhen(Timeline.Direction.FORWARDS)
val timelineModels = getModels() val timelineModels = getModels()
add(timelineModels) add(timelineModels)
LoadingItemModel_() LoadingItem_()
.id("backward_loading_item") .id("backward_loading_item")
.addWhen(Timeline.Direction.BACKWARDS) .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 val shouldAdd = timeline?.hasMoreToLoad(direction) ?: false
addIf(shouldAdd, this@TimelineEventController) addIf(shouldAdd, this@TimelineEventController)
} }

View file

@ -76,18 +76,14 @@ class RoomDirectoryViewModel(initialState: PublicRoomsViewState,
.liveRoomSummaries() .liveRoomSummaries()
.execute { async -> .execute { async ->
val joinedRoomIds = async.invoke() val joinedRoomIds = async.invoke()
?.filter { // Keep only joined room
// Keep only joined room ?.filter { it.membership == Membership.JOIN }
it.membership == Membership.JOIN ?.map { it.roomId }
}
?.map {
it.roomId
}
?.toList() ?.toList()
?: emptyList() ?: emptyList()
copy(
copy(joinedRoomsIds = joinedRoomIds, joinedRoomsIds = joinedRoomIds,
// Remove (newly) joined room id from the joining room list // Remove (newly) joined room id from the joining room list
joiningRoomsIds = joiningRoomsIds.toMutableList().apply { removeAll(joinedRoomIds) } joiningRoomsIds = joiningRoomsIds.toMutableList().apply { removeAll(joinedRoomIds) }
) )
@ -102,7 +98,6 @@ class RoomDirectoryViewModel(initialState: PublicRoomsViewState,
this.roomDirectoryData = roomDirectoryData this.roomDirectoryData = roomDirectoryData
reset() reset()
load() load()
} }
@ -116,7 +111,6 @@ class RoomDirectoryViewModel(initialState: PublicRoomsViewState,
currentFilter = filter currentFilter = filter
reset() reset()
load() load()
} }