@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 onDestroy() {
   mMediaStoreCompat.destroy();
   super.onDestroy();
 }