2019-01-18 10:12:08 +00:00
|
|
|
/*
|
2019-01-25 13:04:59 +00:00
|
|
|
* Copyright 2019 New Vector Ltd
|
2019-01-18 10:12:08 +00:00
|
|
|
*
|
2019-01-25 13:04:59 +00:00
|
|
|
* 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
|
2019-01-18 10:12:08 +00:00
|
|
|
*
|
2019-01-25 13:04:59 +00:00
|
|
|
* 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.
|
2019-01-18 10:12:08 +00:00
|
|
|
*/
|
|
|
|
|
2019-07-02 15:27:08 +00:00
|
|
|
package im.vector.riotx.features.home.room.detail.timeline.factory
|
2018-11-02 16:37:37 +00:00
|
|
|
|
2019-01-18 15:26:17 +00:00
|
|
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
2019-08-28 15:31:31 +00:00
|
|
|
import im.vector.riotx.features.home.AvatarRenderer
|
|
|
|
import im.vector.riotx.features.home.room.detail.timeline.TimelineEventController
|
2019-07-02 15:27:08 +00:00
|
|
|
import im.vector.riotx.features.home.room.detail.timeline.item.DefaultItem
|
|
|
|
import im.vector.riotx.features.home.room.detail.timeline.item.DefaultItem_
|
2019-08-28 15:31:31 +00:00
|
|
|
import im.vector.riotx.features.home.room.detail.timeline.util.MessageInformationDataFactory
|
2019-06-18 18:00:20 +00:00
|
|
|
import javax.inject.Inject
|
2018-11-02 16:37:37 +00:00
|
|
|
|
2019-08-28 15:31:31 +00:00
|
|
|
class DefaultItemFactory @Inject constructor(private val avatarRenderer: AvatarRenderer,
|
|
|
|
private val informationDataFactory: MessageInformationDataFactory) {
|
2018-11-02 16:37:37 +00:00
|
|
|
|
2019-08-28 15:31:31 +00:00
|
|
|
fun create(event: TimelineEvent,
|
|
|
|
highlight: Boolean,
|
|
|
|
callback: TimelineEventController.Callback?,
|
|
|
|
exception: Exception? = null): DefaultItem? {
|
2019-02-11 12:47:47 +00:00
|
|
|
val text = if (exception == null) {
|
2019-05-26 17:21:45 +00:00
|
|
|
"${event.root.getClearType()} events are not yet handled"
|
2019-02-11 12:47:47 +00:00
|
|
|
} else {
|
|
|
|
"an exception occurred when rendering the event ${event.root.eventId}"
|
|
|
|
}
|
2019-08-28 15:31:31 +00:00
|
|
|
|
|
|
|
val informationData = informationDataFactory.create(event, null)
|
|
|
|
|
2019-06-20 14:27:43 +00:00
|
|
|
return DefaultItem_()
|
|
|
|
.text(text)
|
2019-08-28 15:31:31 +00:00
|
|
|
.avatarRenderer(avatarRenderer)
|
2019-06-20 14:27:43 +00:00
|
|
|
.highlighted(highlight)
|
2019-08-28 15:31:31 +00:00
|
|
|
.informationData(informationData)
|
2019-08-28 16:17:37 +00:00
|
|
|
.baseCallback(callback)
|
2019-08-28 15:31:31 +00:00
|
|
|
.readReceiptsCallback(callback)
|
2018-11-02 16:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|