Basic conversations screen

attachment types
action types
forwards
This commit is contained in:
2021-09-11 21:58:55 +03:00
parent 2109ff9ee5
commit f7c8d6e1c8
91 changed files with 1694 additions and 421 deletions
@@ -9,7 +9,15 @@ data class VkConversation(
@PrimaryKey(autoGenerate = false)
val id: Int,
val title: String?,
val photo200: String?,
val type: String,
val callInProgress: Boolean
) {
@Ignore
var lastMessage: VkMessage? = null
fun isChat() = type == "chat"
fun isUser() = type == "user"
fun isGroup() = type == "group"
}
@@ -0,0 +1,17 @@
package com.meloda.fast.api.model
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "groups")
data class VkGroup(
@PrimaryKey(autoGenerate = false)
val id: Int,
val name: String,
val screenName: String,
val photo200: String?
) {
override fun toString() = name.trim()
}
@@ -1,7 +1,9 @@
package com.meloda.fast.api.model
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.meloda.fast.api.model.attachments.VkAttachment
@Entity(tableName = "messages")
data class VkMessage(
@@ -11,9 +13,48 @@ data class VkMessage(
val isOut: Boolean,
val peerId: Int,
val fromId: Int,
val date: Int
val date: Int,
val action: String?,
val actionMemberId: Int?,
val actionText: String?,
val actionConversationMessageId: Int?,
val actionMessage: String?,
val geoType: String?
) {
@Ignore
var forwards: List<VkMessage>? = null
@Ignore
var attachments: List<VkAttachment>? = null
fun isUser() = id > 0
fun isGroup() = id < 0
fun getPreparedAction(): Action? {
if (action == null) return null
return Action.parse(action)
}
enum class Action(val value: String) {
CHAT_CREATE("chat_create"),
CHAT_PHOTO_UPDATE("chat_photo_update"),
CHAT_PHOTO_REMOVE("chat_photo_remove"),
CHAT_TITLE_UPDATE("chat_title_update"),
CHAT_PIN_MESSAGE("chat_pin_message"),
CHAT_UNPIN_MESSAGE("chat_unpin_message"),
CHAT_INVITE_USER("chat_invite_user"),
CHAT_INVITE_USER_BY_LINK("chat_invite_user_by_link"),
CHAT_KICK_USER("chat_kick_user"),
CHAT_SCREENSHOT("chat_screenshot"),
// TODO: 9/11/2021 catch this shit
CHAT_INVITE_USER_BY_CALL("chat_invite_user_by_call"),
CHAT_INVITE_USER_BY_CALL_LINK("chat_invite_user_by_call_join_link");
companion object {
fun parse(value: String) = values().first { it.value == value }
}
}
}
@@ -8,5 +8,11 @@ data class VkUser(
@PrimaryKey(autoGenerate = false)
val id: Int,
val firstName: String,
val lastName: String
)
val lastName: String,
val online: Boolean,
val photo200: String?
) {
override fun toString() = "$firstName $lastName".trim()
}
@@ -1,16 +0,0 @@
package com.meloda.fast.api.model.attachments
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVKAttachmentItem(
val type: String,
val photo: VKPhotoAttachment?,
val video: VKVideoAttachment?,
val audio: VKAudioAttachment?,
val doc: VKFileAttachment?,
val link: VKLinkAttachment?
) : Parcelable
abstract class BaseVKAttachment : Parcelable
@@ -0,0 +1,3 @@
package com.meloda.fast.api.model.attachments
abstract class VkAttachment
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkAudio(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkCall(
val initiatorId: Int
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkFile(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkGift(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkGraffiti(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkLink(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkMiniApp(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkPhoto(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkPoll(
val id: Int
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkSticker(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkVideo(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkVoiceMessage(
val link: String
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkWall(
val id: Int
) : VkAttachment()
@@ -0,0 +1,5 @@
package com.meloda.fast.api.model.attachments
data class VkWallReply(
val id: Int
) : VkAttachment()
@@ -31,12 +31,17 @@ data class BaseVkConversation(
@SerializedName("can_receive_money")
val canReceiveMoney: Boolean,
@SerializedName("chat_settings")
val chatSettings: ChatSettings?
val chatSettings: ChatSettings?,
@SerializedName("call_in_progress")
val callInProgress: CallInProgress?
) : Parcelable {
fun asVkConversation(lastMessage: VkMessage? = null) = VkConversation(
id = peer.id,
title = chatSettings?.title,
photo200 = chatSettings?.photo?.photo200,
type = peer.type,
callInProgress = callInProgress != null
).apply { this.lastMessage = lastMessage }
@Parcelize
@@ -83,7 +88,7 @@ data class BaseVkConversation(
val membersCount: Int,
@SerializedName("friends_count")
val friendsCount: Int,
val photo: Photo,
val photo: Photo?,
@SerializedName("admin_ids")
val adminsIds: List<Int>,
@SerializedName("active_ids")
@@ -93,7 +98,8 @@ data class BaseVkConversation(
@SerializedName("is_disappearing")
val isDisappearing: Boolean,
@SerializedName("is_service")
val isService: Boolean
val isService: Boolean,
val theme: String
) : Parcelable {
@Parcelize
@@ -125,13 +131,28 @@ data class BaseVkConversation(
@Parcelize
data class Photo(
@SerializedName("photo_50")
val photo50: String,
val photo50: String?,
@SerializedName("photo_100")
val photo100: String,
val photo100: String?,
@SerializedName("photo_200")
val photo200: String,
val photo200: String?,
@SerializedName("is_default_photo")
val isDefaultPhoto: Boolean
) : Parcelable
}
@Parcelize
data class CallInProgress(
val participants: Participants,
@SerializedName("join_link")
val joinLink: String
) : Parcelable {
@Parcelize
data class Participants(
val list: List<Int>,
val count: Int
) : Parcelable
}
}
@@ -0,0 +1,38 @@
package com.meloda.fast.api.model.base
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.meloda.fast.api.model.VkGroup
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkGroup(
val id: Int,
val name: String,
@SerializedName("screen_name")
val screenName: String,
@SerializedName("is_closed")
val isClosed: Int,
val type: String,
@SerializedName("is_admin")
val isAdmin: Int,
@SerializedName("is_member")
val isMember: Int,
@SerializedName("is_advertiser")
val isAdvertiser: Int,
@SerializedName("photo_50")
val photo50: String?,
@SerializedName("photo_100")
val photo100: String?,
@SerializedName("photo_200")
val photo200: String?
) : Parcelable {
fun asVkGroup() = VkGroup(
id = -id,
name = name,
screenName = screenName,
photo200 = photo200
)
}
@@ -2,9 +2,10 @@ package com.meloda.fast.api.model.base
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.meloda.fast.api.VkUtils
import com.meloda.fast.api.model.VkMessage
import com.meloda.fast.api.model.base.attachments.BaseVkAttachmentItem
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.RawValue
@Parcelize
data class BaseVkMessage(
@@ -19,25 +20,36 @@ data class BaseVkMessage(
@SerializedName("conversation_message_id")
val conversationMessageId: Int,
@SerializedName("fwd_messages")
val fwdMessages: List<BaseVkMessage> = listOf(),
val fwdMessages: List<BaseVkMessage>? = listOf(),
val important: Boolean,
@SerializedName("random_id")
val randomId: Int,
val attachments: @RawValue List<Any> = listOf(),
val attachments: List<BaseVkAttachmentItem> = listOf(),
@SerializedName("is_hidden")
val isHidden: Boolean,
val payload: String,
val geo: Geo?
val geo: Geo?,
val action: Action?,
val ttl: Int
) : Parcelable {
fun asVkMessage() = VkMessage(
id = id,
text = text,
text = if (text.isBlank()) null else text,
isOut = out == 1,
peerId = peerId,
fromId = fromId,
date = date
)
date = date,
action = action?.type,
actionMemberId = action?.memberId,
actionText = action?.text,
actionConversationMessageId = action?.conversationMessageId,
actionMessage = action?.message,
geoType = geo?.type
).also {
it.attachments = VkUtils.parseAttachments(attachments)
it.forwards = VkUtils.parseForwards(fwdMessages)
}
@Parcelize
data class Geo(
@@ -54,4 +66,15 @@ data class BaseVkMessage(
data class Place(val country: String, val city: String, val title: String) : Parcelable
}
@Parcelize
data class Action(
val type: String,
@SerializedName("member_id")
val memberId: Int?,
val text: String?,
@SerializedName("conversation_message_id")
val conversationMessageId: Int?,
val message: String?
) : Parcelable
}
@@ -50,7 +50,9 @@ data class BaseVkUser(
fun asVkUser() = VkUser(
id = id,
firstName = firstName,
lastName = lastName
lastName = lastName,
online = online == 1,
photo200 = photo200
)
}
@@ -0,0 +1,56 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkAttachmentItem(
val type: String,
val photo: BaseVkPhoto?,
val video: BaseVkVideo?,
val audio: BaseVkAudio?,
@SerializedName("doc")
val file: BaseVkFile?,
val link: BaseVkLink?,
@SerializedName("mini_app")
val miniApp: BaseVkMiniApp?,
@SerializedName("audio_message")
val voiceMessage: BaseVkVoiceMessage?,
val sticker: BaseVkSticker?,
val gift: BaseVkGift?,
val wall: BaseVkWall?,
val graffiti: BaseVkGraffiti?,
val poll: BaseVkPoll?,
@SerializedName("wall_reply")
val wallReply: BaseVkWallReply?,
val call: BaseVkCall?
) : Parcelable {
fun getPreparedType() = AttachmentType.parse(type)
enum class AttachmentType(val value: String) {
PHOTO("photo"),
VIDEO("video"),
AUDIO("audio"),
FILE("doc"),
LINK("link"),
VOICE("audio_message"),
MINI_APP("mini_app"),
STICKER("sticker"),
GIFT("gift"),
WALL("wall"),
GRAFFITI("graffiti"),
POLL("poll"),
WALL_REPLY("wall_reply"),
CALL("call")
;
companion object {
fun parse(value: String) = values().firstOrNull { it.value == value }
}
}
}
abstract class BaseVkAttachment : Parcelable
@@ -1,11 +1,11 @@
package com.meloda.fast.api.model.attachments
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class VKAudioAttachment(
data class BaseVkAudio(
val id: Int,
val title: String,
val artist: String,
@@ -33,7 +33,7 @@ data class VKAudioAttachment(
val storiesAllowed: Boolean,
@SerializedName("stories_cover_allowed")
val storiesCoverAllowed: Boolean
) : BaseVKAttachment() {
) : BaseVkAttachment() {
@Parcelize
data class Album(
@@ -0,0 +1,17 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkCall(
@SerializedName("initiator_id")
val initiatorId: Int,
@SerializedName("receiver_id")
val receiverId: Int,
val state: String,
val time: Int,
val duration: Int,
val video: Boolean
) : Parcelable
@@ -1,11 +1,11 @@
package com.meloda.fast.api.model.attachments
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class VKFileAttachment(
data class BaseVkFile(
val id: Int,
@SerializedName("owner_id")
val ownerId: Int,
@@ -22,7 +22,7 @@ data class VKFileAttachment(
val accessKey: String,
@SerializedName("web_preview_url")
val webPreviewUrl: String?
) : BaseVKAttachment() {
) : BaseVkAttachment() {
@Parcelize
data class Preview(
@@ -0,0 +1,16 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkGift(
val id: Int,
@SerializedName("thumb_256")
val thumb256: String?,
@SerializedName("thumb_96")
val thumb96: String?,
@SerializedName("thumb_48")
val thumb48: String
) : Parcelable
@@ -0,0 +1,17 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkGraffiti(
val id: Int,
@SerializedName("owner_id")
val ownerId: Int,
val url: String,
val width: Int,
val height: Int,
@SerializedName("access_key")
val accessKey: String
) : Parcelable
@@ -1,15 +1,15 @@
package com.meloda.fast.api.model.attachments
package com.meloda.fast.api.model.base.attachments
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class VKLinkAttachment(
data class BaseVkLink(
val url: String,
val title: String,
val caption: String,
val photo: VKPhotoAttachment,
val photo: BaseVkPhoto,
val target: String,
@SerializedName("is_favorite")
val isFavorite: Boolean
) : BaseVKAttachment()
) : BaseVkAttachment()
@@ -0,0 +1,67 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkMiniApp(
val title: String,
val description: String,
val app: App,
val images: List<Image>?,
@SerializedName("button_text")
val buttonText: String
) : Parcelable {
@Parcelize
data class App(
val type: String,
val id: Int,
val title: String,
@SerializedName("author_owner_id")
val authorOwnerId: Int,
@SerializedName("are_notifications_enabled")
val areNotificationsEnabled: Boolean,
@SerializedName("is_favorite")
val isFavorite: Boolean,
@SerializedName("is_installed")
val isInstalled: Boolean,
@SerializedName("track_code")
val trackCode: String,
@SerializedName("share_url")
val shareUrl: String,
@SerializedName("webview_url")
val webViewUrl: String,
@SerializedName("hide_tabbar")
val hideTabBar: Int,
@SerializedName("icon_75")
val icon75: String?,
@SerializedName("icon_139")
val icon139: String?,
@SerializedName("icon_150")
val icon150: String?,
@SerializedName("icon_278")
val icon278: String?,
@SerializedName("icon_576")
val icon576: String?,
@SerializedName("open_in_external_browser")
val openInExternalBrowser: Boolean,
@SerializedName("need_policy_confirmation")
val needPolicyConfirmation: Boolean,
@SerializedName("is_vkui_internal")
val isVkUiInternal: Boolean,
@SerializedName("has_vk_connect")
val hasVkConnect: Boolean,
@SerializedName("need_show_bottom_menu_tooltip_on_close")
val needShowBottomMenuTooltipOnClose: Boolean
) : Parcelable
@Parcelize
data class Image(
val height: Int,
val width: Int,
val url: String
) : Parcelable
}
@@ -1,11 +1,11 @@
package com.meloda.fast.api.model.attachments
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class VKPhotoAttachment(
data class BaseVkPhoto(
@SerializedName("album_id")
val albumId: Int,
val date: Int,
@@ -20,7 +20,7 @@ data class VKPhotoAttachment(
val text: String,
@SerializedName("user_id")
val userId: Int?
) : BaseVKAttachment()
) : BaseVkAttachment()
@Parcelize
data class Size(
@@ -0,0 +1,72 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkPoll(
val multiple: Boolean,
val id: Int,
val votes: Int,
val anonymous: Boolean,
val closed: Boolean,
@SerializedName("end_date")
val endDate: Int,
@SerializedName("is_board")
val isBoard: Boolean,
@SerializedName("can_vote")
val canVote: Boolean,
@SerializedName("can_edit")
val canEdit: Boolean,
@SerializedName("can_report")
val canReport: Boolean,
@SerializedName("can_share")
val canShare: Boolean,
val created: Int,
@SerializedName("owner_id")
val ownerId: Int,
val question: String,
@SerializedName("disable_unvote")
val disableUnVote: Boolean,
val friends: List<Friend>?,
@SerializedName("embed_hash")
val embedHash: String,
val answers: List<Answer>,
@SerializedName("author_id")
val authorId: Int,
val background: Background?
) : Parcelable {
@Parcelize
data class Friend(
val id: Int
) : Parcelable
@Parcelize
data class Answer(
val id: Int,
val rate: Double,
val text: String,
val votes: Int
) : Parcelable
@Parcelize
data class Background(
val angle: Int,
val color: String,
val id: Int,
val name: String,
val type: String,
val points: List<Point>
) : Parcelable {
@Parcelize
data class Point(
val color: String,
val position: Double
) : Parcelable
}
}
@@ -0,0 +1,35 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkSticker(
@SerializedName("product_id")
val productId: Int,
@SerializedName("sticker_id")
val stickerId: Int,
val images: List<Image>,
@SerializedName("images_with_background")
val imagesWithBackground: List<Image>,
@SerializedName("animation_url")
val animationUrl: String?,
val animations: List<Animation>?
) : Parcelable {
@Parcelize
data class Image(
val width: Int,
val height: Int,
val url: String
) : Parcelable
@Parcelize
data class Animation(
val type: String,
val url: String
) : Parcelable
}
@@ -1,11 +1,11 @@
package com.meloda.fast.api.model.attachments
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class VKVideoAttachment(
data class BaseVkVideo(
val id: Int,
val title: String,
val width: Int,
@@ -47,11 +47,11 @@ data class VKVideoAttachment(
val image: List<Image>,
@SerializedName("first_frame")
val firstFrame: List<FirstFrame>,
val files: List<File>,
val files: File,
@SerializedName("timeline_thumbs")
val timelineThumbs: TimelineThumbs
//ads
) : BaseVKAttachment() {
) : BaseVkAttachment() {
@Parcelize
data class Image(
@@ -71,12 +71,12 @@ data class VKVideoAttachment(
@Parcelize
data class File(
val mp4_240: String,
val mp4_360: String,
val mp4_480: String,
val mp4_720: String,
val mp4_1080: String,
val mp4_1440: String,
val mp4_240: String?,
val mp4_360: String?,
val mp4_480: String?,
val mp4_720: String?,
val mp4_1080: String?,
val mp4_1440: String?,
val hls: String,
@SerializedName("dash_uni")
val dashUni: String,
@@ -0,0 +1,23 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkVoiceMessage(
val id: Int,
@SerializedName("owner_id")
val ownerId: Int,
val duration: Int,
val waveform: List<Int>,
@SerializedName("link_ogg")
val linkOgg: String,
@SerializedName("link_mp3")
val linkMp3: String,
@SerializedName("access_key")
val accessKey: String,
@SerializedName("transcript_state")
val transcriptState: String,
val transcript: String
) : Parcelable
@@ -0,0 +1,76 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkWall(
val id: Int,
@SerializedName("from_id")
val fromId: Int,
@SerializedName("to_id")
val toId: Int,
val date: Int,
val text: String,
val attachments: List<BaseVkAttachmentItem>?,
@SerializedName("post_source")
val postSource: PostSource,
val comments: Comments,
val likes: Likes,
val reposts: Reposts,
val views: Views,
@SerializedName("is_favorite")
val isFavorite: Boolean,
val donut: Donut,
@SerializedName("access_key")
val accessKey: String,
@SerializedName("short_text_rate")
val shortTextRate: Double
) : Parcelable {
@Parcelize
data class PostSource(
val type: String,
val platform: String
) : Parcelable
@Parcelize
data class Comments(
val count: Int,
@SerializedName("can_post")
val canPost: Int,
@SerializedName("groups_can_post")
val groupsCanPost: Boolean
) : Parcelable
@Parcelize
data class Likes(
val count: Int,
@SerializedName("user_likes")
val userLikes: Int,
@SerializedName("can_like")
val canLike: Int,
@SerializedName("can_publish")
val canPublish: Int,
) : Parcelable
@Parcelize
data class Reposts(
val count: Int,
@SerializedName("user_reposted")
val userReposted: Int
) : Parcelable
@Parcelize
data class Views(
val count: Int
) : Parcelable
@Parcelize
data class Donut(
@SerializedName("is_donut")
val isDonut: Boolean
) : Parcelable
}
@@ -0,0 +1,39 @@
package com.meloda.fast.api.model.base.attachments
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
@Parcelize
data class BaseVkWallReply(
val id: Int,
@SerializedName("from_id")
val fromId: Int,
val date: Int,
val text: String,
@SerializedName("post_id")
val postId: Int,
@SerializedName("owner_id")
val ownerId: Int,
@SerializedName("parents_stack")
val parentsStack: List<Int>,
val likes: Likes,
@SerializedName("reply_to_user")
val replyToUser: Int?,
@SerializedName("reply_to_comment")
val replyToComment: Int?
) : Parcelable {
@Parcelize
data class Likes(
val count: Int,
@SerializedName("can_like")
val canLike: Int,
@SerializedName("user_likes")
val userLikes: Int,
@SerializedName("can_publish")
val canPublish: Int
) : Parcelable
}
@@ -18,20 +18,20 @@ object VKAttachments {
val jsonObject = attachment.optJSONObject(type.value) ?: continue
when (type) {
Type.PHOTO -> attachments.add(VKPhoto(jsonObject))
Type.AUDIO -> attachments.add(VKAudio(jsonObject))
Type.VIDEO -> attachments.add(VKVideo(jsonObject))
Type.DOCUMENT -> attachments.add(VKDocument(jsonObject))
Type.STICKER -> attachments.add(VKSticker(jsonObject))
Type.LINK -> attachments.add(VKLink(jsonObject))
Type.GIFT -> attachments.add(VKGift(jsonObject))
Type.VOICE_MESSAGE -> attachments.add(VKAudioMessage(jsonObject))
Type.GRAFFITI -> attachments.add(VKGraffiti(jsonObject))
Type.POLL -> attachments.add(VKPoll(jsonObject))
// Type.PHOTO -> attachments.add(oldVKPhoto(jsonObject))
// Type.AUDIO -> attachments.add(oldVKAudio(jsonObject))
// Type.VIDEO -> attachments.add(oldVKVideo(jsonObject))
// Type.DOCUMENT -> attachments.add(oldVKDocument(jsonObject))
// Type.STICKER -> attachments.add(oldVKSticker(jsonObject))
// Type.LINK -> attachments.add(oldVKLink(jsonObject))
// Type.GIFT -> attachments.add(VKGift(jsonObject))
// Type.VOICE_MESSAGE -> attachments.add(oldVKAudioMessage(jsonObject))
// Type.GRAFFITI -> attachments.add(VKGraffiti(jsonObject))
Type.POLL -> attachments.add(oldVKPoll(jsonObject))
Type.CALL -> attachments.add(VKCall(jsonObject))
Type.WALL_POST -> attachments.add(VKWall(jsonObject))
Type.WALL_REPLY -> attachments.add(VKComment(jsonObject))
Type.GEOLOCATION -> attachments.add(VKGeolocation(jsonObject))
// Type.WALL_POST -> attachments.add(VKWall(jsonObject))
Type.WALL_REPLY -> attachments.add(oldVKComment(jsonObject))
// Type.GEOLOCATION -> attachments.add(oldVKGeolocation(jsonObject))
else -> continue
}
}
@@ -9,6 +9,6 @@ class VKLongPollHistory : VKModel() {
private val lpMessages: ArrayList<oldVKMessage>? = null
private val messages: ArrayList<oldVKMessage>? = null
private val profiles: ArrayList<oldVKUser>? = null
private val groups: ArrayList<VKGroup>? = null //TODO: использовать
private val groups: ArrayList<oldVKGroup>? = null //TODO: использовать
}
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKAudio() : VKModel() {
class oldVKAudio() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKAudioMessage() : VKModel() {
class oldVKAudioMessage() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKComment() : VKModel() { //https://vk.com/dev/objects/comment
class oldVKComment() : VKModel() { //https://vk.com/dev/objects/comment
companion object {
const val serialVersionUID: Long = 1L
@@ -10,7 +10,7 @@ class oldVKConversation() : VKModel(), Cloneable {
const val serialVersionUID: Long = 1L
var profiles = arrayListOf<oldVKUser>()
var groups = arrayListOf<VKGroup>()
var groups = arrayListOf<oldVKGroup>()
var conversationsCount: Int = 0
@@ -56,7 +56,7 @@ class oldVKConversation() : VKModel(), Cloneable {
var peerUser: oldVKUser? = null
var peerGroup: VKGroup? = null
var peerGroup: oldVKGroup? = null
constructor(o: JSONObject) : this() {
inReadMessageId = o.optInt("in_read")
@@ -4,7 +4,7 @@ import org.json.JSONObject
import java.io.Serializable
import java.util.*
class VKDocument() : VKModel() {
class oldVKDocument() : VKModel() {
override val attachmentType = VKAttachments.Type.DOCUMENT
@@ -47,13 +47,13 @@ class VKDocument() : VKModel() {
inner class Photo(o: JSONObject) : Serializable {
var sizes: ArrayList<VKPhotoSize>? = null
var sizes: ArrayList<oldVKPhotoSize>? = null
init {
o.optJSONArray("sizes")?.let {
val sizes = ArrayList<VKPhotoSize>()
val sizes = ArrayList<oldVKPhotoSize>()
for (i in 0 until it.length()) {
sizes.add(VKPhotoSize(it.optJSONObject(i)))
sizes.add(oldVKPhotoSize(it.optJSONObject(i)))
}
this.sizes = sizes
}
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKGeolocation() : VKModel() {
class oldVKGeolocation() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKGift() : VKModel() {
class oldVKGift() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKGraffiti() : VKModel() {
class oldVKGraffiti() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -3,7 +3,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONArray
import org.json.JSONObject
open class VKGroup() : VKModel() {
open class oldVKGroup() : VKModel() {
override val attachmentType = VKAttachments.Type.NONE
@@ -11,11 +11,11 @@ open class VKGroup() : VKModel() {
const val serialVersionUID: Long = 1L
fun parse(array: JSONArray): ArrayList<VKGroup> {
val groups = ArrayList<VKGroup>()
fun parse(array: JSONArray): ArrayList<oldVKGroup> {
val groups = ArrayList<oldVKGroup>()
for (i in 0 until array.length()) {
groups.add(VKGroup(array.optJSONObject(i)))
groups.add(oldVKGroup(array.optJSONObject(i)))
}
return groups
}
@@ -3,7 +3,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.io.Serializable
class VKLink() : VKModel() {
class oldVKLink() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -17,7 +17,7 @@ class VKLink() : VKModel() {
var description: String = ""
var previewPage: String = ""
var previewUrl: String = ""
var photo: VKPhoto? = null
var photo: oldVKPhoto? = null
var button: Button? = null
constructor(o: JSONObject): this() {
@@ -29,7 +29,7 @@ class VKLink() : VKModel() {
previewUrl = o.optString("preview_url")
o.optJSONObject("photo")?.let {
photo = VKPhoto(it)
photo = oldVKPhoto(it)
}
o.optJSONObject("button")?.let {
@@ -1,7 +1,7 @@
package com.meloda.fast.api.model.old
import android.util.ArrayMap
import com.meloda.fast.api.VKUtil
import com.meloda.fast.api.oldVKUtil
import org.json.JSONObject
open class oldVKMessage() : VKModel() {
@@ -11,7 +11,7 @@ open class oldVKMessage() : VKModel() {
companion object {
var profiles = arrayListOf<oldVKUser>()
var groups = arrayListOf<VKGroup>()
var groups = arrayListOf<oldVKGroup>()
var conversations = arrayListOf<oldVKConversation>()
const val serialVersionUID: Long = 1L
@@ -101,11 +101,11 @@ open class oldVKMessage() : VKModel() {
var replyMessage: oldVKMessage? = null
var action: VKMessageAction? = null
var action: oldVKMessageAction? = null
var fromUser: oldVKUser? = null
var fromGroup: VKGroup? = null
var fromGroup: oldVKGroup? = null
constructor(o: JSONObject) : this() {
id = o.optInt("id", -1)
@@ -115,7 +115,7 @@ open class oldVKMessage() : VKModel() {
editTime = o.optInt("edit_time", -1)
isOut = o.optInt("out") == 1
text = VKUtil.prepareMessageText(o.optString("text"))
text = oldVKUtil.prepareMessageText(o.optString("text"))
randomId = o.optInt("random_id", -1)
conversationMessageId = o.optInt("conversation_message_id", -1)
@@ -138,7 +138,7 @@ open class oldVKMessage() : VKModel() {
}
o.optJSONObject("action")?.let {
action = VKMessageAction(it)
action = oldVKMessageAction(it)
}
}
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKMessageAction() : VKModel() {
class oldVKMessageAction() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -3,7 +3,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.util.*
class VKPhoto() : VKModel() {
class oldVKPhoto() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -18,7 +18,7 @@ class VKPhoto() : VKModel() {
var date: Int = 0
var width: Int = 0
var height: Int = 0
var sizes: ArrayList<VKPhotoSize>? = null
var sizes: ArrayList<oldVKPhotoSize>? = null
constructor(o: JSONObject) : this() {
id = o.optInt("id", -1)
@@ -30,9 +30,9 @@ class VKPhoto() : VKModel() {
height = o.optInt("height")
o.optJSONArray("sizes")?.let {
val sizes = ArrayList<VKPhotoSize>()
val sizes = ArrayList<oldVKPhotoSize>()
for (i in 0 until it.length()) {
sizes.add(VKPhotoSize(it.optJSONObject(i)))
sizes.add(oldVKPhotoSize(it.optJSONObject(i)))
}
this.sizes = sizes
}
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKPhotoSize(o: JSONObject) : VKModel() {
class oldVKPhotoSize(o: JSONObject) : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKPoll() : VKModel() {
class oldVKPoll() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -3,7 +3,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
import java.util.*
class VKSticker() : VKModel() {
class oldVKSticker() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -4,7 +4,7 @@ import com.meloda.fast.api.model.old.VKAttachments
import com.meloda.fast.api.model.old.VKModel
import org.json.JSONObject
class VKVideo() : VKModel() {
class oldVKVideo() : VKModel() {
companion object {
const val serialVersionUID: Long = 1L
@@ -2,7 +2,7 @@ package com.meloda.fast.api.model.old
import org.json.JSONObject
class VKWall() : VKModel() { //https://vk.com/dev/objects/post
class oldVKWall() : VKModel() { //https://vk.com/dev/objects/post
companion object {
const val serialVersionUID: Long = 1L