improved profile image quality
This commit is contained in:
parent
f837f8920c
commit
0df523234c
|
@ -23,6 +23,7 @@ import android.content.Context
|
||||||
import android.support.v4.text.BidiFormatter
|
import android.support.v4.text.BidiFormatter
|
||||||
import com.bumptech.glide.RequestManager
|
import com.bumptech.glide.RequestManager
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.adapter.iface.IContentAdapter
|
import org.mariotaku.twidere.adapter.iface.IContentAdapter
|
||||||
import org.mariotaku.twidere.adapter.iface.IItemCountsAdapter
|
import org.mariotaku.twidere.adapter.iface.IItemCountsAdapter
|
||||||
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
|
import org.mariotaku.twidere.adapter.iface.ILoadMoreSupportAdapter
|
||||||
|
@ -54,6 +55,7 @@ open class BaseArrayAdapter<T>(
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var permissionsManager: PermissionsManager
|
lateinit var permissionsManager: PermissionsManager
|
||||||
|
|
||||||
|
final override val profileImageSize: String = context.getString(R.string.profile_image_size)
|
||||||
final override val profileImageStyle: Int
|
final override val profileImageStyle: Int
|
||||||
final override val textSize: Float
|
final override val textSize: Float
|
||||||
final override val profileImageEnabled: Boolean
|
final override val profileImageEnabled: Boolean
|
||||||
|
@ -62,17 +64,16 @@ open class BaseArrayAdapter<T>(
|
||||||
|
|
||||||
override val itemCounts: ItemCounts = ItemCounts(1)
|
override val itemCounts: ItemCounts = ItemCounts(1)
|
||||||
|
|
||||||
@ILoadMoreSupportAdapter.IndicatorPosition
|
|
||||||
override var loadMoreSupportedPosition: Long = 0
|
override var loadMoreSupportedPosition: Long = 0
|
||||||
set(value) {
|
@ILoadMoreSupportAdapter.IndicatorPosition set(value) {
|
||||||
field = value
|
field = value
|
||||||
loadMoreIndicatorPosition = ILoadMoreSupportAdapter.apply(loadMoreIndicatorPosition, value)
|
loadMoreIndicatorPosition = ILoadMoreSupportAdapter.apply(loadMoreIndicatorPosition, value)
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ILoadMoreSupportAdapter.IndicatorPosition
|
|
||||||
override var loadMoreIndicatorPosition: Long = 0
|
override var loadMoreIndicatorPosition: Long = 0
|
||||||
set(value) {
|
@ILoadMoreSupportAdapter.IndicatorPosition set(value) {
|
||||||
if (field == value) return
|
if (field == value) return
|
||||||
field = ILoadMoreSupportAdapter.apply(value, loadMoreSupportedPosition)
|
field = ILoadMoreSupportAdapter.apply(value, loadMoreSupportedPosition)
|
||||||
notifyDataSetChanged()
|
notifyDataSetChanged()
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.support.v4.text.BidiFormatter
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import com.bumptech.glide.RequestManager
|
import com.bumptech.glide.RequestManager
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.adapter.iface.IContentAdapter
|
import org.mariotaku.twidere.adapter.iface.IContentAdapter
|
||||||
import org.mariotaku.twidere.constant.displayProfileImageKey
|
import org.mariotaku.twidere.constant.displayProfileImageKey
|
||||||
import org.mariotaku.twidere.constant.profileImageStyleKey
|
import org.mariotaku.twidere.constant.profileImageStyleKey
|
||||||
|
@ -58,6 +59,7 @@ abstract class BaseRecyclerViewAdapter<VH : RecyclerView.ViewHolder>(
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var defaultFeatures: DefaultFeatures
|
lateinit var defaultFeatures: DefaultFeatures
|
||||||
|
|
||||||
|
override final val profileImageSize: String = context.getString(R.string.profile_image_size)
|
||||||
override final val profileImageStyle: Int
|
override final val profileImageStyle: Int
|
||||||
override final val textSize: Float
|
override final val textSize: Float
|
||||||
override final val profileImageEnabled: Boolean
|
override final val profileImageEnabled: Boolean
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.support.v4.text.BidiFormatter
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import com.bumptech.glide.RequestManager
|
import com.bumptech.glide.RequestManager
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.adapter.iface.IGapSupportedAdapter
|
import org.mariotaku.twidere.adapter.iface.IGapSupportedAdapter
|
||||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
|
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter
|
||||||
import org.mariotaku.twidere.adapter.iface.IUserListsAdapter
|
import org.mariotaku.twidere.adapter.iface.IUserListsAdapter
|
||||||
|
@ -39,6 +40,7 @@ class DummyItemAdapter(
|
||||||
@Inject
|
@Inject
|
||||||
override lateinit var bidiFormatter: BidiFormatter
|
override lateinit var bidiFormatter: BidiFormatter
|
||||||
|
|
||||||
|
override var profileImageSize: String = context.getString(R.string.profile_image_size)
|
||||||
override var profileImageStyle: Int = 0
|
override var profileImageStyle: Int = 0
|
||||||
override var mediaPreviewStyle: Int = 0
|
override var mediaPreviewStyle: Int = 0
|
||||||
override var textSize: Float = 0f
|
override var textSize: Float = 0f
|
||||||
|
|
|
@ -21,9 +21,9 @@ package org.mariotaku.twidere.adapter.iface
|
||||||
|
|
||||||
import android.support.v4.text.BidiFormatter
|
import android.support.v4.text.BidiFormatter
|
||||||
import com.bumptech.glide.RequestManager
|
import com.bumptech.glide.RequestManager
|
||||||
|
import org.mariotaku.twidere.annotation.ImageShapeStyle
|
||||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
import org.mariotaku.twidere.util.AsyncTwitterWrapper
|
||||||
import org.mariotaku.twidere.util.UserColorNameManager
|
import org.mariotaku.twidere.util.UserColorNameManager
|
||||||
import org.mariotaku.twidere.annotation.ImageShapeStyle
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 15/1/3.
|
* Created by mariotaku on 15/1/3.
|
||||||
|
@ -37,6 +37,8 @@ interface IContentAdapter {
|
||||||
@ImageShapeStyle
|
@ImageShapeStyle
|
||||||
val profileImageStyle: Int
|
val profileImageStyle: Int
|
||||||
|
|
||||||
|
val profileImageSize: String
|
||||||
|
|
||||||
val profileImageEnabled: Boolean
|
val profileImageEnabled: Boolean
|
||||||
|
|
||||||
val textSize: Float
|
val textSize: Float
|
||||||
|
|
|
@ -34,8 +34,9 @@ open class SimpleUserViewHolder<out A : IContentAdapter>(
|
||||||
secondaryNameView.text = "@${user.screen_name}"
|
secondaryNameView.text = "@${user.screen_name}"
|
||||||
if (adapter.profileImageEnabled) {
|
if (adapter.profileImageEnabled) {
|
||||||
val context = itemView.context
|
val context = itemView.context
|
||||||
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle)
|
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle,
|
||||||
.into(profileImageView)
|
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio,
|
||||||
|
adapter.profileImageSize).into(profileImageView)
|
||||||
profileImageView.visibility = View.VISIBLE
|
profileImageView.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
profileImageView.visibility = View.GONE
|
profileImageView.visibility = View.GONE
|
||||||
|
|
|
@ -298,8 +298,8 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View)
|
||||||
if (adapter.profileImageEnabled) {
|
if (adapter.profileImageEnabled) {
|
||||||
profileImageView.visibility = View.VISIBLE
|
profileImageView.visibility = View.VISIBLE
|
||||||
requestManager.loadProfileImage(context, status, adapter.profileImageStyle,
|
requestManager.loadProfileImage(context, status, adapter.profileImageStyle,
|
||||||
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio)
|
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio,
|
||||||
.into(profileImageView)
|
adapter.profileImageSize).into(profileImageView)
|
||||||
|
|
||||||
profileTypeView.setImageResource(getUserTypeIconRes(status.user_is_verified, status.user_is_protected))
|
profileTypeView.setImageResource(getUserTypeIconRes(status.user_is_verified, status.user_is_protected))
|
||||||
profileTypeView.visibility = View.VISIBLE
|
profileTypeView.visibility = View.VISIBLE
|
||||||
|
|
|
@ -136,7 +136,8 @@ class UserViewHolder(
|
||||||
if (adapter.profileImageEnabled) {
|
if (adapter.profileImageEnabled) {
|
||||||
profileImageView.visibility = View.VISIBLE
|
profileImageView.visibility = View.VISIBLE
|
||||||
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle,
|
adapter.requestManager.loadProfileImage(context, user, adapter.profileImageStyle,
|
||||||
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio).into(profileImageView)
|
profileImageView.cornerRadius, profileImageView.cornerRadiusRatio,
|
||||||
|
adapter.profileImageSize).into(profileImageView)
|
||||||
} else {
|
} else {
|
||||||
profileImageView.visibility = View.GONE
|
profileImageView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue