improved profile image quality

This commit is contained in:
Mariotaku Lee 2017-03-21 18:55:03 +08:00
parent f837f8920c
commit 0df523234c
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
7 changed files with 19 additions and 10 deletions

View File

@ -23,6 +23,7 @@ import android.content.Context
import android.support.v4.text.BidiFormatter
import com.bumptech.glide.RequestManager
import org.mariotaku.kpreferences.get
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.iface.IContentAdapter
import org.mariotaku.twidere.adapter.iface.IItemCountsAdapter
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
@ -54,6 +55,7 @@ open class BaseArrayAdapter<T>(
@Inject
lateinit var permissionsManager: PermissionsManager
final override val profileImageSize: String = context.getString(R.string.profile_image_size)
final override val profileImageStyle: Int
final override val textSize: Float
final override val profileImageEnabled: Boolean
@ -62,17 +64,16 @@ open class BaseArrayAdapter<T>(
override val itemCounts: ItemCounts = ItemCounts(1)
@ILoadMoreSupportAdapter.IndicatorPosition
override var loadMoreSupportedPosition: Long = 0
set(value) {
@ILoadMoreSupportAdapter.IndicatorPosition set(value) {
field = value
loadMoreIndicatorPosition = ILoadMoreSupportAdapter.apply(loadMoreIndicatorPosition, value)
notifyDataSetChanged()
}
@ILoadMoreSupportAdapter.IndicatorPosition
override var loadMoreIndicatorPosition: Long = 0
set(value) {
@ILoadMoreSupportAdapter.IndicatorPosition set(value) {
if (field == value) return
field = ILoadMoreSupportAdapter.apply(value, loadMoreSupportedPosition)
notifyDataSetChanged()

View File

@ -24,6 +24,7 @@ import android.support.v4.text.BidiFormatter
import android.support.v7.widget.RecyclerView
import com.bumptech.glide.RequestManager
import org.mariotaku.kpreferences.get
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.iface.IContentAdapter
import org.mariotaku.twidere.constant.displayProfileImageKey
import org.mariotaku.twidere.constant.profileImageStyleKey
@ -58,6 +59,7 @@ abstract class BaseRecyclerViewAdapter<VH : RecyclerView.ViewHolder>(
@Inject
lateinit var defaultFeatures: DefaultFeatures
override final val profileImageSize: String = context.getString(R.string.profile_image_size)
override final val profileImageStyle: Int
override final val textSize: Float
override final val profileImageEnabled: Boolean

View File

@ -5,6 +5,7 @@ import android.support.v4.text.BidiFormatter
import android.support.v7.widget.RecyclerView
import com.bumptech.glide.RequestManager
import org.mariotaku.kpreferences.get
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.iface.IGapSupportedAdapter
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
import org.mariotaku.twidere.adapter.iface.IUserListsAdapter
@ -39,6 +40,7 @@ class DummyItemAdapter(
@Inject
override lateinit var bidiFormatter: BidiFormatter
override var profileImageSize: String = context.getString(R.string.profile_image_size)
override var profileImageStyle: Int = 0
override var mediaPreviewStyle: Int = 0
override var textSize: Float = 0f

View File

@ -21,9 +21,9 @@ package org.mariotaku.twidere.adapter.iface
import android.support.v4.text.BidiFormatter
import com.bumptech.glide.RequestManager
import org.mariotaku.twidere.annotation.ImageShapeStyle
import org.mariotaku.twidere.util.AsyncTwitterWrapper
import org.mariotaku.twidere.util.UserColorNameManager
import org.mariotaku.twidere.annotation.ImageShapeStyle
/**
* Created by mariotaku on 15/1/3.
@ -37,6 +37,8 @@ interface IContentAdapter {
@ImageShapeStyle
val profileImageStyle: Int
val profileImageSize: String
val profileImageEnabled: Boolean
val textSize: Float

View File

@ -34,8 +34,9 @@ open class SimpleUserViewHolder<out A : IContentAdapter>(
secondaryNameView.text = "@${user.screen_name}"
if (adapter.profileImageEnabled) {
val context = itemView.context
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle)
.into(profileImageView)
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle,
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio,
adapter.profileImageSize).into(profileImageView)
profileImageView.visibility = View.VISIBLE
} else {
profileImageView.visibility = View.GONE

View File

@ -298,8 +298,8 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
if (adapter.profileImageEnabled) {
profileImageView.visibility = View.VISIBLE
requestManager.loadProfileImage(context, status, adapter.profileImageStyle,
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio)
.into(profileImageView)
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio,
adapter.profileImageSize).into(profileImageView)
profileTypeView.setImageResource(getUserTypeIconRes(status.user_is_verified, status.user_is_protected))
profileTypeView.visibility = View.VISIBLE

View File

@ -136,7 +136,8 @@ class UserViewHolder(
if (adapter.profileImageEnabled) {
profileImageView.visibility = View.VISIBLE
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle,
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio).into(profileImageView)
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio,
adapter.profileImageSize).into(profileImageView)
} else {
profileImageView.visibility = View.GONE
}