improved status activity summary

This commit is contained in:
Mariotaku Lee 2017-12-31 05:10:40 +08:00
parent bdd8a9bab6
commit 927e21891c
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
4 changed files with 10 additions and 23 deletions

View File

@ -46,8 +46,6 @@ public class StatusActivitySummary extends MicroBlogResponseObject implements Mi
long repliersCount;
@JsonField(name = "retweeters_count")
long retweetersCount;
@JsonField(name = "descendent_reply_count")
long descendentReplyCount;
public IDs getFavoriters() {
return favoriters;
@ -73,10 +71,6 @@ public class StatusActivitySummary extends MicroBlogResponseObject implements Mi
return retweetersCount;
}
public long getDescendentReplyCount() {
return descendentReplyCount;
}
@Override
public int describeContents() {
return 0;

View File

@ -22,7 +22,6 @@ package org.mariotaku.twidere.data.status
import android.accounts.AccountManager
import android.content.ContentValues
import android.content.Context
import org.mariotaku.ktextension.addAllTo
import org.mariotaku.microblog.library.Twitter
import org.mariotaku.microblog.library.model.Paging
import org.mariotaku.sqliteqb.library.Expression
@ -96,28 +95,22 @@ class StatusActivitySummaryLiveData(val context: Context) : ComputableExceptionL
val status = showStatus(statusId)
result.favoriteCount = status.favoriteCount
result.retweetCount = status.retweetCount
result.replyCount = status.descendentReplyCount
result.replyCount = status.replyCount
return result
}
private fun Twitter.getActivitySummaryOfficial(statusId: String, account: AccountDetails): StatusActivity {
val summary = getStatusActivitySummary(statusId)
val relatedIds = mutableSetOf<String>()
summary.favoriters?.iDs?.let {
it.slice(0 until (10.coerceAtMost(it.size)))
}?.addAllTo(relatedIds)
summary.retweeters?.iDs?.let {
it.slice(0 until (10.coerceAtMost(it.size)))
}?.addAllTo(relatedIds)
val relatedUsers = lookupUsers(relatedIds.toTypedArray())
val paging = Paging().count(5)
val relatedUsers = (getRetweetedBy(statusId, paging) + getFavoritedBy(statusId, paging))
.filterNot { DataStoreUtils.isFilteringUser(context, it.key) }
.map { it.toParcelable(account) }
val result = StatusActivity(statusId, relatedUsers)
result.favoriteCount = summary.favoritersCount
result.retweetCount = summary.retweetersCount
result.replyCount = summary.descendentReplyCount
val status = showStatus(statusId)
result.favoriteCount = status.favoriteCount
result.retweetCount = status.retweetCount
result.replyCount = status.replyCount
return result
}

View File

@ -143,7 +143,7 @@ fun Status.applyTo(accountKey: UserKey, accountType: String, profileImageSize: S
result.addFilterFlag(ParcelableStatus.FilterFlags.QUOTE_NOT_AVAILABLE)
}
result.reply_count = status.descendentReplyCount
result.reply_count = status.replyCount
result.retweet_count = status.retweetCount
result.favorite_count = status.favoriteCount

View File

@ -443,7 +443,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
private fun loadActivity(status: ParcelableStatus?) {
if (status == null || host == null || isDetached) return
statusActivitySummaryLiveData.accountKey = status.account_key
statusActivitySummaryLiveData.statusId = status.id
statusActivitySummaryLiveData.statusId = status.originalId
statusActivitySummaryLiveData.load()
}