DataSource wrapping

Some refactoring
This commit is contained in:
2021-09-10 22:50:57 +03:00
parent 9e8d9247dc
commit 465b492328
65 changed files with 534 additions and 266 deletions
@@ -1,7 +1,15 @@
package com.meloda.fast.api.model
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
@Entity(tableName = "conversations")
data class VkConversation(
@PrimaryKey(autoGenerate = false)
val id: Int,
val title: String?,
val lastMessage: VkMessage
)
) {
@Ignore
var lastMessage: VkMessage? = null
}
@@ -1,10 +1,19 @@
package com.meloda.fast.api.model
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "messages")
data class VkMessage(
@PrimaryKey(autoGenerate = false)
val id: Int,
val text: String?,
val isOut: Boolean,
val peerId: Int,
val fromId: Int,
val date: Int
)
) {
}
@@ -1,6 +1,11 @@
package com.meloda.fast.api.model
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "users")
data class VkUser(
@PrimaryKey(autoGenerate = false)
val id: Int,
val firstName: String,
val lastName: String
@@ -2,6 +2,8 @@ package com.meloda.fast.api.model.base
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.meloda.fast.api.model.VkConversation
import com.meloda.fast.api.model.VkMessage
import kotlinx.parcelize.Parcelize
@Parcelize
@@ -32,6 +34,11 @@ data class BaseVkConversation(
val chatSettings: ChatSettings?
) : Parcelable {
fun asVkConversation(lastMessage: VkMessage? = null) = VkConversation(
id = peer.id,
title = chatSettings?.title,
).apply { this.lastMessage = lastMessage }
@Parcelize
data class Peer(
val id: Int,
@@ -2,6 +2,7 @@ package com.meloda.fast.api.model.base
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.meloda.fast.api.model.VkMessage
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.RawValue
@@ -29,6 +30,15 @@ data class BaseVkMessage(
val geo: Geo?
) : Parcelable {
fun asVkMessage() = VkMessage(
id = id,
text = text,
isOut = out == 1,
peerId = peerId,
fromId = fromId,
date = date
)
@Parcelize
data class Geo(
val type: String,
@@ -2,6 +2,7 @@ package com.meloda.fast.api.model.base
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.meloda.fast.api.model.VkUser
import kotlinx.parcelize.Parcelize
@Parcelize
@@ -46,4 +47,10 @@ data class BaseVkUser(
val appId: Int?
) : Parcelable
fun asVkUser() = VkUser(
id = id,
firstName = firstName,
lastName = lastName
)
}
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONArray
import java.util.*
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.io.Serializable
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONArray
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.io.Serializable
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import java.util.*
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,5 +1,6 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import com.meloda.fast.api.model.old.VKAttachments
import com.meloda.fast.base.adapter.BaseItem
import java.io.Serializable
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.util.*
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.util.*
@@ -1,5 +1,7 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import com.meloda.fast.api.model.old.VKAttachments
import com.meloda.fast.api.model.old.VKModel
import org.json.JSONObject
class VKVideo() : VKModel() {
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONObject
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import android.util.ArrayMap
import com.meloda.fast.api.VKUtil
@@ -1,4 +1,4 @@
package com.meloda.fast.api.model
package com.meloda.fast.api.model.old
import org.json.JSONArray
import org.json.JSONObject