diff --git a/vector/src/main/java/im/vector/riotredesign/core/epoxy/LoadingItem.kt b/vector/src/main/java/im/vector/riotredesign/core/epoxy/LoadingItem.kt index cade275ba0..212196ada7 100644 --- a/vector/src/main/java/im/vector/riotredesign/core/epoxy/LoadingItem.kt +++ b/vector/src/main/java/im/vector/riotredesign/core/epoxy/LoadingItem.kt @@ -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) \ No newline at end of file +@EpoxyModelClass(layout = R.layout.item_loading) +abstract class LoadingItem : VectorEpoxyModel() { + + class Holder : VectorEpoxyHolder() +} \ No newline at end of file diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt index c14b863a18..59a296a735 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt @@ -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) } diff --git a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/PublicRoomsViewModel.kt b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/PublicRoomsViewModel.kt index d00798a93e..32a3e25ebd 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/PublicRoomsViewModel.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/PublicRoomsViewModel.kt @@ -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() }