From 1d4882e59682b33a57500482b044b90954926c7e Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 5 Mar 2019 18:31:03 +0100 Subject: [PATCH] Timeline : fix small issue, reduce animation time and reorganize a bit some files. --- .../riotredesign/features/home/HomeModule.kt | 18 ++++---- .../home/room/detail/RoomDetailFragment.kt | 3 ++ .../timeline/TimelineEventController.kt | 7 ++-- .../animation/TimelineItemAnimator.kt | 32 ++++++++++++++ .../timeline/{ => factory}/CallItemFactory.kt | 42 +++++++++---------- .../{ => factory}/DefaultItemFactory.kt | 4 +- .../{ => factory}/MessageItemFactory.kt | 11 ++++- .../RoomHistoryVisibilityItemFactory.kt | 28 ++++++------- .../{ => factory}/RoomMemberItemFactory.kt | 6 ++- .../{ => factory}/RoomNameItemFactory.kt | 4 +- .../{ => factory}/RoomTopicItemFactory.kt | 4 +- .../{ => factory}/TimelineItemFactory.kt | 3 +- .../{ => helper}/TimelineDateFormatter.kt | 13 ++++-- .../timeline/{ => item}/AbsMessageItem.kt | 2 +- .../timeline/{ => item}/DaySeparatorItem.kt | 2 +- .../detail/timeline/{ => item}/DefaultItem.kt | 2 +- .../timeline/{ => item}/MessageImageItem.kt | 2 +- .../{ => item}/MessageInformationData.kt | 2 +- .../timeline/{ => item}/MessageTextItem.kt | 2 +- .../detail/timeline/{ => item}/NoticeItem.kt | 2 +- 20 files changed, 124 insertions(+), 65 deletions(-) create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/animation/TimelineItemAnimator.kt rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/CallItemFactory.kt (55%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/DefaultItemFactory.kt (86%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/MessageItemFactory.kt (90%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/RoomHistoryVisibilityItemFactory.kt (71%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/RoomMemberItemFactory.kt (96%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/RoomNameItemFactory.kt (91%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/RoomTopicItemFactory.kt (91%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => factory}/TimelineItemFactory.kt (96%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => helper}/TimelineDateFormatter.kt (73%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/AbsMessageItem.kt (99%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/DaySeparatorItem.kt (99%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/DefaultItem.kt (99%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/MessageImageItem.kt (99%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/MessageInformationData.kt (99%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/MessageTextItem.kt (99%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{ => item}/NoticeItem.kt (99%) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt index 04a93d66..cb299d45 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt @@ -19,16 +19,16 @@ package im.vector.riotredesign.features.home import androidx.fragment.app.Fragment import im.vector.riotredesign.core.glide.GlideApp import im.vector.riotredesign.features.home.group.GroupSummaryController -import im.vector.riotredesign.features.home.room.detail.timeline.CallItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.DefaultItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.MessageItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.RoomHistoryVisibilityItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.RoomMemberItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.RoomNameItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.RoomTopicItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.TimelineDateFormatter +import im.vector.riotredesign.features.home.room.detail.timeline.factory.CallItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.DefaultItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.MessageItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.RoomHistoryVisibilityItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.RoomMemberItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.RoomNameItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.RoomTopicItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineDateFormatter import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController -import im.vector.riotredesign.features.home.room.detail.timeline.TimelineItemFactory +import im.vector.riotredesign.features.home.room.detail.timeline.factory.TimelineItemFactory import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider import im.vector.riotredesign.features.home.room.list.RoomSummaryController import im.vector.riotredesign.features.html.EventHtmlRenderer diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt index faf792d7..a72758e9 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/RoomDetailFragment.kt @@ -35,6 +35,7 @@ import im.vector.riotredesign.features.home.AvatarRenderer import im.vector.riotredesign.features.home.HomeModule import im.vector.riotredesign.features.home.HomePermalinkHandler import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController +import im.vector.riotredesign.features.home.room.detail.timeline.animation.TimelineItemAnimator import kotlinx.android.parcel.Parcelize import kotlinx.android.synthetic.main.fragment_room_detail.* import org.koin.android.ext.android.inject @@ -76,6 +77,7 @@ class RoomDetailFragment : RiotFragment(), TimelineEventController.Callback { setupRecyclerView() setupToolbar() setupSendButton() + timelineEventController.requestModelBuild() roomDetailViewModel.subscribe { renderState(it) } } @@ -100,6 +102,7 @@ class RoomDetailFragment : RiotFragment(), TimelineEventController.Callback { val stateRestorer = LayoutManagerStateRestorer(layoutManager).register() scrollOnNewMessageCallback = ScrollOnNewMessageCallback(layoutManager) recyclerView.layoutManager = layoutManager + recyclerView.itemAnimator = TimelineItemAnimator() recyclerView.setHasFixedSize(true) timelineEventController.addModelBuildListener { it.dispatchTo(stateRestorer) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt index 883476de..ce89fda6 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt @@ -26,7 +26,10 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.core.epoxy.LoadingItemModel_ import im.vector.riotredesign.core.epoxy.RiotEpoxyModel 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.TimelineDateFormatter import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.DaySeparatorItem_ import im.vector.riotredesign.features.home.room.detail.timeline.paging.PagedListEpoxyController class TimelineEventController(private val dateFormatter: TimelineDateFormatter, @@ -41,10 +44,6 @@ class TimelineEventController(private val dateFormatter: TimelineDateFormatter, private var isLoadingBackward: Boolean = false private var hasReachedEnd: Boolean = true - init { - requestModelBuild() - } - var callback: Callback? = null fun update(timelineData: TimelineData?) { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/animation/TimelineItemAnimator.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/animation/TimelineItemAnimator.kt new file mode 100644 index 00000000..8a9615db --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/animation/TimelineItemAnimator.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotredesign.features.home.room.detail.timeline.animation + +import androidx.recyclerview.widget.DefaultItemAnimator + +private const val ANIM_DURATION_IN_MILLIS = 100L + +class TimelineItemAnimator : DefaultItemAnimator() { + + init { + addDuration = ANIM_DURATION_IN_MILLIS + removeDuration = ANIM_DURATION_IN_MILLIS + moveDuration = ANIM_DURATION_IN_MILLIS + changeDuration = ANIM_DURATION_IN_MILLIS + } + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/CallItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/CallItemFactory.kt similarity index 55% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/CallItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/CallItemFactory.kt index b5bc183f..e83183ef 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/CallItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/CallItemFactory.kt @@ -1,22 +1,20 @@ /* + * Copyright 2019 New Vector Ltd * - * * Copyright 2019 New Vector Ltd - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.events.model.EventType @@ -26,6 +24,8 @@ import im.vector.matrix.android.api.session.room.model.call.CallInviteContent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.R import im.vector.riotredesign.core.resources.StringProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem_ class CallItemFactory(private val stringProvider: StringProvider) { @@ -40,18 +40,18 @@ class CallItemFactory(private val stringProvider: StringProvider) { private fun buildNoticeText(event: Event, roomMember: RoomMember): CharSequence? { return when { - EventType.CALL_INVITE == event.type -> { - val content = event.content.toModel()?: return null + EventType.CALL_INVITE == event.type -> { + val content = event.content.toModel() ?: return null val isVideoCall = content.offer.sdp == CallInviteContent.Offer.SDP_VIDEO - return if(isVideoCall){ + return if (isVideoCall) { stringProvider.getString(R.string.notice_placed_video_call, roomMember.displayName) - }else{ + } else { stringProvider.getString(R.string.notice_placed_voice_call, roomMember.displayName) } } - EventType.CALL_ANSWER == event.type -> stringProvider.getString(R.string.notice_answered_call, roomMember.displayName) - EventType.CALL_HANGUP == event.type -> stringProvider.getString(R.string.notice_ended_call, roomMember.displayName) - else -> null + EventType.CALL_ANSWER == event.type -> stringProvider.getString(R.string.notice_answered_call, roomMember.displayName) + EventType.CALL_HANGUP == event.type -> stringProvider.getString(R.string.notice_ended_call, roomMember.displayName) + else -> null } } diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/DefaultItemFactory.kt similarity index 86% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/DefaultItemFactory.kt index c168d89e..6b7c391e 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/DefaultItemFactory.kt @@ -14,9 +14,11 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import im.vector.matrix.android.api.session.room.timeline.TimelineEvent +import im.vector.riotredesign.features.home.room.detail.timeline.item.DefaultItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.DefaultItem_ class DefaultItemFactory { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt similarity index 90% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt index b31ccf94..4d3104c8 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import android.text.Spannable import android.text.SpannableStringBuilder @@ -33,7 +33,16 @@ import im.vector.riotredesign.R import im.vector.riotredesign.core.epoxy.RiotEpoxyModel import im.vector.riotredesign.core.extensions.localDateTime import im.vector.riotredesign.core.resources.ColorProvider +import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineDateFormatter +import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.DefaultItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.DefaultItem_ +import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageImageItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageImageItem_ +import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageInformationData +import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageTextItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.MessageTextItem_ import im.vector.riotredesign.features.html.EventHtmlRenderer import im.vector.riotredesign.features.media.MediaContentRenderer import me.gujun.android.span.span diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomHistoryVisibilityItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomHistoryVisibilityItemFactory.kt similarity index 71% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomHistoryVisibilityItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomHistoryVisibilityItemFactory.kt index 91972af2..cd87e7bd 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomHistoryVisibilityItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomHistoryVisibilityItemFactory.kt @@ -1,22 +1,20 @@ /* + * Copyright 2019 New Vector Ltd * - * * Copyright 2019 New Vector Ltd - * * - * * Licensed under the Apache License, Version 2.0 (the "License"); - * * you may not use this file except in compliance with the License. - * * You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, software - * * distributed under the License is distributed on an "AS IS" BASIS, - * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * * See the License for the specific language governing permissions and - * * limitations under the License. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.events.model.toModel @@ -26,6 +24,8 @@ import im.vector.matrix.android.api.session.room.model.RoomMember import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.R import im.vector.riotredesign.core.resources.StringProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem_ class RoomHistoryVisibilityItemFactory(private val stringProvider: StringProvider) { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomMemberItemFactory.kt similarity index 96% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomMemberItemFactory.kt index e2cf8cbd..1aca6133 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomMemberItemFactory.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import android.text.TextUtils import im.vector.matrix.android.api.session.events.model.toModel @@ -23,9 +23,11 @@ import im.vector.matrix.android.api.session.room.model.RoomMember import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.R import im.vector.riotredesign.core.resources.StringProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem_ -//TODO : complete with call membership events +//TODO : complete with call membership eventsĀ¬ class RoomMemberItemFactory(private val stringProvider: StringProvider) { fun create(event: TimelineEvent): NoticeItem? { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomNameItemFactory.kt similarity index 91% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomNameItemFactory.kt index db59e58a..3904d7c7 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomNameItemFactory.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import android.text.TextUtils import im.vector.matrix.android.api.session.events.model.toModel @@ -22,6 +22,8 @@ import im.vector.matrix.android.api.session.room.model.RoomNameContent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.R import im.vector.riotredesign.core.resources.StringProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem_ class RoomNameItemFactory(private val stringProvider: StringProvider) { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomTopicItemFactory.kt similarity index 91% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomTopicItemFactory.kt index f4fe72c9..5aa31c9b 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/RoomTopicItemFactory.kt @@ -14,13 +14,15 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.RoomTopicContent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.R import im.vector.riotredesign.core.resources.StringProvider +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem +import im.vector.riotredesign.features.home.room.detail.timeline.item.NoticeItem_ class RoomTopicItemFactory(private val stringProvider: StringProvider) { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt similarity index 96% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt index 80ed553a..a850fd96 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/factory/TimelineItemFactory.kt @@ -14,12 +14,13 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.factory import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.riotredesign.core.epoxy.EmptyItem_ import im.vector.riotredesign.core.epoxy.RiotEpoxyModel +import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController class TimelineItemFactory(private val messageItemFactory: MessageItemFactory, private val roomNameItemFactory: RoomNameItemFactory, diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineDateFormatter.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDateFormatter.kt similarity index 73% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineDateFormatter.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDateFormatter.kt index 51565a54..0a4ed952 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineDateFormatter.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/helper/TimelineDateFormatter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.helper import im.vector.riotredesign.core.resources.LocaleProvider import org.threeten.bp.LocalDateTime @@ -22,12 +22,19 @@ import org.threeten.bp.format.DateTimeFormatter class TimelineDateFormatter(private val localeProvider: LocaleProvider) { + private val messageHourFormatter by lazy { + DateTimeFormatter.ofPattern("H:mm", localeProvider.current()) + } + private val messageDayFormatter by lazy { + DateTimeFormatter.ofPattern("EEE d MMM", localeProvider.current()) + } + fun formatMessageHour(localDateTime: LocalDateTime): String { - return DateTimeFormatter.ofPattern("H:mm", localeProvider.current()).format(localDateTime) + return messageHourFormatter.format(localDateTime) } fun formatMessageDay(localDateTime: LocalDateTime): String { - return DateTimeFormatter.ofPattern("EEE d MMM", localeProvider.current()).format(localDateTime) + return messageDayFormatter.format(localDateTime) } } \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/AbsMessageItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/AbsMessageItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt index 8a598d0f..969ba696 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/AbsMessageItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/AbsMessageItem.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item import android.view.View import android.widget.ImageView diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/DaySeparatorItem.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/DaySeparatorItem.kt index 6f1bcc7c..2b4e4972 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/DaySeparatorItem.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/DefaultItem.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/DefaultItem.kt index 3d399e2f..82471095 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/DefaultItem.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageImageItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageImageItem.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageImageItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageImageItem.kt index 310ffd46..56d06c38 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageImageItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageImageItem.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item import android.widget.ImageView import android.widget.TextView diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageInformationData.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageInformationData.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageInformationData.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageInformationData.kt index faf32b87..f6ae60a9 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageInformationData.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageInformationData.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item data class MessageInformationData( val time: CharSequence? = null, diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageTextItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageTextItem.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageTextItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageTextItem.kt index 9a0bc8ba..5c5ebbf9 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageTextItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/MessageTextItem.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item import android.text.Spannable import android.widget.ImageView diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/NoticeItem.kt similarity index 99% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/NoticeItem.kt index 63c4ae17..7cea98c4 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/item/NoticeItem.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.riotredesign.features.home.room.detail.timeline +package im.vector.riotredesign.features.home.room.detail.timeline.item import android.widget.ImageView import android.widget.TextView