@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == REQUEST_CODE_CAPTURE && resultCode == Activity.RESULT_OK) {
      Uri captured = mMediaStoreCompat.getCapturedPhotoUri(data, mCapturePhotoUriHolder);
      if (captured != null) {
        mCollection.add(captured);
        mMediaStoreCompat.cleanUp(mCapturePhotoUriHolder);
      }
      supportInvalidateOptionsMenu();
    } else if (requestCode == REQUEST_CODE_PREVIEW && resultCode == Activity.RESULT_OK) {
      ArrayList<Uri> checked =
          data.getParcelableArrayListExtra(ImagePreviewActivity.EXTRA_RESULT_CHECKED);
      mCollection.overwrite(checked);
      PhotoSelectionViewHelper.refreshGridView(this);
      supportInvalidateOptionsMenu();
    }
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.l_activity_select_photo);
   PhotoSelectionViewHelper.setUpActivity(this);
   mMediaStoreCompat = new MediaStoreCompat(this, HandlerUtils.getMainHandler());
   mCapturePhotoUriHolder =
       savedInstanceState != null ? savedInstanceState.getString(STATE_CAPTURE_PHOTO_URI) : "";
   mCollection.onCreate(savedInstanceState);
   mCollection.prepareSelectionSpec(
       getIntent().<SelectionSpec>getParcelableExtra(EXTRA_SELECTION_SPEC));
   mCollection.setDefaultSelection(
       getIntent().<Uri>getParcelableArrayListExtra(EXTRA_RESUME_LIST));
   mDrawer = (DrawerLayout) findViewById(R.id.l_container_drawer);
   Toolbar toolbar = (Toolbar) findViewById(R.id.l_toolbar);
   mToggle = new PhotoSelectionActivityDrawerToggle(this, mDrawer, toolbar);
   setSupportActionBar(toolbar);
   mToggle.setUpActionBar(getSupportActionBar());
   mDrawer.setDrawerListener(mToggle);
 }
 @Override
 public final void onClickSelectedView() {
   PhotoSelectionViewHelper.setSelectedGridFragment(this);
 }
 @Override
 public final void onSelect(Album album) {
   PhotoSelectionViewHelper.setPhotoGridFragment(this, mDrawer, album);
 }
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   PhotoSelectionViewHelper.refreshOptionsMenuState(this, mCollection, menu);
   return super.onPrepareOptionsMenu(menu);
 }