content: package com.cjj.mousepaint;
  
  import android.app.ActionBar;
  import android.os.Build;
  import android.support.design.widget.NavigationView;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.GridLayoutManager;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.StaggeredGridLayoutManager;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuItem;
  
  
  import java.util.ArrayList;
  import java.util.Arrays;
  
  import butterknife.Bind;
  import butterknife.ButterKnife;
  
  public class MainActivity extends AppCompatActivity {
  
      @Bind(R.id.recycler_view)RecyclerView recyclerView;
      @Bind(R.id.toolbar)Toolbar toolbar;
      @Bind(R.id.drawer_layout)DrawerLayout mDrawerLayout;
      @Bind(R.id.nav_view)  NavigationView navigationView;
      private RecyclerView.Adapter mAdapter;
      private ArrayList<String> mDataSet;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          ButterKnife.bind(this);
  
          setSupportActionBar(toolbar);
  
          final android.support.v7.app.ActionBar ab = getSupportActionBar();
          ab.setHomeAsUpIndicator(R.drawable.ic_menu);
          ab.setDisplayHomeAsUpEnabled(true);
  
          if (navigationView != null) {
              setupDrawerContent(navigationView);
          }
  
  //        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  //            ActionBar actionBar = getActionBar();
  //            if (actionBar != null) {
  //                actionBar.setTitle("RecyclerView");
  //            }
  //        }
          // Layout Managers:
          final StaggeredGridLayoutManager layoutManager =
                  new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
          recyclerView.setLayoutManager(layoutManager);
  
          // Item Decorator:
  //        recyclerView.addItemDecoration(new DividerItemDecoration(getResources().getDrawable(R.drawable.divider)));
  //        recyclerView.setItemAnimator(new FadeInLeftAnimator());
  
          // Adapter:
          String[] adapterData = new String[]{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
          mDataSet = new ArrayList<String>(Arrays.asList(adapterData));
  //        mAdapter = new RecyclerViewAdapter(MainActivity.this, mDataSet);
  //        ((RecyclerViewAdapter) mAdapter).setMode(Attributes.Mode.Single);
          recyclerView.setAdapter(mAdapter);
  
          /* Listeners */
          recyclerView.setOnScrollListener(onScrollListener);
      }
  
      @Override
      protected void onDestroy() {
          super.onDestroy();
          ButterKnife.unbind(this);
      }
  
      private void setupDrawerContent(NavigationView navigationView) {
          navigationView.setNavigationItemSelectedListener(
                  new NavigationView.OnNavigationItemSelectedListener() {
                      @Override
                      public boolean onNavigationItemSelected(MenuItem menuItem) {
                          menuItem.setChecked(true);
                          mDrawerLayout.closeDrawers();
                          return true;
                      }
                  });
      }
  
  
  
  
      /**
       * Substitute for our onScrollListener for RecyclerView
       */
      RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
              super.onScrollStateChanged(recyclerView, newState);
              Log.e("ListView", "onScrollStateChanged");
          }
  
          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
              super.onScrolled(recyclerView, dx, dy);
              // Could hide open views here if you wanted. //
          }
      };
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  //
  //        //noinspection SimplifiableIfStatement
  //        if (id == R.id.action_settings) {
  //            return true;
  //        }
  
          switch (item.getItemId()) {
              case android.R.id.home:
                  mDrawerLayout.openDrawer(GravityCompat.START);
                  return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  }
  