Пример #1
0
 @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;
                     });
           });
 }
Пример #2
0
 @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();
                     });
           });
 }