code saving
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package com.meloda.fast.api.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import androidx.room.PrimaryKey
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@@ -24,10 +24,14 @@ data class VkConversation(
|
||||
val lastMessageId: Int,
|
||||
val unreadCount: Int?,
|
||||
val membersCount: Int?,
|
||||
val isPinned: Boolean
|
||||
) : Parcelable {
|
||||
@Ignore
|
||||
val isPinned: Boolean,
|
||||
|
||||
@Embedded(prefix = "pinnedMessage_")
|
||||
var pinnedMessage: VkMessage? = null,
|
||||
|
||||
@Embedded(prefix = "lastMessage_")
|
||||
var lastMessage: VkMessage? = null
|
||||
) : Parcelable {
|
||||
|
||||
fun isChat() = type == "chat"
|
||||
fun isUser() = type == "user"
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.meloda.fast.api.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import androidx.room.PrimaryKey
|
||||
import com.meloda.fast.api.model.attachments.VkAttachment
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Entity(tableName = "messages")
|
||||
@@ -25,16 +23,10 @@ data class VkMessage(
|
||||
val actionConversationMessageId: Int? = null,
|
||||
val actionMessage: String? = null,
|
||||
val geoType: String? = null,
|
||||
val important: Boolean = false
|
||||
) : Parcelable {
|
||||
|
||||
@IgnoredOnParcel
|
||||
@Ignore
|
||||
var forwards: List<VkMessage>? = null
|
||||
|
||||
@IgnoredOnParcel
|
||||
@Ignore
|
||||
val important: Boolean = false,
|
||||
var forwards: List<VkMessage>? = null,
|
||||
var attachments: List<VkAttachment>? = null
|
||||
) : Parcelable {
|
||||
|
||||
fun isPeerChat() = peerId > 2_000_000_000
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
abstract class VkAttachment : Parcelable
|
||||
@Parcelize
|
||||
open class VkAttachment : Parcelable
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkAudio(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkCall(
|
||||
val initiatorId: Int
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkFile(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkGift(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkGraffiti(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkGroupCall(
|
||||
val initiatorId: Int
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkLink(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkMiniApp(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import com.meloda.fast.api.model.base.attachments.Size
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
@@ -16,6 +17,9 @@ data class VkPhoto(
|
||||
val userId: Int?
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
|
||||
fun sizeOfType(type: Char): Size? {
|
||||
for (size in sizes) {
|
||||
if (size.type == type.toString())
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkPoll(
|
||||
val id: Int
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.meloda.fast.api.model.attachments
|
||||
|
||||
import com.meloda.fast.api.model.base.attachments.BaseVkSticker
|
||||
import com.meloda.fast.api.model.base.attachments.StickerSize
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
@@ -12,6 +13,9 @@ data class VkSticker(
|
||||
val backgroundImages: List<BaseVkSticker.Image>
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
|
||||
fun urlForSize(@StickerSize size: Int): String? {
|
||||
for (image in images) {
|
||||
if (image.width == size) return image.url
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import com.meloda.fast.api.model.base.attachments.BaseVkVideo
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkVideo(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
val id: Int,
|
||||
val images: List<BaseVkVideo.Image>,
|
||||
val firstFrames: List<BaseVkVideo.FirstFrame>
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
|
||||
fun imageForWidth(width: Int): BaseVkVideo.Image? {
|
||||
return images.find { it.width == width }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkVoiceMessage(
|
||||
val link: String
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkWall(
|
||||
val id: Int
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.meloda.fast.api.model.attachments
|
||||
|
||||
import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class VkWallReply(
|
||||
val id: Int
|
||||
) : VkAttachment()
|
||||
) : VkAttachment() {
|
||||
|
||||
@IgnoredOnParcel
|
||||
val className: String = this::class.java.name
|
||||
}
|
||||
@@ -54,7 +54,10 @@ data class BaseVkConversation(
|
||||
membersCount = chatSettings?.membersCount,
|
||||
ownerId = chatSettings?.ownerId,
|
||||
isPinned = sortId.majorId > 0
|
||||
).apply { this.lastMessage = lastMessage }
|
||||
).apply {
|
||||
this.lastMessage = lastMessage
|
||||
this.pinnedMessage = chatSettings?.pinnedMessage?.asVkMessage()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
data class Peer(
|
||||
@@ -111,7 +114,9 @@ data class BaseVkConversation(
|
||||
val isDisappearing: Boolean,
|
||||
@SerializedName("is_service")
|
||||
val isService: Boolean,
|
||||
val theme: String
|
||||
val theme: String?,
|
||||
@SerializedName("pinned_message")
|
||||
val pinnedMessage: BaseVkMessage?
|
||||
) : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.meloda.fast.api.model.base.attachments
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.meloda.fast.api.model.attachments.VkVideo
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
//not all fields
|
||||
@Parcelize
|
||||
data class BaseVkVideo(
|
||||
val id: Int,
|
||||
@@ -53,6 +55,12 @@ data class BaseVkVideo(
|
||||
//ads
|
||||
) : BaseVkAttachment() {
|
||||
|
||||
fun asVkVideo() = VkVideo(
|
||||
id = id,
|
||||
images = image,
|
||||
firstFrames = firstFrame
|
||||
)
|
||||
|
||||
@Parcelize
|
||||
data class Image(
|
||||
val height: Int,
|
||||
|
||||
Reference in New Issue
Block a user