Пример #1
0
  public void processImageCaptureResult(int resultCode, Intent intent) {
    if (resultCode == Activity.RESULT_OK) {
      // Get reference to receipt, in case the small chance that the
      // active receipt changes while we're doing this work
      final Receipt ourReceipt = mReceipt;

      // TODO handle various problem situations in ways other than just
      // 'die'

      File workFile = getWorkPhotoFile();
      if (!workFile.isFile()) {
        Uri uri = Uri.fromFile(workFile);
        die("no work file found: " + workFile + ", uri=" + uri);
      }

      BitmapUtil.orientAndScaleBitmap(workFile, IPhotoStore.FULLSIZE_HEIGHT, true);

      try {
        FileArguments args = new FileArguments();
        args.setData(Files.readBinaryFile(workFile));
        args.setFileId(ourReceipt.getPhotoId());

        final FileArguments arg = args;

        // We have to wait until the photo has been processed, and a
        // photoId assigned; then store this assignment in the receipt,
        // and push new version to any listeners
        args.setCallback(
            new Runnable() {
              public void run() {
                ourReceipt.setPhotoId(arg.getFileIdString());
                getRBuddyActivity().receiptFile().setModified(ourReceipt);
                // TODO: need better pattern to keep track of changes to
                // receipts, maybe do it silently
                getRBuddyActivity()
                    .photoStore()
                    .pushPhoto(ourReceipt.getId(), ourReceipt.getPhotoId());
              }
            });
        IPhotoStore ps = getRBuddyActivity().photoStore();
        ps.storePhoto(mReceipt.getId(), args);
      } catch (IOException e) {
        // TODO display popup message to user, and don't update
        // receipt's
        // photo id
        die(e);
      }
    }
    // Whether or not the user selected a new photo, pop the photo fragment
    ((MyActivity) getActivity()).getFragmentOrganizer().popFragment(this.getName(), true);
  }
Пример #2
0
 private File getWorkPhotoFile() {
   return BitmapUtil.constructExternalImageFile("work");
 }