DM refactoring

This commit is contained in:
Mariotaku Lee 2018-02-01 11:40:06 +08:00
parent 61da4c2453
commit deadd3a0a8
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
19 changed files with 430 additions and 235 deletions

View File

@ -19,10 +19,10 @@
package org.mariotaku.microblog.library.api.twitter;
import org.mariotaku.microblog.library.MicroBlogException;
import org.mariotaku.microblog.library.model.microblog.DirectMessageEventObject;
import org.mariotaku.microblog.library.model.microblog.PageableResponseList;
import org.mariotaku.microblog.library.model.Paging;
import org.mariotaku.microblog.library.model.microblog.ResponseCode;
import org.mariotaku.microblog.library.model.twitter.dm.DirectMessageEventList;
import org.mariotaku.microblog.library.model.twitter.dm.DirectMessageEventObject;
import org.mariotaku.microblog.library.template.twitter.DirectMessageAnnotationTemplate;
import org.mariotaku.restfu.annotation.method.DELETE;
import org.mariotaku.restfu.annotation.method.GET;
@ -38,8 +38,7 @@ public interface DirectMessagesEventResources {
@GET("/direct_messages/events/list.json")
@BodyType(BodyType.FORM)
PageableResponseList<DirectMessageEventObject> getDirectMessageEvents(@Query Paging paging)
throws MicroBlogException;
DirectMessageEventList getDirectMessageEvents(@Query Paging paging) throws MicroBlogException;
@POST("/direct_messages/events/new.json")
@BodyType(BodyType.RAW)

View File

@ -23,7 +23,7 @@ import android.support.annotation.Nullable;
import org.mariotaku.microblog.library.MicroBlogException;
import org.mariotaku.microblog.library.model.microblog.ConversationTimeline;
import org.mariotaku.microblog.library.model.microblog.DMResponse;
import org.mariotaku.microblog.library.model.twitter.NewDm;
import org.mariotaku.microblog.library.model.twitter.dm.NewDm;
import org.mariotaku.microblog.library.model.Paging;
import org.mariotaku.microblog.library.model.microblog.ResponseCode;
import org.mariotaku.microblog.library.model.microblog.UserEvents;

View File

@ -1,177 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 org.mariotaku.microblog.library.model.microblog;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
/**
* Created by mariotaku on 2017/5/11.
*/
@JsonObject
public class DirectMessageEventObject {
@JsonField(name = "event")
Event event;
public Event getEvent() {
return event;
}
public void setEvent(Event event) {
this.event = event;
}
@JsonObject
public static class Event {
@JsonField(name = "id")
String id;
@JsonField(name = "type")
String type;
@JsonField(name = "message_create")
MessageCreate messageCreate;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public MessageCreate getMessageCreate() {
return messageCreate;
}
public void setMessageCreate(MessageCreate messageCreate) {
this.messageCreate = messageCreate;
}
public String getId() {
return id;
}
@JsonObject
public static class MessageCreate {
@JsonField(name = "target")
Target target;
@JsonField(name = "message_data")
MessageData messageData;
public Target getTarget() {
return target;
}
public void setTarget(Target target) {
this.target = target;
}
public MessageData getMessageData() {
return messageData;
}
public void setMessageData(MessageData messageData) {
this.messageData = messageData;
}
@JsonObject
public static class Target {
@JsonField(name = "recipient_id")
String recipientId;
public String getRecipientId() {
return recipientId;
}
public void setRecipientId(String recipientId) {
this.recipientId = recipientId;
}
}
@JsonObject
public static class MessageData {
@JsonField(name = "text")
String text;
@JsonField(name = "attachment")
Attachment attachment;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Attachment getAttachment() {
return attachment;
}
public void setAttachment(Attachment attachment) {
this.attachment = attachment;
}
@JsonObject
public static class Attachment {
@JsonField(name = "type")
String type;
@JsonField(name = "media")
Media media;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Media getMedia() {
return media;
}
public void setMedia(Media media) {
this.media = media;
}
@JsonObject
public static class Media {
@JsonField(name = "id")
String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
}
}
}
}
}

View File

@ -38,8 +38,8 @@ import java.util.Map;
@ParcelablePlease
@JsonObject
public class MediaEntity extends UrlEntity implements Parcelable {
@JsonField(name = "id")
long id;
@JsonField(name = {"id_str", "id"})
protected String id;
@JsonField(name = "indices", typeConverter = IndicesConverter.class)
Indices indices;
@ -125,7 +125,7 @@ public class MediaEntity extends UrlEntity implements Parcelable {
return indices.getStart();
}
public long getId() {
public String getId() {
return id;
}

View File

@ -0,0 +1,44 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 org.mariotaku.microblog.library.model.twitter.dm;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
@JsonObject
public class App {
@JsonField(name = "id")
String id;
@JsonField(name = "name")
String name;
@JsonField(name = "url")
String url;
public String getId() {
return id;
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
}

View File

@ -0,0 +1,57 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 org.mariotaku.microblog.library.model.twitter.dm;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.microblog.library.model.microblog.MediaEntity;
@JsonObject
public class Attachment {
@JsonField(name = "type")
String type;
@JsonField(name = "media")
Media media;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Media getMedia() {
return media;
}
public void setMedia(Media media) {
this.media = media;
}
@JsonObject
public static class Media extends MediaEntity {
public void setId(String id) {
this.id = id;
}
}
}

View File

@ -0,0 +1,142 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 org.mariotaku.microblog.library.model.twitter.dm;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.microblog.library.model.microblog.Entities;
@JsonObject
public class DirectMessageEvent {
@JsonField(name = "id")
String id;
@JsonField(name = "created_timestamp")
long created_timestamp;
@JsonField(name = "type")
String type;
@JsonField(name = "message_create")
MessageCreate messageCreate;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public MessageCreate getMessageCreate() {
return messageCreate;
}
public void setMessageCreate(MessageCreate messageCreate) {
this.messageCreate = messageCreate;
}
public String getId() {
return id;
}
@JsonObject
public static class MessageCreate {
@JsonField(name = "sender_id")
String senderId;
@JsonField(name = "source_app_id")
String sourceAppId;
@JsonField(name = "target")
MessageCreate.Target target;
@JsonField(name = "message_data")
MessageCreate.MessageData messageData;
public String getSenderId() {
return senderId;
}
public String getSourceAppId() {
return sourceAppId;
}
public MessageCreate.Target getTarget() {
return target;
}
public void setTarget(MessageCreate.Target target) {
this.target = target;
}
public MessageCreate.MessageData getMessageData() {
return messageData;
}
public void setMessageData(MessageCreate.MessageData messageData) {
this.messageData = messageData;
}
@JsonObject
public static class Target {
@JsonField(name = "recipient_id")
String recipientId;
public String getRecipientId() {
return recipientId;
}
public void setRecipientId(String recipientId) {
this.recipientId = recipientId;
}
}
@JsonObject
public static class MessageData {
@JsonField(name = "text")
String text;
@JsonField(name = "attachment")
Attachment attachment;
@JsonField(name = "attachment")
Entities entities;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Attachment getAttachment() {
return attachment;
}
public void setAttachment(Attachment attachment) {
this.attachment = attachment;
}
}
}
}

View File

@ -0,0 +1,43 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 org.mariotaku.microblog.library.model.twitter.dm;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.microblog.library.model.microblog.MicroBlogResponseObject;
import java.util.List;
import java.util.Map;
@JsonObject
public class DirectMessageEventList extends MicroBlogResponseObject {
@JsonField(name = "apps")
Map<String, App> apps;
@JsonField(name = "events")
List<DirectMessageEvent> events;
public Map<String, App> getApps() {
return apps;
}
public List<DirectMessageEvent> getEvents() {
return events;
}
}

View File

@ -0,0 +1,39 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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 org.mariotaku.microblog.library.model.twitter.dm;
import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.mariotaku.microblog.library.model.microblog.MicroBlogResponseObject;
@JsonObject
public class DirectMessageEventObject extends MicroBlogResponseObject {
@JsonField(name = "event")
DirectMessageEvent event;
public DirectMessageEvent getEvent() {
return event;
}
public void setEvent(DirectMessageEvent event) {
this.event = event;
}
}

View File

@ -1,7 +1,7 @@
/*
* Twidere - Twitter client for Android
*
* Copyright 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
* Copyright 2012-2018 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,14 +16,11 @@
* limitations under the License.
*/
package org.mariotaku.microblog.library.model.twitter;
package org.mariotaku.microblog.library.model.twitter.dm;
import org.mariotaku.microblog.library.util.InternalArrayUtil;
import org.mariotaku.restfu.http.SimpleValueMap;
/**
* Created by mariotaku on 16/3/1.
*/
public class NewDm extends SimpleValueMap {
public void setText(String text) {

View File

@ -365,6 +365,9 @@ public class ParcelableUser implements Parcelable, Comparable<ParcelableUser> {
@JsonField(name = "pinned_status_ids")
@ParcelableThisPlease
public String[] pinned_status_ids;
@JsonField(name = "url_display")
@ParcelableThisPlease
public String url_display;
@Override

View File

@ -106,7 +106,8 @@ inline val ParcelableUser.originalProfileImage: String?
?: Utils.getOriginalTwitterProfileImage(profile_image_url)
}
inline val ParcelableUser.urlPreferred: String? get() = url_expanded?.takeIf(String::isNotEmpty) ?: url
inline val ParcelableUser.urlFull: String? get() = url_expanded?.takeIf(String::isNotEmpty) ?: url
inline val ParcelableUser.urlDisplay: String? get() = extras?.url_display ?: urlFull
inline val ParcelableUser.acct: String
get() {

View File

@ -19,22 +19,20 @@
package org.mariotaku.twidere.extension.model.api
import org.mariotaku.microblog.library.model.microblog.DirectMessageEventObject
import org.mariotaku.microblog.library.model.microblog.DirectMessageEventObject.Event
import org.mariotaku.microblog.library.model.microblog.DirectMessageEventObject.Event.MessageCreate
import org.mariotaku.microblog.library.model.twitter.dm.DirectMessageEvent
import org.mariotaku.microblog.library.model.twitter.dm.DirectMessageEvent.MessageCreate
import org.mariotaku.microblog.library.model.twitter.dm.DirectMessageEventObject
import org.mariotaku.microblog.library.model.twitter.dm.Attachment
/**
* Created by mariotaku on 2017/5/11.
*/
fun DirectMessageEventObject(action: Event.() -> Unit): DirectMessageEventObject {
fun DirectMessageEventObject(action: DirectMessageEvent.() -> Unit): DirectMessageEventObject {
val obj = DirectMessageEventObject()
val event = Event()
val event = DirectMessageEvent()
action(event)
obj.event = event
return obj
}
fun Event.messageCreate(action: MessageCreate.() -> Unit) {
fun DirectMessageEvent.messageCreate(action: MessageCreate.() -> Unit) {
val messageCreate = MessageCreate()
action(messageCreate)
this.messageCreate = messageCreate
@ -52,14 +50,14 @@ fun MessageCreate.messageData(action: MessageCreate.MessageData.() -> Unit) {
this.messageData = messageData
}
fun MessageCreate.MessageData.attachment(action: MessageCreate.MessageData.Attachment.() -> Unit) {
val attachment = MessageCreate.MessageData.Attachment()
fun MessageCreate.MessageData.attachment(action: Attachment.() -> Unit) {
val attachment = Attachment()
action(attachment)
this.attachment = attachment
}
fun MessageCreate.MessageData.Attachment.media(action: MessageCreate.MessageData.Attachment.Media.() -> Unit) {
val media = MessageCreate.MessageData.Attachment.Media()
fun Attachment.media(action: Attachment.Media.() -> Unit) {
val media = Attachment.Media()
action(media)
this.media = media
}

View File

@ -20,7 +20,6 @@
package org.mariotaku.twidere.extension.model.api
import android.text.TextUtils
import org.mariotaku.ktextension.isNotNullOrEmpty
import org.mariotaku.microblog.library.model.microblog.User
import org.mariotaku.twidere.TwidereConstants.USER_TYPE_FANFOU_COM
import org.mariotaku.twidere.TwidereConstants.USER_TYPE_TWITTER_COM
@ -84,9 +83,8 @@ fun User.toParcelableInternal(accountKey: UserKey?, @AccountType accountType: St
obj.profile_background_url = profileBackgroundImageUrl
}
obj.url = url
if (obj.url != null && urlEntities.isNotNullOrEmpty()) {
obj.url_expanded = urlEntities[0].expandedUrl
}
val urlEntity = urlEntities?.find { it.url == url }
obj.url_expanded = urlEntity?.expandedUrl
obj.is_follow_request_sent = isFollowRequestSent == true
obj.followers_count = followersCount
obj.friends_count = friendsCount
@ -103,6 +101,7 @@ fun User.toParcelableInternal(accountKey: UserKey?, @AccountType accountType: St
obj.is_basic = false
val extras = ParcelableUser.Extras()
extras.url_display = urlEntity?.displayUrl
extras.ostatus_uri = ostatusUri
extras.blocking = isBlocking == true
extras.blocked_by = isBlockedBy == true

View File

@ -862,7 +862,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
IntentUtils.openProfileEditor(context, accountKey)
}
R.id.url -> {
val uri = user.urlPreferred?.let(Uri::parse) ?: return
val uri = user.urlFull?.let(Uri::parse) ?: return
OnLinkClickHandler.openLink(context, preferences, uri)
}
R.id.profileBirthdayBanner -> {
@ -1164,7 +1164,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
location.spannable = user.location
location.hideIfEmpty()
url.spannable = user.urlPreferred?.let {
url.spannable = user.urlDisplay?.let {
val ssb = SpannableStringBuilder(it)
ssb.setSpan(TwidereURLSpan(it, highlightStyle = linkHighlightOption), 0, ssb.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

View File

@ -44,7 +44,7 @@ import org.mariotaku.twidere.data.user.UserLiveData
import org.mariotaku.twidere.extension.*
import org.mariotaku.twidere.extension.data.observe
import org.mariotaku.twidere.extension.model.expandedDescription
import org.mariotaku.twidere.extension.model.urlPreferred
import org.mariotaku.twidere.extension.model.urlFull
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.UserKey
@ -103,7 +103,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
editName.setText(savedInstanceState.getString(EXTRA_NAME, savedUser.name))
editLocation.setText(savedInstanceState.getString(EXTRA_LOCATION, savedUser.location))
editDescription.setText(savedInstanceState.getString(EXTRA_DESCRIPTION, savedUser.expandedDescription))
editUrl.setText(savedInstanceState.getString(EXTRA_URL, savedUser.urlPreferred))
editUrl.setText(savedInstanceState.getString(EXTRA_URL, savedUser.urlFull))
} else {
getUserInfo(false)
}
@ -251,7 +251,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
editName.setText(user.name)
editDescription.setText(user.expandedDescription)
editLocation.setText(user.location)
editUrl.setText(user.urlPreferred)
editUrl.setText(user.urlFull)
requestManager.loadProfileImage(activity, user,
ImageShapeStyle.SHAPE_RECTANGLE).into(profileImage)
@ -303,7 +303,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener,
if (user.name != editName.string) return true
if (user.expandedDescription != editDescription.string) return true
if (user.location != editLocation.string) return true
if (user.urlPreferred != editUrl.string) return true
if (user.urlFull != editUrl.string) return true
return false
}

View File

@ -35,6 +35,7 @@ import org.mariotaku.microblog.library.model.Paging
import org.mariotaku.microblog.library.model.microblog.DMResponse
import org.mariotaku.microblog.library.model.microblog.DMResponse.Conversation
import org.mariotaku.microblog.library.model.microblog.DirectMessage
import org.mariotaku.microblog.library.model.twitter.dm.DirectMessageEvent
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_SHOW_NOTIFICATION
@ -105,6 +106,7 @@ class GetMessagesTask(
if (details.isOfficial(context)) {
return getTwitterOfficialMessages(twitter, details, param, index)
}
// getTwitterMessages(twitter, details, param, index)
}
}
// Use default method
@ -140,34 +142,19 @@ class GetMessagesTask(
val sincePagination = param.pagination?.get(accountsCount + index) as? SinceMaxPagination
val firstFetch by lazy {
val noConversationsBefore = context.contentResolver.queryCount(Conversations.CONTENT_URI,
return@lazy context.contentResolver.queryCount(Conversations.CONTENT_URI,
Expression.equalsArgs(Conversations.ACCOUNT_KEY).sql, arrayOf(accountKey.toString())) <= 0
return@lazy noConversationsBefore
}
val updateLastRead = param.hasMaxIds || firstFetch
val received = microBlog.getDirectMessages(Paging().apply {
count(100)
val maxId = receivedPagination?.maxId
val sinceId = receivedPagination?.sinceId
if (maxId != null) {
maxId(maxId)
}
if (sinceId != null) {
sinceId(sinceId)
}
receivedPagination?.applyTo(this)
})
val sent = microBlog.getSentDirectMessages(Paging().apply {
count(100)
val maxId = sincePagination?.maxId
val sinceId = sincePagination?.sinceId
if (maxId != null) {
maxId(maxId)
}
if (sinceId != null) {
sinceId(sinceId)
}
sincePagination?.applyTo(this)
})
@ -197,6 +184,50 @@ class GetMessagesTask(
}
private fun getTwitterMessages(twitter: Twitter, details: AccountDetails,
param: RefreshMessagesParam, index: Int): DatabaseUpdateData {
val accountKey = details.key
val receivedPagination = param.pagination?.get(index) as? CursorPagination
val firstFetch by lazy {
return@lazy context.contentResolver.queryCount(Conversations.CONTENT_URI,
Expression.equalsArgs(Conversations.ACCOUNT_KEY).sql, arrayOf(accountKey.toString())) <= 0
}
val updateLastRead = param.hasMaxIds || firstFetch
val events = twitter.getDirectMessageEvents(Paging().apply {
count(50)
receivedPagination?.applyTo(this)
}).events
val insertMessages = arrayListOf<ParcelableMessage>()
val conversations = hashMapOf<String, ParcelableMessageConversation>()
val conversationIds = hashSetOf<String>()
val users = twitter.lookupUsers(events.flatMap {
val mc = it.messageCreate ?: return@flatMap emptyList<String>()
return@flatMap listOf(mc.senderId, mc.target.recipientId)
}.distinct().toTypedArray())
events.forEach { event ->
val msg = event.messageCreate
conversationIds.add(ParcelableMessageUtils.incomingConversationId(msg.senderId, msg.target.recipientId))
}
conversations.addLocalConversations(context, accountKey, conversationIds)
events.forEachIndexed { i, dm ->
// addConversationMessage(insertMessages, conversations, details, dm, i, events.size,
// false, profileImageSize, updateLastRead)
}
return DatabaseUpdateData(conversations.values, insertMessages)
}
private fun getTwitterOfficialConversation(twitter: Twitter, details: AccountDetails,
conversationId: String, param: RefreshMessagesParam, index: Int): DatabaseUpdateData {
val maxId = (param.pagination?.get(index) as? SinceMaxPagination)?.maxId
@ -364,7 +395,6 @@ class GetMessagesTask(
}
companion object {
private const val KEY_FIRST_FETCH = "state_first_fetch_direct_messages"
private val getMessageTasks = mutableSetOf<Uri>()
@ -601,6 +631,25 @@ class GetMessagesTask(
conversation.conversation_extras = DefaultConversationExtras()
}
}
internal fun addConversationMessage(messages: MutableCollection<ParcelableMessage>,
conversations: MutableMap<String, ParcelableMessageConversation>,
details: AccountDetails, dm: DirectMessageEvent.MessageCreate, index: Int, size: Int,
outgoing: Boolean, profileImageSize: String = "normal", updateLastRead: Boolean) {
val accountKey = details.key
val accountType = details.type
// val message = ParcelableMessageUtils.fromMessage(accountKey, dm, outgoing,
// 1.0 - (index.toDouble() / size))
// messages.add(message)
// val sender = dm.sender.toParcelable(accountKey, accountType, profileImageSize = profileImageSize)
// val recipient = dm.recipient.toParcelable(accountKey, accountType, profileImageSize = profileImageSize)
// val conversation = conversations.addConversation(message.conversation_id, details,
// message, setOf(sender, recipient), updateLastRead = updateLastRead) ?: return
// conversation.conversation_extras_type = ParcelableMessageConversation.ExtrasType.DEFAULT
// if (conversation.conversation_extras == null) {
// conversation.conversation_extras = DefaultConversationExtras()
// }
}
}
}

View File

@ -24,7 +24,7 @@ import org.mariotaku.ktextension.isNotNullOrEmpty
import org.mariotaku.microblog.library.*
import org.mariotaku.microblog.library.annotation.twitter.MediaCategory
import org.mariotaku.microblog.library.model.microblog.DirectMessage
import org.mariotaku.microblog.library.model.twitter.NewDm
import org.mariotaku.microblog.library.model.twitter.dm.NewDm
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.R
import org.mariotaku.twidere.annotation.AccountType

View File

@ -36,6 +36,7 @@ import org.mariotaku.twidere.adapter.iface.IUsersAdapter
import org.mariotaku.twidere.adapter.iface.IUsersAdapter.*
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.hasSameHost
import org.mariotaku.twidere.extension.model.urlDisplay
import org.mariotaku.twidere.extension.setVisible
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.placeholder.PlaceholderObject
@ -169,7 +170,7 @@ class UserViewHolder(
descriptionView.hideIfEmpty()
locationView.spannable = user.location
locationView.hideIfEmpty()
urlView.spannable = user.url_expanded
urlView.spannable = user.urlDisplay
urlView.hideIfEmpty()
val locale = Locale.getDefault()
statusesCountView.text = user.statuses_count.toString(locale)