fixed conversation order bug
This commit is contained in:
parent
9bcabb1eb6
commit
a9b83d8977
|
@ -42,12 +42,12 @@ subprojects {
|
||||||
]
|
]
|
||||||
libVersions = [
|
libVersions = [
|
||||||
Kotlin : "${kotlinVersion}",
|
Kotlin : "${kotlinVersion}",
|
||||||
SupportLib : '26.0.2',
|
SupportLib : '26.1.0',
|
||||||
SupportTest : '1.0.0',
|
SupportTest : '1.0.0',
|
||||||
MariotakuCommons : '0.9.19',
|
MariotakuCommons : '0.9.19',
|
||||||
RestFu : '0.9.60',
|
RestFu : '0.9.60',
|
||||||
ObjectCursor : '0.9.20',
|
ObjectCursor : '0.9.20',
|
||||||
PlayServices : '11.2.0',
|
PlayServices : '11.2.2',
|
||||||
MapsUtils : '0.5',
|
MapsUtils : '0.5',
|
||||||
DropboxCoreSdk : '3.0.3',
|
DropboxCoreSdk : '3.0.3',
|
||||||
GoogleDriveApi : 'v3-rev61-1.22.0',
|
GoogleDriveApi : 'v3-rev61-1.22.0',
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
|
||||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
|
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
|
||||||
import org.mariotaku.twidere.constant.*
|
import org.mariotaku.twidere.constant.*
|
||||||
import org.mariotaku.twidere.extension.model.originalId
|
import org.mariotaku.twidere.extension.model.originalId
|
||||||
|
import org.mariotaku.twidere.extension.model.retweet_sort_id
|
||||||
import org.mariotaku.twidere.fragment.status.StatusFragment
|
import org.mariotaku.twidere.fragment.status.StatusFragment
|
||||||
import org.mariotaku.twidere.model.*
|
import org.mariotaku.twidere.model.*
|
||||||
import org.mariotaku.twidere.util.StatusAdapterLinkClickHandler
|
import org.mariotaku.twidere.util.StatusAdapterLinkClickHandler
|
||||||
|
@ -207,13 +208,12 @@ class StatusDetailsAdapter(
|
||||||
setTypeCount(ITEM_IDX_REPLY, 0)
|
setTypeCount(ITEM_IDX_REPLY, 0)
|
||||||
replyStart = -1
|
replyStart = -1
|
||||||
} else {
|
} else {
|
||||||
var sortId = status.sort_id
|
val sortId = if (status.is_retweet) {
|
||||||
|
status.retweet_sort_id
|
||||||
if (status.is_retweet) {
|
} else {
|
||||||
sortId = data.find {
|
status.sort_id
|
||||||
it.id == status.retweet_id
|
|
||||||
}?.sort_id ?: status.retweet_timestamp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var conversationCount = 0
|
var conversationCount = 0
|
||||||
var replyCount = 0
|
var replyCount = 0
|
||||||
var replyStart = -1
|
var replyStart = -1
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.mariotaku.twidere.extension.model
|
package org.mariotaku.twidere.extension.model
|
||||||
|
|
||||||
import org.mariotaku.ktextension.addAllTo
|
import org.mariotaku.ktextension.addAllTo
|
||||||
|
import org.mariotaku.ktextension.toLongOr
|
||||||
import org.mariotaku.microblog.library.mastodon.annotation.StatusVisibility
|
import org.mariotaku.microblog.library.mastodon.annotation.StatusVisibility
|
||||||
import org.mariotaku.twidere.TwidereConstants.USER_TYPE_FANFOU_COM
|
import org.mariotaku.twidere.TwidereConstants.USER_TYPE_FANFOU_COM
|
||||||
import org.mariotaku.twidere.model.*
|
import org.mariotaku.twidere.model.*
|
||||||
|
@ -103,6 +104,12 @@ val ParcelableStatus.quoted: ParcelableStatus?
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val ParcelableStatus.retweet_sort_id: Long
|
||||||
|
get() {
|
||||||
|
if (!is_retweet) return -1
|
||||||
|
return retweet_id.toLongOr(timestamp)
|
||||||
|
}
|
||||||
|
|
||||||
fun ParcelableStatus.toSummaryLine(): ParcelableActivity.SummaryLine {
|
fun ParcelableStatus.toSummaryLine(): ParcelableActivity.SummaryLine {
|
||||||
val result = ParcelableActivity.SummaryLine()
|
val result = ParcelableActivity.SummaryLine()
|
||||||
result.key = user_key
|
result.key = user_key
|
||||||
|
@ -133,13 +140,14 @@ fun ParcelableStatus.extractFanfouHashtags(): List<String> {
|
||||||
fun ParcelableStatus.makeOriginal() {
|
fun ParcelableStatus.makeOriginal() {
|
||||||
if (!is_retweet) return
|
if (!is_retweet) return
|
||||||
id = retweet_id
|
id = retweet_id
|
||||||
is_retweet = false
|
|
||||||
retweeted_by_user_key = null
|
retweeted_by_user_key = null
|
||||||
retweeted_by_user_name = null
|
retweeted_by_user_name = null
|
||||||
retweeted_by_user_screen_name = null
|
retweeted_by_user_screen_name = null
|
||||||
retweeted_by_user_profile_image = null
|
retweeted_by_user_profile_image = null
|
||||||
retweet_timestamp = -1
|
retweet_timestamp = -1
|
||||||
retweet_id = null
|
retweet_id = null
|
||||||
|
is_retweet = false
|
||||||
|
sort_id = id.toLongOr(timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ParcelableStatus.addFilterFlag(@ParcelableStatus.FilterFlags flags: Long) {
|
fun ParcelableStatus.addFilterFlag(@ParcelableStatus.FilterFlags flags: Long) {
|
||||||
|
|
|
@ -142,8 +142,6 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
|
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
|
||||||
return ConversationLoader(activity, status, adapter.getData(), true, loadingMore).apply {
|
return ConversationLoader(activity, status, adapter.getData(), true, loadingMore).apply {
|
||||||
pagination = args.toPagination()
|
pagination = args.toPagination()
|
||||||
// Setting comparator to null lets statuses sort ascending
|
|
||||||
comparator = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ import org.mariotaku.twidere.util.cache.JsonCache
|
||||||
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -62,7 +61,7 @@ abstract class AbsRequestStatusesLoader(
|
||||||
protected val loadingMore: Boolean
|
protected val loadingMore: Boolean
|
||||||
) : ParcelableStatusesLoader(context, adapterData, tabPosition, fromUser), IPaginationLoader {
|
) : ParcelableStatusesLoader(context, adapterData, tabPosition, fromUser), IPaginationLoader {
|
||||||
// Statuses sorted descending by default
|
// Statuses sorted descending by default
|
||||||
var comparator: Comparator<ParcelableStatus>? = ParcelableStatus.REVERSE_COMPARATOR
|
open val comparator: Comparator<ParcelableStatus>? = ParcelableStatus.REVERSE_COMPARATOR
|
||||||
|
|
||||||
var exception: MicroBlogException?
|
var exception: MicroBlogException?
|
||||||
get() = exceptionRef.get()
|
get() = exceptionRef.get()
|
||||||
|
@ -105,6 +104,7 @@ abstract class AbsRequestStatusesLoader(
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
override final fun loadInBackground(): ListResponse<ParcelableStatus> {
|
override final fun loadInBackground(): ListResponse<ParcelableStatus> {
|
||||||
val context = context
|
val context = context
|
||||||
|
val comparator = this.comparator
|
||||||
val accountKey = accountKey ?: return ListResponse.getListInstance<ParcelableStatus>(MicroBlogException("No Account"))
|
val accountKey = accountKey ?: return ListResponse.getListInstance<ParcelableStatus>(MicroBlogException("No Account"))
|
||||||
val details = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?:
|
val details = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?:
|
||||||
return ListResponse.getListInstance<ParcelableStatus>(MicroBlogException("No Account"))
|
return ListResponse.getListInstance<ParcelableStatus>(MicroBlogException("No Account"))
|
||||||
|
@ -114,11 +114,11 @@ abstract class AbsRequestStatusesLoader(
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
data.addAll(cached)
|
data.addAll(cached)
|
||||||
if (comparator != null) {
|
if (comparator != null) {
|
||||||
Collections.sort(data, comparator)
|
data.sortWith(comparator)
|
||||||
} else {
|
} else {
|
||||||
Collections.sort(data)
|
data.sort()
|
||||||
}
|
}
|
||||||
return ListResponse.getListInstance(CopyOnWriteArrayList(data))
|
return ListResponse.getListInstance(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fromUser) return ListResponse.getListInstance(data)
|
if (!fromUser) return ListResponse.getListInstance(data)
|
||||||
|
@ -171,12 +171,12 @@ abstract class AbsRequestStatusesLoader(
|
||||||
data.forEach { it.is_filtered = shouldFilterStatus(it) }
|
data.forEach { it.is_filtered = shouldFilterStatus(it) }
|
||||||
|
|
||||||
if (comparator != null) {
|
if (comparator != null) {
|
||||||
data.sortWith(comparator!!)
|
data.sortWith(comparator)
|
||||||
} else {
|
} else {
|
||||||
data.sort()
|
data.sort()
|
||||||
}
|
}
|
||||||
saveCachedData(data)
|
saveCachedData(data)
|
||||||
return ListResponse.getListInstance(CopyOnWriteArrayList(data))
|
return ListResponse.getListInstance(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override final fun onStartLoading() {
|
override final fun onStartLoading() {
|
||||||
|
|
|
@ -59,11 +59,13 @@ class ConversationLoader(
|
||||||
loadingMore: Boolean
|
loadingMore: Boolean
|
||||||
) : AbsRequestStatusesLoader(context, status.account_key, adapterData, null, -1, fromUser, loadingMore) {
|
) : AbsRequestStatusesLoader(context, status.account_key, adapterData, null, -1, fromUser, loadingMore) {
|
||||||
|
|
||||||
private val status = ParcelUtils.clone(status).apply { makeOriginal() }
|
override val comparator: Comparator<ParcelableStatus>? = null
|
||||||
|
|
||||||
var canLoadAllReplies: Boolean = false
|
var canLoadAllReplies: Boolean = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
private val status = ParcelUtils.clone(status).apply { makeOriginal() }
|
||||||
|
|
||||||
@Throws(MicroBlogException::class)
|
@Throws(MicroBlogException::class)
|
||||||
override fun getStatuses(account: AccountDetails, paging: Paging): PaginatedList<ParcelableStatus> {
|
override fun getStatuses(account: AccountDetails, paging: Paging): PaginatedList<ParcelableStatus> {
|
||||||
when (account.type) {
|
when (account.type) {
|
||||||
|
@ -89,11 +91,11 @@ class ConversationLoader(
|
||||||
AccountType.TWITTER -> {
|
AccountType.TWITTER -> {
|
||||||
val isOfficial = account.isOfficial(context)
|
val isOfficial = account.isOfficial(context)
|
||||||
canLoadAllReplies = isOfficial
|
canLoadAllReplies = isOfficial
|
||||||
if (isOfficial) {
|
// if (isOfficial) {
|
||||||
return microBlog.showConversation(status.id, paging).mapMicroBlogToPaginated {
|
// return microBlog.showConversation(status.id, paging).mapMicroBlogToPaginated {
|
||||||
it.toParcelable(account, profileImageSize)
|
// it.toParcelable(account, profileImageSize)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return showConversationCompat(microBlog, account, status, true)
|
return showConversationCompat(microBlog, account, status, true)
|
||||||
}
|
}
|
||||||
AccountType.STATUSNET -> {
|
AccountType.STATUSNET -> {
|
||||||
|
|
Loading…
Reference in New Issue