package is.uncommon.droidcon2015;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import is.uncommon.droidcon2015.models.PrimaryContent;
import is.uncommon.droidcon2015.utils.Extras;
import is.uncommon.droidcon2015.utils.HtmlUtils;

public class SectionDetailActivity extends AppCompatActivity {

    private final static String TAG = "SectionDetailActivity";

    @Bind(R.id.toolbar) Toolbar mToolbar;
    @Bind(R.id.iv_header_image) ImageView mHeaderImageView;
    @Bind(R.id.tv_card_summary) TextView mSummaryTextView;

    public static void startActivity(Activity activity, PrimaryContent content, ImageView imageView) {
        Intent intent = new Intent(activity, SectionDetailActivity.class);
        intent.putExtra(Extras.CONTENT, content);
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imageView, "header_image");
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_section_detail);
        ButterKnife.bind(this);

        PrimaryContent content = getIntent().getParcelableExtra(Extras.CONTENT);
        setSupportActionBar(mToolbar);
        //noinspection ConstantConditions
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        CollapsingToolbarLayout ct = ButterKnife.findById(this, R.id.ct_header);
        ct.setContentScrimColor(ContextCompat.getColor(this, content.color));
        ct.setStatusBarScrimColor(ContextCompat.getColor(this, content.color));

        mHeaderImageView.setImageResource(content.image);
        mSummaryTextView.setText(HtmlUtils.getHtml(content.summary, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
                getResources().getDisplayMetrics()), Color.parseColor("#c3c3c3")));
        getSupportActionBar().setTitle(content.sectionName);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                onBackPressed();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        supportFinishAfterTransition();
    }
}

@@ -119,16 +119,89 @@
 .Color;%0A
+import android.graphics.ColorFilter;%0Aimport android.graphics.PorterDuff;%0A
 import a
@@ -2312,24 +2312,115 @@
 ent.image);%0A
+        mHeaderImageView.setColorFilter(content.color, PorterDuff.Mode.SRC_ATOP);%0A        %0A
         mSum

add color filter on sectiondetailpage header image