mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-19 03:29:58 +01:00
fixed conversation load
This commit is contained in:
parent
42db9325c8
commit
177b682d84
@ -174,6 +174,9 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
|
||||
@JsonField(name = "statusnet_conversation_id")
|
||||
String statusnetConversationId;
|
||||
|
||||
@JsonField(name = "conversation_id")
|
||||
String conversationId;
|
||||
|
||||
|
||||
/**
|
||||
* For GNU social
|
||||
@ -414,6 +417,10 @@ public class Status extends TwitterResponseObject implements Comparable<Status>,
|
||||
return attentions;
|
||||
}
|
||||
|
||||
public String getConversationId() {
|
||||
return conversationId;
|
||||
}
|
||||
|
||||
public String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
@ -520,6 +520,10 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
|
||||
@ParcelableThisPlease
|
||||
@Nullable
|
||||
public int[] quoted_display_text_range;
|
||||
@JsonField(name = "conversation_id")
|
||||
@ParcelableThisPlease
|
||||
@Nullable
|
||||
public String conversation_id;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
|
@ -157,9 +157,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||
val loader = ConversationLoader(activity, status, sinceId, maxId, sinceSortId, maxSortId,
|
||||
adapter.getData(), true, loadingMore)
|
||||
// Setting comparator to null lets statuses sort ascending
|
||||
loader.comparator = Comparator { l, r ->
|
||||
(r.sort_id - l.sort_id).toInt()
|
||||
}
|
||||
loader.comparator = null
|
||||
return loader
|
||||
}
|
||||
|
||||
@ -1557,13 +1555,12 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||
val itemType = getItemType(position)
|
||||
when (itemType) {
|
||||
ITEM_IDX_CONVERSATION -> {
|
||||
if (data == null) return null
|
||||
return data!![position - getIndexStart(ITEM_IDX_CONVERSATION)]
|
||||
return data?.get(position - getIndexStart(ITEM_IDX_CONVERSATION))
|
||||
}
|
||||
ITEM_IDX_REPLY -> {
|
||||
if (data == null || replyStart < 0) return null
|
||||
return data!![position - getIndexStart(ITEM_IDX_CONVERSATION)
|
||||
- getTypeCount(ITEM_IDX_CONVERSATION) - getTypeCount(ITEM_IDX_STATUS) + replyStart]
|
||||
if (replyStart < 0) return null
|
||||
return data?.get(position - getIndexStart(ITEM_IDX_CONVERSATION)
|
||||
- getTypeCount(ITEM_IDX_CONVERSATION) - getTypeCount(ITEM_IDX_STATUS) + replyStart)
|
||||
}
|
||||
ITEM_IDX_STATUS -> {
|
||||
return status
|
||||
@ -1651,7 +1648,9 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||
data.forEachIndexed { i, item ->
|
||||
if (item.sort_id < sortId) {
|
||||
conversationCount++
|
||||
} else if (item.sort_id > sortId && status.id != item.id) {
|
||||
} else if (status.id == item.id) {
|
||||
this.status = item
|
||||
} else if (item.sort_id > sortId) {
|
||||
if (replyStart < 0) {
|
||||
replyStart = i
|
||||
}
|
||||
|
@ -66,16 +66,14 @@ class ConversationLoader(
|
||||
canLoadAllReplies = isOfficial
|
||||
if (isOfficial) {
|
||||
return microBlog.showConversation(status.id, paging)
|
||||
} else {
|
||||
return showConversationCompat(microBlog, details, status, true)
|
||||
}
|
||||
return showConversationCompat(microBlog, details, status, true)
|
||||
}
|
||||
AccountType.STATUSNET -> {
|
||||
canLoadAllReplies = true
|
||||
if (status.extras != null && status.extras.statusnet_conversation_id != null) {
|
||||
return microBlog.getStatusNetConversation(status.extras.statusnet_conversation_id, paging)
|
||||
}
|
||||
return microBlog.showConversation(status.id, paging)
|
||||
}
|
||||
AccountType.FANFOU -> {
|
||||
canLoadAllReplies = true
|
||||
@ -88,10 +86,8 @@ class ConversationLoader(
|
||||
}
|
||||
|
||||
@Throws(MicroBlogException::class)
|
||||
private fun showConversationCompat(twitter: MicroBlog,
|
||||
details: AccountDetails,
|
||||
status: ParcelableStatus,
|
||||
loadReplies: Boolean): List<Status> {
|
||||
private fun showConversationCompat(twitter: MicroBlog, details: AccountDetails,
|
||||
status: ParcelableStatus, loadReplies: Boolean): List<Status> {
|
||||
val statuses = ArrayList<Status>()
|
||||
val noSinceMaxId = maxId == null && sinceId == null
|
||||
// Load conversations
|
||||
|
@ -1,10 +1,8 @@
|
||||
package org.mariotaku.twidere.model.util
|
||||
|
||||
import android.text.Spannable
|
||||
import android.text.Spanned
|
||||
import android.text.style.URLSpan
|
||||
import org.mariotaku.microblog.library.twitter.model.Status
|
||||
import org.mariotaku.twidere.extension.model.applyTo
|
||||
import org.mariotaku.twidere.model.*
|
||||
import org.mariotaku.twidere.model.ParcelableStatus.FilterFlags
|
||||
import org.mariotaku.twidere.util.HtmlSpanBuilder
|
||||
@ -28,8 +26,7 @@ object ParcelableStatusUtils {
|
||||
status.retweet_id = null
|
||||
}
|
||||
|
||||
fun fromStatus(orig: Status, accountKey: UserKey,
|
||||
isGap: Boolean): ParcelableStatus {
|
||||
fun fromStatus(orig: Status, accountKey: UserKey, isGap: Boolean): ParcelableStatus {
|
||||
val result = ParcelableStatus()
|
||||
result.is_gap = isGap
|
||||
result.account_key = accountKey
|
||||
@ -41,6 +38,7 @@ object ParcelableStatusUtils {
|
||||
result.extras.external_url = orig.inferExternalUrl()
|
||||
result.extras.support_entities = orig.entities != null
|
||||
result.extras.statusnet_conversation_id = orig.statusnetConversationId
|
||||
result.extras.conversation_id = orig.conversationId
|
||||
result.is_pinned_status = orig.user.pinnedTweetIds?.contains(orig.id) ?: false
|
||||
|
||||
val retweetedStatus = orig.retweetedStatus
|
||||
|
Loading…
Reference in New Issue
Block a user