package com.liuguangqiang.idaily.ui.act;

import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import com.liuguangqiang.idaily.R;
import com.liuguangqiang.idaily.databinding.ActivityStoryBinding;
import com.liuguangqiang.idaily.domain.entity.Story;
import com.liuguangqiang.idaily.ui.viewmodel.StoryViewModel;

import butterknife.Bind;
import butterknife.ButterKnife;

public class StoryActivity extends BaseActivity {

    public static final String ARG_STORY = "ARG_STORY";

    private Story mStory;

    @Bind(R.id.collapsing_toolbar)
    public CollapsingToolbarLayout collapsingToolbar;

    private ActivityStoryBinding binding;
    private StoryViewModel viewModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initViews();
    }

    @Override
    public void onCreateBinding() {
        binding = DataBindingUtil.setContentView(this, R.layout.activity_story);
        viewModel = new StoryViewModel();
        binding.setStoryViewModel(viewModel);
        ButterKnife.bind(this);
        viewModel.pushArguments(getIntent().getExtras());
    }

    private void initViews() {
        Toolbar toolbar = findById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

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

    private void getExtraData() {
        Bundle bundle = getIntent().getExtras();
        if (bundle != null && bundle.containsKey(ARG_STORY)) {
            mStory = bundle.getParcelable(ARG_STORY);
            if (mStory != null) {
                collapsingToolbar.setExpandedTitleColor(Color.WHITE);
                collapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);
                collapsingToolbar.setExpandedTitleTextAppearance(R.style.CollapsingToolbarTitle);
                viewModel.getStory(mStory.getId());
            }
        }
    }

}

@@ -83,39 +83,8 @@
 il;%0A
-import android.graphics.Color;%0A
 impo
@@ -105,16 +105,16 @@
 Bundle;%0A
+
 import a
@@ -345,61 +345,8 @@
 ng;%0A
-import com.liuguangqiang.idaily.domain.entity.Story;%0A
 impo
@@ -573,35 +573,8 @@
 %22;%0A%0A
-    private Story mStory;%0A%0A
     
@@ -1589,32 +1589,32 @@
 true;%0A        %7D%0A
+
         return s
@@ -1658,566 +1658,6 @@
  %7D%0A%0A
-    private void getExtraData() %7B%0A        Bundle bundle = getIntent().getExtras();%0A        if (bundle != null && bundle.containsKey(ARG_STORY)) %7B%0A            mStory = bundle.getParcelable(ARG_STORY);%0A            if (mStory != null) %7B%0A                collapsingToolbar.setExpandedTitleColor(Color.WHITE);%0A                collapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);%0A                collapsingToolbar.setExpandedTitleTextAppearance(R.style.CollapsingToolbarTitle);%0A                viewModel.getStory(mStory.getId());%0A            %7D%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Remove unused method.