From 56e06803981fbe89c601223762952013d439d39f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 18 Jun 2019 16:03:20 +0200 Subject: [PATCH] Remove unused class --- .../session/room/send/EventFactory.kt | 60 ------------------- 1 file changed, 60 deletions(-) delete mode 100644 matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EventFactory.kt diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EventFactory.kt deleted file mode 100644 index 514526ea..00000000 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/EventFactory.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.matrix.android.internal.session.room.send - -import im.vector.matrix.android.api.auth.data.Credentials -import im.vector.matrix.android.api.session.events.model.Content -import im.vector.matrix.android.api.session.events.model.Event -import im.vector.matrix.android.api.session.events.model.EventType -import im.vector.matrix.android.api.session.room.model.message.MessageTextContent -import im.vector.matrix.android.internal.di.MoshiProvider - -// TODO Remove -internal class EventFactory(private val credentials: Credentials) { - - private val moshi = MoshiProvider.providesMoshi() - - fun createTextEvent(roomId: String, msgType: String, text: String): Event { - val content = MessageTextContent(type = msgType, body = text) - - return Event( - roomId = roomId, - originServerTs = dummyOriginServerTs(), - senderId = credentials.userId, - eventId = dummyEventId(roomId), - type = EventType.MESSAGE, - content = toContent(content) - ) - } - - private fun dummyOriginServerTs(): Long { - return System.currentTimeMillis() - } - - private fun dummyEventId(roomId: String): String { - return roomId + "-" + dummyOriginServerTs() - } - - @Suppress("UNCHECKED_CAST") - private inline fun toContent(data: T?): Content? { - val moshiAdapter = moshi.adapter(T::class.java) - val jsonValue = moshiAdapter.toJsonValue(data) - return jsonValue as? Content? - } - - -}