fixed #777
added display name fallback
This commit is contained in:
Mariotaku Lee 2017-04-23 11:54:18 +08:00
parent 682ccf2b56
commit 0612336e62
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
6 changed files with 13 additions and 16 deletions

View File

@ -46,7 +46,7 @@ fun Account.toParcelable(accountKey: UserKey, position: Long = 0): ParcelableUse
obj.key = getKey(accountKey.host)
obj.created_at = createdAt?.time ?: -1
obj.is_protected = isLocked
obj.name = displayName?.takeIf(String::isNotEmpty) ?: username
obj.name = name
obj.screen_name = username
if (note?.isHtml ?: false) {
val descriptionHtml = HtmlSpanBuilder.fromHtml(note, note)
@ -70,6 +70,8 @@ fun Account.toParcelable(accountKey: UserKey, position: Long = 0): ParcelableUse
return obj
}
val Account.host: String? get() = acct?.let(UserKey::valueOf)?.host
inline val Account.host: String? get() = acct?.let(UserKey::valueOf)?.host
fun Account.getKey(host: String?) = UserKey(id, acct?.let(UserKey::valueOf)?.host ?: host)
inline val Account.name: String? get() = displayName?.takeIf(String::isNotEmpty) ?: username
fun Account.getKey(host: String?) = UserKey(id, acct?.let(UserKey::valueOf)?.host ?: host)

View File

@ -54,7 +54,7 @@ fun Status.toParcelable(accountKey: UserKey): ParcelableStatus {
result.retweet_id = retweetedStatus.id
result.retweet_timestamp = retweetedStatus.createdAt?.time ?: 0
result.retweeted_by_user_key = retweetAccount.getKey(accountKey.host)
result.retweeted_by_user_name = retweetAccount.displayName
result.retweeted_by_user_name = retweetAccount.name
result.retweeted_by_user_screen_name = retweetAccount.username
result.retweeted_by_user_profile_image = retweetAccount.avatar
@ -79,7 +79,7 @@ fun Status.toParcelable(accountKey: UserKey): ParcelableStatus {
val account = status.account
result.user_key = account.getKey(accountKey.host)
result.user_name = account.displayName
result.user_name = account.name
result.user_screen_name = account.username
result.user_profile_image_url = account.avatar
result.user_is_protected = account.isLocked

View File

@ -20,7 +20,6 @@
package org.mariotaku.twidere.fragment.statuses
import android.content.Context
import android.graphics.Rect
import android.os.Bundle
import android.support.v4.content.Loader
import org.mariotaku.twidere.TwidereConstants.*
@ -73,12 +72,8 @@ open class StatusesSearchFragment : ParcelableStatusesFragment() {
val tabPosition = args.getInt(EXTRA_TAB_POSITION, -1)
val makeGap = args.getBoolean(EXTRA_MAKE_GAP, true)
val loadingMore = args.getBoolean(EXTRA_LOADING_MORE, false)
return TweetSearchLoader(activity, accountKey, query, adapterData, savedStatusesFileArgs, tabPosition, fromUser,
makeGap, loadingMore)
}
override fun fitSystemWindows(insets: Rect) {
super.fitSystemWindows(insets)
return TweetSearchLoader(activity, accountKey, query, adapterData, savedStatusesFileArgs,
tabPosition, fromUser, makeGap, loadingMore)
}
}

View File

@ -76,9 +76,9 @@ open class MediaStatusesSearchLoader(
protected open fun processQuery(details: AccountDetails, query: String): String {
if (details.type == AccountType.TWITTER) {
if (details.extras?.official ?: false) {
return TweetSearchLoader.smQuery(query, pagination)
return TweetSearchLoader.smQuery("$query filter:media", pagination)
}
return "$query exclude:retweets filter:media"
return "$query filter:media exclude:retweets"
}
return query
}

View File

@ -53,7 +53,7 @@ class NetworkPublicTimelineLoader(
when (account.type) {
AccountType.MASTODON -> {
val mastodon = account.newMicroBlogInstance(context, Mastodon::class.java)
return mastodon.getPublicTimeline(paging, true).mapToPaginated {
return mastodon.getPublicTimeline(paging, false).mapToPaginated {
it.toParcelable(account)
}
}

View File

@ -130,7 +130,7 @@ open class TweetSearchLoader(
companion object {
fun smQuery(query: String, pagination: Pagination?): String {
var universalQueryText = "$query filter:media"
var universalQueryText = query
if (pagination !is SinceMaxPagination) return universalQueryText
pagination.maxId?.let { maxId ->