@Override
  public void onCreate() {
    super.onCreate();
    //        if (isDexProcess()) {
    //            return;
    //        }

    if (BuildConfig.LOG_DEBUG) {
      LeakCanary.install(this);
      //            BlockCanary.install(this, new NoteBlockCanaryContext(this)).start();
      AndroidDevMetrics.initWith(this);
    }

    initComponent();
    Utils.init(this);
    initImageLoader();
    FilePathUtils.initEnvironment(this);

    // 打点
    MobclickAgent.setDebugMode(BuildConfig.LOG_DEBUG);
    MobclickAgent.openActivityDurationTrack(true);
    MobclickAgent.updateOnlineConfig(this);
    MobclickAgent.setCatchUncaughtExceptions(!BuildConfig.LOG_DEBUG);

    //        CrashHandler.getInstance().init(getApplicationContext());

    YLog.setDEBUG(BuildConfig.LOG_DEBUG);
  }
 @Override
 public boolean checkStorageEnough() {
   if (!FilePathUtils.isSDCardStoredEnough()) {
     mAlbumView.showToast(mContext.getResources().getString(R.string.no_space));
     return false;
   }
   return true;
 }
 @Override
 public void saveSmallImage(final Bitmap thumbNail) {
   mRxPhotoNote
       .findByCategoryId(mCategoryId, mComparator)
       .map(photoNoteList -> photoNoteList.get(mPosition))
       .doOnSubscribe(() -> mZoomView.showProgressBar())
       .subscribeOn(AndroidSchedulers.mainThread())
       .subscribe(
           photoNote -> {
             FilePathUtils.saveSmallPhotoFromSDK(photoNote.getPhotoName(), thumbNail);
             photoNote.setPaletteColor(
                 UiHelper.getPaletteColor(
                     ImageLoaderManager.loadImageSync(photoNote.getBigPhotoPathWithFile())));
             mRxPhotoNote
                 .updatePhotoNote(photoNote)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(
                     photoNoteList -> {
                       sendBroadcast();
                       mZoomView.hideProgressBar();
                       mIsChanged = true;
                     });
           });
 }
 @Override
 public void savePhotoFromSystemCamera() {
   PhotoNote photoNote =
       new PhotoNote(
           System.currentTimeMillis() + ".jpg",
           System.currentTimeMillis(),
           System.currentTimeMillis(),
           "",
           "",
           System.currentTimeMillis(),
           System.currentTimeMillis(),
           mCategoryId);
   mRxPhotoNote
       .savePhotoNote(photoNote)
       .map(
           photoNote1 -> {
             // 复制大图
             try {
               FilePathUtils.copyFile(
                   FilePathUtils.getTempFilePath(), photoNote1.getBigPhotoPathWithoutFile());
               // 保存小图
               FilePathUtils.saveSmallPhotoFromBigPhoto(photoNote);
             } catch (FileNotFoundException e) {
               e.printStackTrace();
             } catch (IOException e) {
               e.printStackTrace();
             }
             photoNote1.setPaletteColor(
                 UiHelper.getPaletteColor(
                     ImageLoaderManager.loadImageSync(photoNote.getBigPhotoPathWithFile())));
             mRxPhotoNote.updatePhotoNote(photoNote1).subscribe();
             return photoNote1;
           })
       .doOnSubscribe(
           new Action0() { // todo // FIXME: 15/11/29 lambda
             @Override
             public void call() {
               mAlbumView.showProgressBar();
             }
           })
       .subscribeOn(AndroidSchedulers.mainThread())
       .subscribe(
           photoNote2 -> {
             EventBus.getDefault().post(new PhotoNoteCreateEvent());
             // 因为是最新时间,即“图片创建事件”、“图片修改时间”、“笔记创建时间”、“笔记修改时间”,所以要么在最前面,要么在最后面//// TODO: 15/11/20
             // 还是因时间来判断插入到哪里,所以要计算
             mRxPhotoNote
                 .findByCategoryId(mCategoryId, mAlbumSortKind)
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(
                     photoNoteList -> {
                       mAlbumView.updateData(photoNoteList);
                       switch (mAlbumSortKind) {
                         case ComparatorFactory.FACTORY_CREATE_CLOSE:
                         case ComparatorFactory.FACTORY_EDITED_CLOSE:
                           mAlbumView.notifyItemInserted(photoNoteList.size() - 1);
                           break;
                         case ComparatorFactory.FACTORY_CREATE_FAR:
                         case ComparatorFactory.FACTORY_EDITED_FAR:
                           mAlbumView.notifyItemInserted(0);
                           break;
                       }
                       mAlbumView.hideProgressBar();
                     });
           });
 }