package com.garpr.android.views;

import android.content.Context;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

import com.garpr.android.R;
import com.garpr.android.adapters.BaseAdapterView;
import com.garpr.android.models.Ranking;

public class PreviousRankView extends AppCompatImageView implements BaseAdapterView<Ranking> {

    public PreviousRankView(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }

    public PreviousRankView(final Context context, final AttributeSet attrs,
            final int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setContent(final Ranking content) {
        final Integer previousRank = content.getPreviousRank();
        final int rank = content.getRank();

        if (previousRank == null || previousRank == rank) {
            setVisibility(INVISIBLE);
            return;
        }

        final int drawableResId;

        if (previousRank > rank) {
            drawableResId = R.drawable.ic_arrow_downward_white_18dp;
        } else {
            drawableResId = R.drawable.ic_arrow_upward_white_18dp;
        }

        setImageResource(drawableResId);
        setVisibility(VISIBLE);
    }

}

@@ -59,16 +59,168 @@
 ontext;%0A
+import android.graphics.drawable.Drawable;%0Aimport android.support.v4.content.ContextCompat;%0Aimport android.support.v4.graphics.drawable.DrawableCompat;%0A
 import a
@@ -1136,16 +1136,40 @@
 leResId;
+%0A        final int tint;
 %0A%0A      
@@ -1258,32 +1258,65 @@
 ard_white_18dp;%0A
+            tint = R.color.lose;%0A
         %7D else %7B
@@ -1395,52 +1395,293 @@
     
-%7D%0A%0A        setImageResource(drawableResId
+    tint = R.color.win;%0A        %7D%0A%0A        final Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(getContext(),%0A                drawableResId));%0A        DrawableCompat.setTint(drawable, ContextCompat.getColor(getContext(), tint));%0A        setImageDrawable(drawable
 );%0A
+%0A
     

set icon color