test conversations loading
This commit is contained in:
@@ -6,9 +6,9 @@ class VKLongPollHistory : VKModel() {
|
||||
|
||||
override val attachmentType = VKAttachments.Type.NONE
|
||||
|
||||
private val lpMessages: ArrayList<VKMessage>? = null
|
||||
private val messages: ArrayList<VKMessage>? = null
|
||||
private val profiles: ArrayList<VKUser>? = null
|
||||
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: использовать
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class VKMessageAction() : VKModel() {
|
||||
|
||||
var type: Type = Type.NONE
|
||||
var memberId = 0
|
||||
var message: VKMessage? = null
|
||||
var message: oldVKMessage? = null
|
||||
var conversationMessageId: Int = 0
|
||||
var text: String = ""
|
||||
var oldText: String = ""
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.meloda.fast.api.model
|
||||
|
||||
data class VkConversation(
|
||||
val id: Int,
|
||||
val title: String?,
|
||||
val lastMessage: VkMessage
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.meloda.fast.api.model
|
||||
|
||||
data class VkMessage(
|
||||
val id: Int,
|
||||
val text: String?,
|
||||
val isOut: Boolean,
|
||||
val peerId: Int,
|
||||
val fromId: Int,
|
||||
val date: Int
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.meloda.fast.api.model
|
||||
|
||||
data class VkUser(
|
||||
val id: Int,
|
||||
val firstName: String,
|
||||
val lastName: String
|
||||
)
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package com.meloda.fast.api.model
|
||||
package com.meloda.fast.api.model.base
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class BaseVKConversation(
|
||||
data class BaseVkConversation(
|
||||
val peer: Peer,
|
||||
@SerializedName("last_message_id")
|
||||
val lastMessageId: Int,
|
||||
@@ -29,7 +29,7 @@ data class BaseVKConversation(
|
||||
@SerializedName("can_receive_money")
|
||||
val canReceiveMoney: Boolean,
|
||||
@SerializedName("chat_settings")
|
||||
val chatSettings: ChatSettings
|
||||
val chatSettings: ChatSettings?
|
||||
) : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.meloda.fast.api.model
|
||||
package com.meloda.fast.api.model.base
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
@@ -6,7 +6,7 @@ import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.parcelize.RawValue
|
||||
|
||||
@Parcelize
|
||||
data class BaseVKMessage(
|
||||
data class BaseVkMessage(
|
||||
val date: Int,
|
||||
@SerializedName("from_id")
|
||||
val fromId: Int,
|
||||
@@ -18,7 +18,7 @@ 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,
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.meloda.fast.api.model.base
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class BaseVkUser(
|
||||
val id: Int,
|
||||
@SerializedName("first_name")
|
||||
val firstName: String,
|
||||
@SerializedName("last_name")
|
||||
val lastName: String,
|
||||
@SerializedName("can_access_closed")
|
||||
val canAccessClosed: Boolean,
|
||||
@SerializedName("is_closed")
|
||||
val isClosed: Boolean,
|
||||
@SerializedName("can_invite_to_chats")
|
||||
val canInviteToChats: Boolean,
|
||||
val sex: Int?,
|
||||
@SerializedName("photo_50")
|
||||
val photo50: String?,
|
||||
@SerializedName("photo_100")
|
||||
val photo100: String?,
|
||||
@SerializedName("photo_200")
|
||||
val photo200: String?,
|
||||
val online: Int?,
|
||||
@SerializedName("online_info")
|
||||
val onlineInfo: OnlineInfo?,
|
||||
@SerializedName("screen_name")
|
||||
val screenName: String
|
||||
//...other fields
|
||||
) : Parcelable {
|
||||
|
||||
@Parcelize
|
||||
data class OnlineInfo(
|
||||
val visible: Boolean,
|
||||
val status: String,
|
||||
@SerializedName("last_seen")
|
||||
val lastSeen: Int?,
|
||||
@SerializedName("is_online")
|
||||
val isOnline: Boolean?,
|
||||
@SerializedName("online_mobile")
|
||||
val isOnlineMobile: Boolean?,
|
||||
@SerializedName("app_id")
|
||||
val appId: Int?
|
||||
) : Parcelable
|
||||
|
||||
}
|
||||
+7
-7
@@ -2,14 +2,14 @@ package com.meloda.fast.api.model
|
||||
|
||||
import org.json.JSONObject
|
||||
|
||||
class VKConversation() : VKModel(), Cloneable {
|
||||
class oldVKConversation() : VKModel(), Cloneable {
|
||||
|
||||
override val attachmentType = VKAttachments.Type.NONE
|
||||
|
||||
companion object {
|
||||
const val serialVersionUID: Long = 1L
|
||||
|
||||
var profiles = arrayListOf<VKUser>()
|
||||
var profiles = arrayListOf<oldVKUser>()
|
||||
var groups = arrayListOf<VKGroup>()
|
||||
|
||||
var conversationsCount: Int = 0
|
||||
@@ -41,12 +41,12 @@ class VKConversation() : VKModel(), Cloneable {
|
||||
var membersCount: Int = 0
|
||||
var title: String? = null
|
||||
|
||||
var pinnedMessage: VKMessage? = null
|
||||
var pinnedMessage: oldVKMessage? = null
|
||||
|
||||
var intState: Int = 0
|
||||
var state: State = State.IN
|
||||
|
||||
var lastMessage: VKMessage = VKMessage()
|
||||
var lastMessage: oldVKMessage = oldVKMessage()
|
||||
|
||||
var isGroupChannel: Boolean = false
|
||||
|
||||
@@ -54,7 +54,7 @@ class VKConversation() : VKModel(), Cloneable {
|
||||
var photo100: String = ""
|
||||
var photo200: String = ""
|
||||
|
||||
var peerUser: VKUser? = null
|
||||
var peerUser: oldVKUser? = null
|
||||
|
||||
var peerGroup: VKGroup? = null
|
||||
|
||||
@@ -87,7 +87,7 @@ class VKConversation() : VKModel(), Cloneable {
|
||||
if (title?.isBlank() == true) title = null
|
||||
|
||||
it.optJSONObject("pinned_message")?.let { pinned ->
|
||||
pinnedMessage = VKMessage(pinned)
|
||||
pinnedMessage = oldVKMessage(pinned)
|
||||
}
|
||||
|
||||
state = State.fromString(it.optString("state"))
|
||||
@@ -112,7 +112,7 @@ class VKConversation() : VKModel(), Cloneable {
|
||||
|
||||
override fun toString() = title ?: ""
|
||||
|
||||
public override fun clone() = super.clone() as VKConversation
|
||||
public override fun clone() = super.clone() as oldVKConversation
|
||||
|
||||
enum class Type(val value: String) {
|
||||
NULL("null"),
|
||||
+10
-10
@@ -4,15 +4,15 @@ import android.util.ArrayMap
|
||||
import com.meloda.fast.api.VKUtil
|
||||
import org.json.JSONObject
|
||||
|
||||
open class VKMessage() : VKModel() {
|
||||
open class oldVKMessage() : VKModel() {
|
||||
|
||||
override val attachmentType = VKAttachments.Type.NONE
|
||||
|
||||
companion object {
|
||||
|
||||
var profiles = arrayListOf<VKUser>()
|
||||
var profiles = arrayListOf<oldVKUser>()
|
||||
var groups = arrayListOf<VKGroup>()
|
||||
var conversations = arrayListOf<VKConversation>()
|
||||
var conversations = arrayListOf<oldVKConversation>()
|
||||
|
||||
const val serialVersionUID: Long = 1L
|
||||
|
||||
@@ -97,13 +97,13 @@ open class VKMessage() : VKModel() {
|
||||
|
||||
var attachments: ArrayList<VKModel> = arrayListOf()
|
||||
|
||||
var fwdMessages: ArrayList<VKMessage> = arrayListOf()
|
||||
var fwdMessages: ArrayList<oldVKMessage> = arrayListOf()
|
||||
|
||||
var replyMessage: VKMessage? = null
|
||||
var replyMessage: oldVKMessage? = null
|
||||
|
||||
var action: VKMessageAction? = null
|
||||
|
||||
var fromUser: VKUser? = null
|
||||
var fromUser: oldVKUser? = null
|
||||
|
||||
var fromGroup: VKGroup? = null
|
||||
|
||||
@@ -126,15 +126,15 @@ open class VKMessage() : VKModel() {
|
||||
}
|
||||
|
||||
o.optJSONArray("fwd_messages")?.let {
|
||||
val fwdMessages = ArrayList<VKMessage>(it.length())
|
||||
val fwdMessages = ArrayList<oldVKMessage>(it.length())
|
||||
for (i in 0 until it.length()) {
|
||||
fwdMessages.add(VKMessage(it.optJSONObject(i)))
|
||||
fwdMessages.add(oldVKMessage(it.optJSONObject(i)))
|
||||
}
|
||||
this.fwdMessages = fwdMessages
|
||||
}
|
||||
|
||||
o.optJSONObject("reply_message")?.let {
|
||||
replyMessage = VKMessage(it)
|
||||
replyMessage = oldVKMessage(it)
|
||||
}
|
||||
|
||||
o.optJSONObject("action")?.let {
|
||||
@@ -142,7 +142,7 @@ open class VKMessage() : VKModel() {
|
||||
}
|
||||
}
|
||||
|
||||
fun getForwardedMessages() = ArrayList<VKMessage>().apply {
|
||||
fun getForwardedMessages() = ArrayList<oldVKMessage>().apply {
|
||||
for (model in fwdMessages) add(model)
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@ package com.meloda.fast.api.model
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
open class VKUser() : VKModel() {
|
||||
open class oldVKUser() : VKModel() {
|
||||
|
||||
override val attachmentType = VKAttachments.Type.NONE
|
||||
|
||||
@@ -12,11 +12,11 @@ open class VKUser() : VKModel() {
|
||||
|
||||
var friendsCount: Int = 0
|
||||
|
||||
fun parse(array: JSONArray): ArrayList<VKUser> {
|
||||
val users = ArrayList<VKUser>()
|
||||
fun parse(array: JSONArray): ArrayList<oldVKUser> {
|
||||
val users = ArrayList<oldVKUser>()
|
||||
|
||||
for (i in 0 until array.length()) {
|
||||
users.add(VKUser(array.optJSONObject(i)))
|
||||
users.add(oldVKUser(array.optJSONObject(i)))
|
||||
}
|
||||
|
||||
return users
|
||||
Reference in New Issue
Block a user