migrating to Glide

This commit is contained in:
Mariotaku Lee 2017-03-02 10:42:40 +08:00
parent d78f3dca96
commit 4e84016d0d
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
35 changed files with 202 additions and 122 deletions

View File

@ -32,7 +32,7 @@ allprojects {
subprojects {
buildscript {
ext {
kotlin_version = '1.0.6'
kotlin_version = '1.1.0'
android_support_lib_version = '25.2.0'
mariotaku_commons_library_version = '0.9.11'
mariotaku_restfu_version = '0.9.35'

View File

@ -509,6 +509,10 @@ public class ParcelableStatus implements Parcelable, Comparable<ParcelableStatus
@JsonField(name = "user_profile_image_url_profile_size")
@ParcelableThisPlease
public String user_profile_image_url_profile_size;
@JsonField(name = "user_profile_image_url_fallback")
@ParcelableThisPlease
@Nullable
public String user_profile_image_url_fallback;
@JsonField(name = "user_statusnet_profile_url")
@ParcelableThisPlease
public String user_statusnet_profile_url;

View File

@ -75,7 +75,6 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_SCREEN_NAME
import org.mariotaku.twidere.extension.applyTheme
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getAccountUser
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.extension.model.textLimit
import org.mariotaku.twidere.extension.model.unique_id_non_null
import org.mariotaku.twidere.fragment.BaseDialogFragment
@ -1426,7 +1425,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
if (account != iconView.tag || iconView.drawable == null) {
iconView.tag = account
val context = adapter.context
adapter.getRequestManager().loadProfileImage(context, account.user.getBestProfileImage(context)).into(iconView)
adapter.getRequestManager().loadProfileImage(context, account).into(iconView)
}
iconView.setBorderColor(account.color)
nameView.text = if (adapter.isNameFirst) account.user.name else "@" + account.user.screen_name

View File

@ -527,11 +527,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi
internal abstract class AbstractSignInTask(activity: SignInActivity) : AsyncTask<Any, Runnable, SingleResponse<SignInResponse>>() {
protected val activityRef: WeakReference<SignInActivity>
init {
this.activityRef = WeakReference(activity)
}
protected val activityRef = WeakReference(activity)
protected val profileImageSize = activity.getString(R.string.profile_image_size)
override final fun doInBackground(vararg args: Any?): SingleResponse<SignInResponse> {
try {
@ -615,7 +612,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi
val accountType = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
val userId = apiUser.id!!
val accountKey = UserKey(userId, UserKeyUtils.getUserHost(apiUser))
val user = ParcelableUserUtils.fromUser(apiUser, accountKey)
val user = ParcelableUserUtils.fromUser(apiUser, accountKey,
profileImageSize = profileImageSize)
val am = AccountManager.get(context)
val account = AccountUtils.findByAccountKey(am, accountKey)
if (account != null) {
@ -903,7 +901,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi
var color = analyseUserProfileColor(apiUser)
val accountType = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
val accountKey = UserKey(userId, UserKeyUtils.getUserHost(apiUser))
val user = ParcelableUserUtils.fromUser(apiUser, accountKey)
val user = ParcelableUserUtils.fromUser(apiUser, accountKey,
profileImageSize = profileImageSize)
val am = AccountManager.get(activity)
val account = AccountUtils.findByAccountKey(am, accountKey)
if (account != null) {
@ -933,7 +932,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi
var color = analyseUserProfileColor(apiUser)
val accountType = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
val accountKey = UserKey(userId, UserKeyUtils.getUserHost(apiUser))
val user = ParcelableUserUtils.fromUser(apiUser, accountKey)
val user = ParcelableUserUtils.fromUser(apiUser, accountKey,
profileImageSize = profileImageSize)
val am = AccountManager.get(activity)
val account = AccountUtils.findByAccountKey(am, accountKey)
if (account != null) {
@ -961,7 +961,8 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, APIEditorDi
var color = analyseUserProfileColor(apiUser)
val accountType = SignInActivity.detectAccountType(twitter, apiUser, apiConfig.type)
val accountKey = UserKey(userId, UserKeyUtils.getUserHost(apiUser))
val user = ParcelableUserUtils.fromUser(apiUser, accountKey)
val user = ParcelableUserUtils.fromUser(apiUser, accountKey,
profileImageSize = profileImageSize)
val am = AccountManager.get(activity)
val account = AccountUtils.findByAccountKey(am, accountKey)
if (account != null) {

View File

@ -26,7 +26,6 @@ import android.widget.CompoundButton
import com.bumptech.glide.RequestManager
import org.mariotaku.twidere.R
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.model.util.AccountUtils
@ -63,7 +62,7 @@ class AccountDetailsAdapter(
holder.screenName.text = String.format("@%s", details.user.screen_name)
holder.setAccountColor(details.color)
if (profileImageEnabled) {
getRequestManager().loadProfileImage(context, details.user.getBestProfileImage(context)).into(holder.profileImage)
getRequestManager().loadProfileImage(context, details).into(holder.profileImage)
} else {
// TODO: display stub image?
}

View File

@ -27,7 +27,6 @@ import com.bumptech.glide.RequestManager
import kotlinx.android.synthetic.main.list_item_simple_user.view.*
import org.mariotaku.twidere.R
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.UserKey
@ -70,7 +69,7 @@ class AccountsSpinnerAdapter(
if (profileImageEnabled) {
icon.visibility = View.VISIBLE
icon.style = profileImageStyle
getRequestManager().loadProfileImage(context, item.user.getBestProfileImage(context)).into(icon)
getRequestManager().loadProfileImage(context, item.user).into(icon)
} else {
icon.visibility = View.GONE
}

View File

@ -30,7 +30,6 @@ import com.commonsware.cwac.layouts.AspectLockedFrameLayout
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable
import org.mariotaku.twidere.model.ParcelableMedia
import org.mariotaku.twidere.model.ParcelableStatus
@ -94,7 +93,7 @@ class StaggeredGridParcelableStatusesAdapter(
mediaImageView.setHasPlayIcon(ParcelableMediaUtils.hasPlayIcon(firstMedia.type))
val context = itemView.context
adapter.getRequestManager().loadProfileImage(context, status.getBestProfileImage(context)).into(profileImageView)
adapter.getRequestManager().loadProfileImage(context, status).into(profileImageView)
// TODO image loaded event and credentials
adapter.getRequestManager().load(firstMedia.preview_url).into(mediaImageView)
}

View File

@ -24,10 +24,15 @@ import android.text.TextUtils
import com.bumptech.glide.DrawableRequestBuilder
import com.bumptech.glide.RequestManager
import jp.wasabeef.glide.transformations.CropCircleTransformation
import org.mariotaku.twidere.R
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.ParcelableStatus
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.util.Utils
fun RequestManager.loadProfileImage(context: Context, url: String?): DrawableRequestBuilder<String?> {
return load(url).bitmapTransform(CropCircleTransformation(context))
val size = context.getString(R.string.profile_image_size)
return load(Utils.getTwitterProfileImageOfSize(url, size)).bitmapTransform(CropCircleTransformation(context))
}
fun RequestManager.loadProfileImage(context: Context, resourceId: Int): DrawableRequestBuilder<Int> {
@ -35,9 +40,22 @@ fun RequestManager.loadProfileImage(context: Context, resourceId: Int): Drawable
}
fun RequestManager.loadProfileImage(context: Context, account: AccountDetails): DrawableRequestBuilder<String?> {
if (account.user.extras != null && !TextUtils.isEmpty(account.user.extras.profile_image_url_profile_size)) {
return load(account.user.extras.profile_image_url_profile_size)
return loadProfileImage(context, account.user)
}
fun RequestManager.loadProfileImage(context: Context, user: ParcelableUser): DrawableRequestBuilder<String?> {
if (user.extras != null && !TextUtils.isEmpty(user.extras.profile_image_url_profile_size)) {
return load(user.extras.profile_image_url_profile_size)
} else {
return load(account.user.profile_image_url)
return load(user.profile_image_url)
}
}
}
fun RequestManager.loadProfileImage(context: Context, status: ParcelableStatus): DrawableRequestBuilder<String?> {
if (status.extras != null && status.extras.user_profile_image_url_fallback == null) {
// No fallback image, use compatible logic
return loadProfileImage(context, status.user_profile_image_url)
}
return load(status.user_profile_image_url).bitmapTransform(CropCircleTransformation(context))
}

View File

@ -118,7 +118,7 @@ fun ParcelableMessageConversation.displayAvatarTo(getRequestManager: () -> Reque
if (conversation_type == ConversationType.ONE_TO_ONE) {
val user = this.user
if (user != null) {
getRequestManager().loadProfileImage(context, user.getBestProfileImage(context)).into(view)
getRequestManager().loadProfileImage(context, user).into(view)
} else {
// TODO: show default conversation icon
getRequestManager().loadProfileImage(context, R.drawable.ic_profile_image_default_group).into(view)

View File

@ -1,6 +1,5 @@
package org.mariotaku.twidere.extension.model
import android.content.Context
import org.mariotaku.twidere.model.ParcelableStatus
import org.mariotaku.twidere.model.ParcelableUser
@ -30,7 +29,3 @@ val ParcelableStatus.referenced_users: Array<ParcelableUser>
}
return resultList.toTypedArray()
}
fun ParcelableStatus.getBestProfileImage(context: Context): String? {
return user_profile_image_url
}

View File

@ -19,15 +19,9 @@
package org.mariotaku.twidere.extension.model
import android.content.Context
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.util.InternalTwitterContentUtils
fun ParcelableUser.getBestProfileImage(context: Context): String? {
return profile_image_url
}
fun ParcelableUser.getBestProfileBanner(width: Int): String? {
return InternalTwitterContentUtils.getBestBannerUrl(profile_banner_url, width)
}

View File

@ -0,0 +1,28 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.extension.model.api
import org.mariotaku.microblog.library.twitter.model.User
import org.mariotaku.twidere.util.Utils
fun User.getProfileImageOfSize(size: String): String {
val profileImage = profileImageUrlHttps ?: profileImageUrl
return Utils.getTwitterProfileImageOfSize(profileImage, size) ?: profileImage
}

View File

@ -94,7 +94,6 @@ import org.mariotaku.twidere.extension.applyTheme
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.applyTo
import org.mariotaku.twidere.extension.model.getAccountType
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.extension.model.media_type
import org.mariotaku.twidere.extension.view.calculateSpaceItemHeight
import org.mariotaku.twidere.fragment.AbsStatusesFragment.Companion.handleActionClick
@ -928,7 +927,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
itemView.name.screenName = String.format("@%s", status.user_screen_name)
itemView.name.updateText(formatter)
adapter.getRequestManager().loadProfileImage(context, status.getBestProfileImage(context)).into(itemView.profileImage)
adapter.getRequestManager().loadProfileImage(context, status).into(itemView.profileImage)
val typeIconRes = Utils.getUserTypeIconRes(status.user_is_verified, status.user_is_protected)
val typeDescriptionRes = Utils.getUserTypeDescriptionRes(status.user_is_verified, status.user_is_protected)
@ -1375,7 +1374,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
fun displayUser(item: ParcelableUser) {
val context = adapter.context
adapter.getRequestManager().loadProfileImage(context, item.getBestProfileImage(context)).into(profileImageView)
adapter.getRequestManager().loadProfileImage(context, item).into(profileImageView)
}
override fun onClick(v: View) {

View File

@ -50,8 +50,8 @@ import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.activity.ColorPickerDialogActivity
import org.mariotaku.twidere.activity.ThemedMediaPickerActivity
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileBanner
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
import org.mariotaku.twidere.loader.ParcelableUserLoader
import org.mariotaku.twidere.model.AccountDetails
@ -139,7 +139,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, TextWat
}
override fun onLoadFinished(loader: Loader<SingleResponse<ParcelableUser>>,
data: SingleResponse<ParcelableUser>) {
data: SingleResponse<ParcelableUser>) {
if (data.data != null && data.data.key != null) {
displayUser(data.data)
} else if (user == null) {
@ -289,7 +289,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, TextWat
editLocation.setText(user.location)
editUrl.setText(if (isEmpty(user.url_expanded)) user.url else user.url_expanded)
Glide.with(this).load(user.getBestProfileImage(context)).into(profileImage)
Glide.with(this).loadProfileImage(context, user).into(profileImage)
Glide.with(this).load(user.getBestProfileBanner(resources.displayMetrics.widthPixels)).into(profileBanner)
Glide.with(this).load(user.profile_background_url).into(profileBackground)
@ -360,6 +360,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, TextWat
private val backgroundColor: Int
) : AbstractTask<Context, SingleResponse<ParcelableUser>, UserProfileEditorFragment>() {
override fun doLongOperation(context: Context): SingleResponse<ParcelableUser> {
val details = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?: return SingleResponse.getInstance()
val microBlog = details.newMicroBlogInstance(context = context, cls = MicroBlog::class.java)
@ -379,8 +380,9 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, TextWat
// User profile unchanged
return SingleResponse.Companion.getInstance<ParcelableUser>()
}
val response = SingleResponse.Companion.getInstance(
ParcelableUserUtils.fromUser(user, accountKey))
val profileImageSize = context.getString(R.string.profile_image_size)
val response = SingleResponse(ParcelableUserUtils.fromUser(user, accountKey,
profileImageSize = profileImageSize))
response.extras.putParcelable(EXTRA_ACCOUNT, details)
return response
} catch (e: MicroBlogException) {
@ -467,7 +469,7 @@ class UserProfileEditorFragment : BaseFragment(), OnSizeChangedListener, TextWat
}
private inner class UpdateProfileBannerImageTaskInternal(context: Context, accountKey: UserKey,
imageUri: Uri, deleteImage: Boolean) : UpdateProfileBannerImageTask<UserProfileEditorFragment>(context, accountKey, imageUri, deleteImage) {
imageUri: Uri, deleteImage: Boolean) : UpdateProfileBannerImageTask<UserProfileEditorFragment>(context, accountKey, imageUri, deleteImage) {
override fun afterExecute(handler: UserProfileEditorFragment?, result: SingleResponse<ParcelableUser>?) {
super.afterExecute(handler, result)

View File

@ -30,6 +30,7 @@ import org.mariotaku.microblog.library.MicroBlogException
import org.mariotaku.microblog.library.twitter.model.Paging
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.BuildConfig
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.app.TwidereApplication
import org.mariotaku.twidere.constant.loadItemLimitKey
@ -69,6 +70,7 @@ abstract class MicroBlogAPIStatusesLoader(
// Statuses sorted descending by default
var comparator: Comparator<ParcelableStatus>? = ParcelableStatus.REVERSE_COMPARATOR
private val exceptionRef = AtomicReference<MicroBlogException?>()
private val profileImageSize = context.getString(R.string.profile_image_size)
var exception: MicroBlogException?
get() = exceptionRef.get()
@ -154,7 +156,8 @@ abstract class MicroBlogAPIStatusesLoader(
val sortDiff = firstSortId - lastSortId
for (i in 0 until statuses.size) {
val status = statuses[i]
val item = ParcelableStatusUtils.fromStatus(status, accountKey, insertGap && isGapEnabled && minIdx == i)
val isGap = insertGap && isGapEnabled && minIdx == i
val item = ParcelableStatusUtils.fromStatus(status, accountKey, isGap, profileImageSize)
item.position_key = GetStatusesTask.getPositionKey(item.timestamp, item.sort_id, lastSortId,
sortDiff, i, statuses.size)
ParcelableStatusUtils.updateExtraInformation(item, details)

View File

@ -32,6 +32,7 @@ import org.mariotaku.microblog.library.twitter.model.User
import org.mariotaku.sqliteqb.library.Columns
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.Constants
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.annotation.AccountType
import org.mariotaku.twidere.annotation.Referral
@ -58,6 +59,8 @@ class ParcelableUserLoader(
private val loadFromCache: Boolean
) : FixedAsyncTaskLoader<SingleResponse<ParcelableUser>>(context), Constants {
private val profileImageSize = context.getString(R.string.profile_image_size)
@Inject
lateinit var userColorNameManager: UserColorNameManager
@ -149,9 +152,10 @@ class ParcelableUserLoader(
details.type)
}
}
val cachedUserValues = createCachedUser(twitterUser)
val cachedUserValues = createCachedUser(twitterUser, profileImageSize)
resolver.insert(CachedUsers.CONTENT_URI, cachedUserValues)
val user = ParcelableUserUtils.fromUser(twitterUser, accountKey)
val user = ParcelableUserUtils.fromUser(twitterUser, accountKey,
profileImageSize = profileImageSize)
ParcelableUserUtils.updateExtraInformation(user, details, userColorNameManager)
val response = SingleResponse.Companion.getInstance(user)
response.extras.putParcelable(EXTRA_ACCOUNT, details)

View File

@ -28,6 +28,7 @@ import org.mariotaku.microblog.library.MicroBlogException
import org.mariotaku.microblog.library.twitter.model.Paging
import org.mariotaku.microblog.library.twitter.model.ResponseList
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.R
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.ParcelableStatus
import org.mariotaku.twidere.model.UserKey
@ -52,6 +53,7 @@ class UserTimelineLoader(
tabPosition, fromUser, loadingMore) {
private val pinnedStatusesRef = AtomicReference<List<ParcelableStatus>>()
private val profileImageSize = context.getString(R.string.profile_image_size)
var pinnedStatuses: List<ParcelableStatus>?
get() = pinnedStatusesRef.get()
@ -61,17 +63,18 @@ class UserTimelineLoader(
@Throws(MicroBlogException::class)
override fun getStatuses(microBlog: MicroBlog,
details: AccountDetails,
paging: Paging): ResponseList<Status> {
details: AccountDetails,
paging: Paging): ResponseList<Status> {
if (pinnedStatusIds != null) {
try {
pinnedStatuses = microBlog.lookupStatuses(pinnedStatusIds).mapIndexed { idx, status ->
val created = ParcelableStatusUtils.fromStatus(status, details.key, false)
pinnedStatuses = try {
microBlog.lookupStatuses(pinnedStatusIds).mapIndexed { idx, status ->
val created = ParcelableStatusUtils.fromStatus(status, details.key,
profileImageSize = profileImageSize)
created.sort_id = idx.toLong()
return@mapIndexed created
}
} catch (e: MicroBlogException) {
// Ignore
null
}
}
if (userId != null) {

View File

@ -23,7 +23,7 @@ object ParcelableActivityUtils {
* @return true if source ids changed, false otherwise
*/
fun initAfterFilteredSourceIds(activity: ParcelableActivity, filteredUserIds: Array<UserKey>,
followingOnly: Boolean): Boolean {
followingOnly: Boolean): Boolean {
if (activity.sources == null) return false
if (activity.after_filtered_source_ids != null) return false
if (followingOnly || filteredUserIds.isNotEmpty()) {
@ -57,9 +57,8 @@ object ParcelableActivityUtils {
return result
}
fun fromActivity(activity: Activity,
accountKey: UserKey,
isGap: Boolean): ParcelableActivity {
fun fromActivity(activity: Activity, accountKey: UserKey, isGap: Boolean,
profileImageSize: String = "normal"): ParcelableActivity {
val result = ParcelableActivity()
result.account_key = accountKey
result.timestamp = activity.createdAt.time
@ -68,13 +67,13 @@ object ParcelableActivityUtils {
result.min_sort_position = activity.minSortPosition
result.max_position = activity.maxPosition
result.min_position = activity.minPosition
result.sources = ParcelableUserUtils.fromUsers(activity.sources, accountKey)
result.target_users = ParcelableUserUtils.fromUsers(activity.targetUsers, accountKey)
result.sources = ParcelableUserUtils.fromUsers(activity.sources, accountKey, profileImageSize)
result.target_users = ParcelableUserUtils.fromUsers(activity.targetUsers, accountKey, profileImageSize)
result.target_user_lists = ParcelableUserListUtils.fromUserLists(activity.targetUserLists, accountKey)
result.target_statuses = ParcelableStatusUtils.fromStatuses(activity.targetStatuses, accountKey)
result.target_object_statuses = ParcelableStatusUtils.fromStatuses(activity.targetObjectStatuses, accountKey)
result.target_statuses = ParcelableStatusUtils.fromStatuses(activity.targetStatuses, accountKey, profileImageSize)
result.target_object_statuses = ParcelableStatusUtils.fromStatuses(activity.targetObjectStatuses, accountKey, profileImageSize)
result.target_object_user_lists = ParcelableUserListUtils.fromUserLists(activity.targetObjectUserLists, accountKey)
result.target_object_users = ParcelableUserUtils.fromUsers(activity.targetObjectUsers, accountKey)
result.target_object_users = ParcelableUserUtils.fromUsers(activity.targetObjectUsers, accountKey, profileImageSize)
result.has_following_source = activity.sources.fold(false) { folded, item ->
if (item.isFollowing) {
return@fold true

View File

@ -34,7 +34,8 @@ object ParcelableMessageUtils {
return result
}
fun fromEntry(accountKey: UserKey, entry: DMResponse.Entry, users: Map<String, User>): ParcelableMessage? {
fun fromEntry(accountKey: UserKey, entry: DMResponse.Entry, users: Map<String, User>,
profileImageSize: String = "normal"): ParcelableMessage? {
when {
entry.message != null -> {
return ParcelableMessage().apply { applyMessage(accountKey, entry.message) }
@ -60,13 +61,13 @@ object ParcelableMessageUtils {
entry.conversationNameUpdate != null -> {
return ParcelableMessage().apply {
applyInfoUpdatedEvent(accountKey, entry.conversationNameUpdate, users,
MessageType.CONVERSATION_NAME_UPDATE)
MessageType.CONVERSATION_NAME_UPDATE, profileImageSize)
}
}
entry.conversationAvatarUpdate != null -> {
return ParcelableMessage().apply {
applyInfoUpdatedEvent(accountKey, entry.conversationAvatarUpdate, users,
MessageType.CONVERSATION_AVATAR_UPDATE)
MessageType.CONVERSATION_AVATAR_UPDATE, profileImageSize)
}
}
}
@ -114,13 +115,15 @@ object ParcelableMessageUtils {
}
private fun ParcelableMessage.applyInfoUpdatedEvent(accountKey: UserKey, message: Message,
users: Map<String, User>, @MessageType type: String) {
users: Map<String, User>, @MessageType type: String, profileImageSize: String = "normal") {
this.commonEntry(accountKey, message)
this.message_type = type
this.extras = ConversationInfoUpdatedExtras().apply {
this.name = message.conversationName
this.avatar = message.conversationAvatarImageHttps
this.user = users[message.byUserId]?.let { ParcelableUserUtils.fromUser(it, accountKey) }
this.user = users[message.byUserId]?.let {
ParcelableUserUtils.fromUser(it, accountKey, profileImageSize = profileImageSize)
}
}
this.is_outgoing = false
}

View File

@ -3,11 +3,11 @@ package org.mariotaku.twidere.model.util
import android.text.Spanned
import android.text.style.URLSpan
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.extension.model.api.getProfileImageOfSize
import org.mariotaku.twidere.model.*
import org.mariotaku.twidere.model.ParcelableStatus.FilterFlags
import org.mariotaku.twidere.util.HtmlSpanBuilder
import org.mariotaku.twidere.util.InternalTwitterContentUtils
import org.mariotaku.twidere.util.TwitterContentUtils
import java.util.*
/**
@ -26,7 +26,8 @@ object ParcelableStatusUtils {
status.retweet_id = null
}
fun fromStatus(orig: Status, accountKey: UserKey, isGap: Boolean): ParcelableStatus {
fun fromStatus(orig: Status, accountKey: UserKey, isGap: Boolean = false,
profileImageSize: String = "normal"): ParcelableStatus {
val result = ParcelableStatus()
result.is_gap = isGap
result.account_key = accountKey
@ -53,7 +54,7 @@ object ParcelableStatusUtils {
result.retweeted_by_user_key = UserKeyUtils.fromUser(retweetUser)
result.retweeted_by_user_name = retweetUser.name
result.retweeted_by_user_screen_name = retweetUser.screenName
result.retweeted_by_user_profile_image = TwitterContentUtils.getProfileImageUrl(retweetUser)
result.retweeted_by_user_profile_image = retweetUser.getProfileImageOfSize(profileImageSize)
result.extras.retweeted_external_url = retweetedStatus.inferExternalUrl()
@ -104,7 +105,7 @@ object ParcelableStatusUtils {
result.quoted_user_key = UserKeyUtils.fromUser(quotedUser)
result.quoted_user_name = quotedUser.name
result.quoted_user_screen_name = quotedUser.screenName
result.quoted_user_profile_image = TwitterContentUtils.getProfileImageUrl(quotedUser)
result.quoted_user_profile_image = quotedUser.getProfileImageOfSize(profileImageSize)
result.quoted_user_is_protected = quotedUser.isProtected
result.quoted_user_is_verified = quotedUser.isVerified
@ -128,12 +129,13 @@ object ParcelableStatusUtils {
result.user_key = UserKeyUtils.fromUser(user)
result.user_name = user.name
result.user_screen_name = user.screenName
result.user_profile_image_url = TwitterContentUtils.getProfileImageUrl(user)
result.user_profile_image_url = user.getProfileImageOfSize(profileImageSize)
result.user_is_protected = user.isProtected
result.user_is_verified = user.isVerified
result.user_is_following = user.isFollowing
result.extras.user_profile_image_url_profile_size = user.profileImageUrlProfileSize
result.extras.user_statusnet_profile_url = user.statusnetProfileUrl
result.extras.user_profile_image_url_fallback = user.profileImageUrlHttps ?: user.profileImageUrl
if (result.extras.user_profile_image_url_profile_size == null) {
result.extras.user_profile_image_url_profile_size = user.profileImageUrlLarge
}
@ -208,10 +210,11 @@ object ParcelableStatusUtils {
return UserKey(inReplyToUserId, accountKey.host)
}
fun fromStatuses(statuses: Array<Status>?, accountKey: UserKey): Array<ParcelableStatus>? {
fun fromStatuses(statuses: Array<Status>?, accountKey: UserKey,
profileImageSize: String = "normal"): Array<ParcelableStatus>? {
if (statuses == null) return null
return Array(statuses.size) { i ->
fromStatus(statuses[i], accountKey, false)
fromStatus(statuses[i], accountKey, false, profileImageSize)
}
}

View File

@ -4,12 +4,12 @@ import android.text.TextUtils
import org.mariotaku.ktextension.isNotNullOrEmpty
import org.mariotaku.microblog.library.twitter.model.User
import org.mariotaku.twidere.TwidereConstants.USER_TYPE_FANFOU_COM
import org.mariotaku.twidere.extension.model.api.getProfileImageOfSize
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.util.InternalTwitterContentUtils
import org.mariotaku.twidere.util.ParseUtils
import org.mariotaku.twidere.util.TwitterContentUtils
import org.mariotaku.twidere.util.UserColorNameManager
/**
@ -20,7 +20,8 @@ import org.mariotaku.twidere.util.UserColorNameManager
*/
object ParcelableUserUtils {
fun fromUser(user: User, accountKey: UserKey?, position: Long = 0): ParcelableUser {
fun fromUser(user: User, accountKey: UserKey?, position: Long = 0,
profileImageSize: String = "normal"): ParcelableUser {
val urlEntities = user.urlEntities
val obj = ParcelableUser()
obj.position = position
@ -38,7 +39,7 @@ object ParcelableUserUtils {
obj.description_spans = userDescription.second
}
obj.location = user.location
obj.profile_image_url = TwitterContentUtils.getProfileImageUrl(user)
obj.profile_image_url = user.getProfileImageOfSize(profileImageSize)
obj.profile_banner_url = user.profileBannerImageUrl
obj.profile_background_url = user.profileBackgroundImageUrlHttps
if (TextUtils.isEmpty(obj.profile_background_url)) {
@ -81,8 +82,8 @@ object ParcelableUserUtils {
return obj
}
fun fromUsers(users: Array<User>?, accountKey: UserKey?): Array<ParcelableUser>? {
return users?.map { fromUser(it, accountKey) }?.toTypedArray()
fun fromUsers(users: Array<User>?, accountKey: UserKey?, profileImageSize: String = "normal"): Array<ParcelableUser>? {
return users?.map { fromUser(it, accountKey, profileImageSize = profileImageSize) }?.toTypedArray()
}
fun parseColor(colorString: String?): Int {

View File

@ -24,6 +24,7 @@ import android.content.Context
import com.twitter.Extractor
import org.mariotaku.abstask.library.AbstractTask
import org.mariotaku.microblog.library.twitter.model.Status
import org.mariotaku.twidere.R
import org.mariotaku.twidere.provider.TwidereDataStore.*
import org.mariotaku.twidere.util.ContentValuesCreator
import org.mariotaku.twidere.util.InternalTwitterContentUtils
@ -35,6 +36,8 @@ class CacheUsersStatusesTask(
private val context: Context
) : AbstractTask<TwitterListResponse<Status>, Unit?, Unit?>() {
private val profileImageSize = context.getString(R.string.profile_image_size)
override fun doLongOperation(params: TwitterListResponse<Status>) {
val resolver = context.contentResolver
val extractor = Extractor()
@ -52,7 +55,7 @@ class CacheUsersStatusesTask(
val hashTagValues = HashSet<ContentValues>()
val accountKey = params.accountKey
statusesValues.add(ContentValuesCreator.createStatus(status, accountKey))
statusesValues.add(ContentValuesCreator.createStatus(status, accountKey, profileImageSize))
val text = InternalTwitterContentUtils.unescapeTwitterStatusText(status.extendedText)
for (hashtag in extractor.extractHashtags(text)) {
val values = ContentValues()
@ -63,7 +66,8 @@ class CacheUsersStatusesTask(
cachedUser.put(CachedUsers.LAST_SEEN, System.currentTimeMillis())
usersValues.add(cachedUser)
if (status.isRetweet) {
val cachedRetweetedUser = ContentValuesCreator.createCachedUser(status.retweetedStatus.user)
val cachedRetweetedUser = ContentValuesCreator.createCachedUser(status.retweetedStatus.user,
profileImageSize)
cachedRetweetedUser.put(CachedUsers.LAST_SEEN, System.currentTimeMillis())
usersValues.add(cachedRetweetedUser)
}

View File

@ -26,6 +26,8 @@ open class UpdateProfileBannerImageTask<ResultHandler>(
private val deleteImage: Boolean
) : BaseAbstractTask<Any?, SingleResponse<ParcelableUser>, ResultHandler>(context) {
private val profileImageSize = context.getString(R.string.profile_image_size)
override fun afterExecute(handler: ResultHandler?, result: SingleResponse<ParcelableUser>?) {
super.afterExecute(handler, result)
if (result!!.hasData()) {
@ -50,7 +52,8 @@ open class UpdateProfileBannerImageTask<ResultHandler>(
}
val user = twitter.verifyCredentials()
return SingleResponse(ParcelableUserUtils.fromUser(user, accountKey))
return SingleResponse(ParcelableUserUtils.fromUser(user, accountKey,
profileImageSize = profileImageSize))
} catch (e: MicroBlogException) {
return SingleResponse(exception = e)
} catch (e: IOException) {

View File

@ -26,9 +26,12 @@ open class UpdateProfileImageTask<ResultHandler>(
private val deleteImage: Boolean
) : BaseAbstractTask<Any?, SingleResponse<ParcelableUser>, ResultHandler>(context) {
private val profileImageSize = context.getString(R.string.profile_image_size)
override fun doLongOperation(params: Any?): SingleResponse<ParcelableUser> {
try {
val microBlog = MicroBlogAPIFactory.getInstance(context, accountKey)!!
val microBlog = MicroBlogAPIFactory.getInstance(context, accountKey)
?: throw MicroBlogException("No account")
TwitterWrapper.updateProfileImage(context, microBlog, imageUri, deleteImage)
// Wait for 5 seconds, see
// https://dev.twitter.com/rest/reference/post/account/update_profile_image
@ -39,7 +42,8 @@ open class UpdateProfileImageTask<ResultHandler>(
}
val user = microBlog.verifyCredentials()
return SingleResponse(ParcelableUserUtils.fromUser(user, accountKey))
return SingleResponse(ParcelableUserUtils.fromUser(user, accountKey,
profileImageSize = profileImageSize))
} catch (e: MicroBlogException) {
return SingleResponse(exception = e)
} catch (e: IOException) {

View File

@ -13,6 +13,7 @@ import org.mariotaku.microblog.library.twitter.model.Activity
import org.mariotaku.microblog.library.twitter.model.Paging
import org.mariotaku.microblog.library.twitter.model.ResponseList
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.LOGTAG
import org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_SHOW_NOTIFICATION
import org.mariotaku.twidere.constant.loadItemLimitKey
@ -37,6 +38,8 @@ abstract class GetActivitiesTask(
context: Context
) : BaseAbstractTask<RefreshTaskParam, List<TwitterListResponse<Activity>>, (Boolean) -> Unit>(context) {
private val profileImageSize = context.getString(R.string.profile_image_size)
protected abstract val errorInfoKey: String
protected abstract val contentUri: Uri
@ -115,8 +118,8 @@ abstract class GetActivitiesTask(
}
private fun storeActivities(cr: ContentResolver, loadItemLimit: Int, details: AccountDetails,
noItemsBefore: Boolean, activities: ResponseList<Activity>,
sinceId: String?, maxId: String?, notify: Boolean): Int {
noItemsBefore: Boolean, activities: ResponseList<Activity>,
sinceId: String?, maxId: String?, notify: Boolean): Int {
val deleteBound = LongArray(2) { -1 }
val valuesList = ArrayList<ContentValues>()
var minIdx = -1
@ -128,7 +131,8 @@ abstract class GetActivitiesTask(
val sortDiff = firstSortId - lastSortId
for (i in activities.indices) {
val item = activities[i]
val activity = ParcelableActivityUtils.fromActivity(item, details.key, false)
val activity = ParcelableActivityUtils.fromActivity(item, details.key, false,
profileImageSize)
mediaLoader.preloadActivity(activity)
activity.position_key = GetStatusesTask.getPositionKey(activity.timestamp,
activity.timestamp, lastSortId, sortDiff, i, activities.size)

View File

@ -44,6 +44,8 @@ abstract class GetStatusesTask(
context: Context
) : BaseAbstractTask<RefreshTaskParam, List<TwitterWrapper.StatusListResponse>, (Boolean) -> Unit>(context) {
private val profileImageSize = context.getString(R.string.profile_image_size)
@Throws(MicroBlogException::class)
abstract fun getStatuses(twitter: MicroBlog, paging: Paging): ResponseList<Status>
@ -144,10 +146,10 @@ abstract class GetStatusesTask(
}
private fun storeStatus(accountKey: UserKey, details: AccountDetails,
statuses: List<Status>,
sinceId: String?, maxId: String?,
sinceSortId: Long, maxSortId: Long,
loadItemLimit: Int, notify: Boolean): Int {
statuses: List<Status>,
sinceId: String?, maxId: String?,
sinceSortId: Long, maxSortId: Long,
loadItemLimit: Int, notify: Boolean): Int {
val uri = contentUri
val writeUri = UriUtils.appendQueryParameters(uri, QUERY_PARAM_SHOW_NOTIFICATION, notify)
val resolver = context.contentResolver
@ -165,8 +167,7 @@ abstract class GetStatusesTask(
for (i in 0 until statuses.size) {
val item = statuses[i]
val status = ParcelableStatusUtils.fromStatus(item, accountKey,
false)
val status = ParcelableStatusUtils.fromStatus(item, accountKey, false, profileImageSize)
ParcelableStatusUtils.updateExtraInformation(status, details)
status.position_key = getPositionKey(status.timestamp, status.sort_id, lastSortId,
sortDiff, i, statuses.size)
@ -244,7 +245,7 @@ abstract class GetStatusesTask(
const val ERROR_LOAD_GAP = 1
fun getPositionKey(timestamp: Long, sortId: Long, lastSortId: Long, sortDiff: Long,
position: Int, count: Int): Long {
position: Int, count: Int): Long {
if (sortDiff == 0L) return timestamp
val extraValue: Int
if (sortDiff > 0) {

View File

@ -23,6 +23,7 @@ import android.accounts.AccountManager
import android.content.Context
import org.mariotaku.microblog.library.MicroBlog
import org.mariotaku.microblog.library.MicroBlogException
import org.mariotaku.twidere.R
import org.mariotaku.twidere.annotation.AccountType
import org.mariotaku.twidere.extension.model.addParticipants
import org.mariotaku.twidere.extension.model.isOfficial
@ -45,6 +46,9 @@ class AddParticipantsTask(
val conversationId: String,
val participants: Collection<ParcelableUser>
) : ExceptionHandlingAbstractTask<Unit?, Boolean, MicroBlogException, ((Boolean) -> Unit)?>(context) {
private val profileImageSize: String = context.getString(R.string.profile_image_size)
override fun onExecute(params: Unit?): Boolean {
val account = AccountUtils.getAccountDetails(AccountManager.get(context), accountKey, true) ?:
throw MicroBlogException("No account")
@ -78,7 +82,8 @@ class AddParticipantsTask(
conversation.addParticipants(participants)
return GetMessagesTask.DatabaseUpdateData(listOf(conversation), emptyList())
}
return GetMessagesTask.createDatabaseUpdateData(context, account, response)
return GetMessagesTask.createDatabaseUpdateData(context, account, response,
profileImageSize)
}
}

View File

@ -31,6 +31,7 @@ import org.mariotaku.microblog.library.twitter.model.DMResponse
import org.mariotaku.microblog.library.twitter.model.DirectMessage
import org.mariotaku.microblog.library.twitter.model.Paging
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.R
import org.mariotaku.twidere.TwidereConstants.QUERY_PARAM_SHOW_NOTIFICATION
import org.mariotaku.twidere.annotation.AccountType
import org.mariotaku.twidere.extension.model.*
@ -58,6 +59,9 @@ import java.util.*
class GetMessagesTask(
context: Context
) : BaseAbstractTask<GetMessagesTask.RefreshMessagesTaskParam, Unit, (Boolean) -> Unit>(context) {
private val profileImageSize = context.getString(R.string.profile_image_size)
override fun doLongOperation(param: RefreshMessagesTaskParam) {
val accountKeys = param.accountKeys
val am = android.accounts.AccountManager.get(context)
@ -176,7 +180,7 @@ class GetMessagesTask(
}
val response = microBlog.getDmConversation(conversationId, paging).conversationTimeline
return Companion.createDatabaseUpdateData(context, details, response)
return createDatabaseUpdateData(context, details, response, profileImageSize)
}
private fun getTwitterOfficialUserInbox(microBlog: MicroBlog, details: AccountDetails,
@ -192,7 +196,7 @@ class GetMessagesTask(
}
}).userInbox
}
return Companion.createDatabaseUpdateData(context, details, response)
return createDatabaseUpdateData(context, details, response, profileImageSize)
}
@ -338,8 +342,8 @@ class GetMessagesTask(
companion object {
fun createDatabaseUpdateData(context: Context, account: AccountDetails, response: DMResponse):
DatabaseUpdateData {
fun createDatabaseUpdateData(context: Context, account: AccountDetails,
response: DMResponse, profileImageSize: String = "normal"): DatabaseUpdateData {
val accountKey = account.key
val respConversations = response.conversations.orEmpty()
@ -366,7 +370,8 @@ class GetMessagesTask(
return@mapNotNullTo null
}
else -> {
return@mapNotNullTo ParcelableMessageUtils.fromEntry(accountKey, entry, respUsers)
return@mapNotNullTo ParcelableMessageUtils.fromEntry(accountKey, entry,
respUsers, profileImageSize)
}
}
}

View File

@ -27,6 +27,7 @@ import org.mariotaku.microblog.library.twitter.TwitterUpload
import org.mariotaku.microblog.library.twitter.model.DirectMessage
import org.mariotaku.microblog.library.twitter.model.NewDm
import org.mariotaku.sqliteqb.library.Expression
import org.mariotaku.twidere.R
import org.mariotaku.twidere.annotation.AccountType
import org.mariotaku.twidere.extension.model.isOfficial
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
@ -51,6 +52,8 @@ class SendMessageTask(
) : ExceptionHandlingAbstractTask<ParcelableNewMessage, SendMessageTask.SendMessageResult,
MicroBlogException, Unit>(context) {
private val profileImageSize = context.getString(R.string.profile_image_size)
override fun onExecute(params: ParcelableNewMessage): SendMessageResult {
val account = params.account
val microBlog = account.newMicroBlogInstance(context, cls = MicroBlog::class.java)
@ -128,7 +131,7 @@ class SendMessageTask(
it.message != null
}?.message?.conversationId
val response = microBlog.getDmConversation(conversationId, null).conversationTimeline
return GetMessagesTask.createDatabaseUpdateData(context, account, response)
return GetMessagesTask.createDatabaseUpdateData(context, account, response, profileImageSize)
}
private fun sendFanfouDM(microBlog: MicroBlog, account: AccountDetails, message: ParcelableNewMessage): GetMessagesTask.DatabaseUpdateData {
@ -174,8 +177,10 @@ class SendMessageTask(
val conversations = hashMapOf<String, ParcelableMessageConversation>()
conversations.addLocalConversations(context, accountKey, conversationIds)
val message = ParcelableMessageUtils.fromMessage(accountKey, dm, true)
val sender = ParcelableUserUtils.fromUser(dm.sender, accountKey)
val recipient = ParcelableUserUtils.fromUser(dm.recipient, accountKey)
val sender = ParcelableUserUtils.fromUser(dm.sender, accountKey,
profileImageSize = profileImageSize)
val recipient = ParcelableUserUtils.fromUser(dm.recipient, accountKey,
profileImageSize = profileImageSize)
conversations.addConversation(message.conversation_id, details, message, setOf(sender, recipient), true)
return GetMessagesTask.DatabaseUpdateData(conversations.values, listOf(message))
}

View File

@ -32,9 +32,10 @@ import org.mariotaku.twidere.provider.TwidereDataStore.SavedSearches
object ContentValuesCreator {
fun createCachedUser(user: User): ContentValues {
fun createCachedUser(user: User, profileImageSize: String = "normal"): ContentValues {
val values = ContentValues()
ParcelableUserValuesCreator.writeTo(ParcelableUserUtils.fromUser(user, null), values)
ParcelableUserValuesCreator.writeTo(ParcelableUserUtils.fromUser(user, null,
profileImageSize = profileImageSize), values)
return values
}
@ -76,9 +77,9 @@ object ContentValuesCreator {
return savedSearches.map { createSavedSearch(it, accountKey) }.toTypedArray()
}
fun createStatus(orig: Status, accountKey: UserKey): ContentValues {
fun createStatus(orig: Status, accountKey: UserKey, profileImageSize: String): ContentValues {
return ParcelableStatusValuesCreator.create(ParcelableStatusUtils.fromStatus(orig,
accountKey, false))
accountKey, false, profileImageSize))
}
fun createActivity(activity: ParcelableActivity, details: AccountDetails): ContentValues {

View File

@ -30,7 +30,6 @@ import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.ParcelableActivitiesAdapter
import org.mariotaku.twidere.adapter.iface.IActivitiesAdapter
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.model.ActivityTitleSummaryMessage
import org.mariotaku.twidere.model.ParcelableActivity
import org.mariotaku.twidere.model.ParcelableUser
@ -118,31 +117,31 @@ class ActivityTitleSummaryViewHolder(
}
}
private fun displayUserProfileImages(statuses: Array<ParcelableUser>?) {
private fun displayUserProfileImages(users: Array<ParcelableUser>?) {
val shouldDisplayImages = adapter.profileImageEnabled
profileImagesContainer.visibility = if (shouldDisplayImages) View.VISIBLE else View.GONE
profileImageSpace.visibility = if (shouldDisplayImages) View.VISIBLE else View.GONE
if (!shouldDisplayImages) return
if (statuses == null) {
if (users == null) {
for (view in profileImageViews) {
view.visibility = View.GONE
}
return
}
val length = Math.min(profileImageViews.size, statuses.size)
val length = Math.min(profileImageViews.size, users.size)
for (i in 0 until profileImageViews.size) {
val view = profileImageViews[i]
view.setImageDrawable(null)
if (i < length) {
view.visibility = View.VISIBLE
val context = adapter.context
adapter.getRequestManager().loadProfileImage(context, statuses[i].getBestProfileImage(context)).into(view)
adapter.getRequestManager().loadProfileImage(context, users[i]).into(view)
} else {
view.visibility = View.GONE
}
}
if (statuses.size > profileImageViews.size) {
val moreNumber = statuses.size - profileImageViews.size
if (users.size > profileImageViews.size) {
val moreNumber = users.size - profileImageViews.size
profileImageMoreNumber.visibility = View.VISIBLE
profileImageMoreNumber.setText(moreNumber.toString())
} else {

View File

@ -8,7 +8,6 @@ import kotlinx.android.synthetic.main.list_item_simple_user.view.*
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.iface.IContentAdapter
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.view.ProfileImageView
@ -35,7 +34,7 @@ open class SimpleUserViewHolder<out A : IContentAdapter>(
secondaryNameView.text = "@${user.screen_name}"
if (adapter.profileImageEnabled) {
val context = itemView.context
adapter.getRequestManager().loadProfileImage(context, user.getBestProfileImage(context)).into(profileImageView)
adapter.getRequestManager().loadProfileImage(context, user).into(profileImageView)
profileImageView.visibility = View.VISIBLE
} else {
profileImageView.visibility = View.GONE

View File

@ -23,7 +23,6 @@ import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.applyTo
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.graphic.like.LikeAnimationDrawable
import org.mariotaku.twidere.model.ParcelableLocation
import org.mariotaku.twidere.model.ParcelableMedia
@ -299,7 +298,7 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
if (adapter.profileImageEnabled) {
profileImageView.visibility = View.VISIBLE
getRequestManager().loadProfileImage(context, status.getBestProfileImage(context)).into(profileImageView)
getRequestManager().loadProfileImage(context, status).into(profileImageView)
profileTypeView.setImageResource(getUserTypeIconRes(status.user_is_verified, status.user_is_protected))
profileTypeView.visibility = View.VISIBLE

View File

@ -30,7 +30,6 @@ import org.mariotaku.twidere.R
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.getBestProfileImage
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.util.UserKeyUtils
import org.mariotaku.twidere.util.Utils
@ -136,7 +135,7 @@ class UserViewHolder(
if (adapter.profileImageEnabled) {
profileImageView.visibility = View.VISIBLE
adapter.getRequestManager().loadProfileImage(context, user.getBestProfileImage(context)).into(profileImageView)
adapter.getRequestManager().loadProfileImage(context, user).into(profileImageView)
} else {
profileImageView.visibility = View.GONE
}

View File

@ -31,7 +31,6 @@ import android.widget.TextView
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.MessagesConversationAdapter
import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.model.getBestProfileImage
import org.mariotaku.twidere.extension.model.timestamp
import org.mariotaku.twidere.model.ParcelableMessage
import org.mariotaku.twidere.view.ProfileImageView
@ -84,7 +83,7 @@ abstract class AbsMessageViewHolder(itemView: View, val adapter: MessagesConvers
if (adapter.displaySenderProfile && adapter.profileImageEnabled && sender != null
&& !message.is_outgoing) {
this.visibility = View.VISIBLE
adapter.getRequestManager().loadProfileImage(context, sender.getBestProfileImage(context)).into(this)
adapter.getRequestManager().loadProfileImage(context, sender).into(this)
} else {
this.visibility = View.GONE
}