Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package no.getspiff.spiff.adapters.viewHolders
- import android.app.Activity
- import android.content.Context
- import android.graphics.Color
- import android.support.text.emoji.EmojiCompat
- import android.support.v4.content.ContextCompat
- import android.support.v7.widget.CardView
- import android.support.v7.widget.RecyclerView
- import android.view.View
- import android.widget.TextView
- import kotlinx.android.synthetic.main.row_savings_plan.view.*
- import no.getspiff.spiff.R
- import no.getspiff.spiff.model.SavingsPlanPresentation
- import android.support.v4.graphics.drawable.DrawableCompat
- class SavingsPlanNewViewHolder(val view: View,
- val context: Context?,
- val activity: Activity? = null) : RecyclerView.ViewHolder(view) {
- private val titleTextView: TextView = view.titleTextView
- private val savingsPlanCardView: CardView = view.savingsPlanCardView
- private val progressTextView : TextView = view.progressTextView
- fun set(position: Int, data: SavingsPlanPresentation?) {
- data?.let {
- itemView.id = position
- titleTextView.text = EmojiCompat.get().process(data.title)
- progressTextView.text = data.humanReadableIndividualProgress.toString()
- val normalColor = data.color
- val disabledColor = Color.argb(
- 99,
- Color.red(normalColor),
- Color.green(normalColor),
- Color.blue(normalColor))
- if(data.categoryId=="wallet"){
- savingsPlanCardView.background = ContextCompat.getDrawable(this.context!!, R.drawable.wallet_border)
- titleTextView.setTextColor(ContextCompat.getColor(context, R.color.colorDurple))
- val drawable1 = ContextCompat.getDrawable(context, R.drawable.ic_wallet)
- drawable1?.let { it1 -> DrawableCompat.setTint(it1,ContextCompat.getColor(context,R.color.colorDurple)) }
- titleTextView.setCompoundDrawablesWithIntrinsicBounds(drawable1, null, null, null)
- progressTextView.setTextColor(ContextCompat.getColor(context, R.color.colorDurple))
- titleTextView.compoundDrawablePadding = 12
- }
- if(data.isSelected){
- if(data.categoryId=="wallet"){
- titleTextView.setTextColor(ContextCompat.getColor(this.context!!,R.color.colorGreyLight))
- progressTextView.setTextColor(ContextCompat.getColor(context, R.color.colorGreyLight))
- val drawable = ContextCompat.getDrawable(context, R.drawable.ic_wallet)
- drawable?.let { it1 -> DrawableCompat.setTint(it1,ContextCompat.getColor(context,R.color.colorGreyLight)) }
- titleTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
- titleTextView.compoundDrawablePadding = 12
- }else{
- savingsPlanCardView.setCardBackgroundColor(disabledColor)
- }
- }else{
- if(data.categoryId=="wallet"){
- titleTextView.setTextColor(ContextCompat.getColor(this.context!!,R.color.colorDurple))
- progressTextView.setTextColor(ContextCompat.getColor(context, R.color.colorDurple))
- val drawable = ContextCompat.getDrawable(context, R.drawable.ic_wallet)
- drawable?.let { it1 -> DrawableCompat.setTint(it1,ContextCompat.getColor(context,R.color.colorDurple)) }
- titleTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
- titleTextView.compoundDrawablePadding = 12
- }else{
- savingsPlanCardView.setCardBackgroundColor(normalColor)
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement