Beispiel #1
0
    @Override
    public synchronized void saveRequest() {
      if (mData == null) {
        Log.w(TAG, "[saveRequest]mData is null,return!");
        return;
      }
      int orientation = Exif.getOrientation(mData);
      // M: ConShots
      mGroupId = Exif.getGroupId(mData);
      mGroupIndex = Exif.getGroupIndex(mData);
      mFocusValueHigh = Exif.getFocusValueHigh(mData);
      mFocusValueLow = Exif.getFocusValueLow(mData);
      mOrientation = orientation;
      mDataSize = mData.length;

      if (null != mFileName) {
        mTitle = mFileName.substring(0, mFileName.indexOf('.'));
      } else {
        mTitle = createName(mFileType, mDateTaken, mGroupIndex);
        mFileName = Storage.generateFileName(mTitle, mTempPictureType);
        Log.i(TAG, "[saveRequest]PhotoOperator,mFileName = " + mFileName);
      }
      mFilePath = Storage.generateFilepath(mFileName);
      mTempFilePath = mFilePath + TEMP_SUFFIX;
      saveImageToSDCard(mTempFilePath, mFilePath, mData);
      // camera decouple
      mMimeType = Storage.generateMimetype(mTitle, mTempPictureType);
      checkDataProperty();
      saveImageToDatabase(this);
    }
  @Override
  public View getView(
      Context context,
      View recycled,
      int thumbWidth,
      int thumbHeight,
      int placeholderResourcedId,
      LocalDataAdapter adapter,
      boolean isInProgress) {
    final ImageView imageView;
    if (recycled != null) {
      imageView = (ImageView) recycled;
    } else {
      imageView = new ImageView(context);
      imageView.setTag(R.id.mediadata_tag_viewtype, getItemViewType().ordinal());
    }

    byte[] jpegData = Storage.getJpegForSession(mUri);
    int currentVersion = Storage.getJpegVersionForSession(mUri);
    Glide.with(context)
        .loadFromImage(jpegData, mUri.toString() + currentVersion)
        .skipDiskCache(true)
        .fitCenter()
        .into(imageView);

    imageView.setContentDescription(
        context.getResources().getString(R.string.media_processing_content_description));
    return imageView;
  }
Beispiel #3
0
 @Override
 public void prepareRequest() {
   Log.i(TAG, "[prepareRequest]PanoOperator,mFileName = " + mFileName);
   mFileType = Storage.FILE_TYPE_PANO;
   mDateTaken = System.currentTimeMillis();
   Location loc = mContext.getLocationManager().getCurrentLocation();
   if (loc != null) {
     mLocation = new Location(loc);
   }
   mTitle = createName(mFileType, mDateTaken, 0);
   mFileName = Storage.generateFileName(mTitle, mTempPictureType);
   mFilePath = Storage.generateFilepath(mFileName);
   mTempFilePath = mFilePath + TEMP_SUFFIX;
 }
Beispiel #4
0
 @Override
 public void prepareRequest() {
   mFileType = Storage.FILE_TYPE_VIDEO;
   mDateTaken = System.currentTimeMillis();
   mTitle = createName(mFileType, mDateTaken, 0);
   mFileName = mTitle + convertOutputFormatToFileExt(mTempOutputFileFormat);
   mMimeType = convertOutputFormatToMimeType(mTempOutputFileFormat);
   mFilePath = Storage.generateFilepath(mFileName);
 }
Beispiel #5
0
    @Override
    public void saveRequest() {
      // title, file path, temp file path is ready
      FileOutputStream out = null;
      try {
        // Write to a temporary file and rename it to the final name.
        // This
        // avoids other apps reading incomplete data.
        out = new FileOutputStream(mTempFilePath);
        out.write(mData);
        out.close();
        new File(mTempFilePath).renameTo(new File(mFilePath));
      } catch (IOException e) {
        Log.e(TAG, "[saveRequest]PanoOperator,Failed to write image", e);
      } finally {
        if (out != null) {
          try {
            out.close();
          } catch (IOException e) {
            Log.e(TAG, "[saveRequest]PanoOperator,exception:", e);
          }
        }
      }
      mDataSize = new File(mFilePath).length();
      try {
        ExifInterface exif = new ExifInterface(mFilePath);
        int orientation = Util.getExifOrientation(exif);
        int width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0);
        int height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0);
        mWidth = width;
        mHeight = height;
        mOrientation = orientation;
      } catch (IOException ex) {
        Log.e(TAG, "[saveRequest]PanoOperator,cannot read exif:", ex);
      }
      if (null == mFileName) {
        mTitle = createName(mFileType, mDateTaken, mGroupIndex);
        mFileName = Storage.generateFileName(mTitle, mTempPictureType);
        Log.i(TAG, "[saveRequest]PhotoOperator,mFileName = " + mFileName);
      }
      mMimeType = Storage.generateMimetype(mTitle, mTempPictureType);

      saveImageToDatabase(this);
    }
Beispiel #6
0
  /** Updates the image values in MediaStore. */
  private static Uri updateImage(
      Uri imageUri,
      ContentResolver resolver,
      String title,
      long date,
      Location location,
      int orientation,
      int jpegLength,
      String path,
      int width,
      int height,
      String mimeType) {

    ContentValues values =
        getContentValuesForData(
            title, date, location, orientation, jpegLength, path, width, height, mimeType);

    Uri resultUri = imageUri;
    if (Storage.isSessionUri(imageUri)) {
      // If this is a session uri, then we need to add the image
      resultUri =
          addImageToMediaStore(
              resolver,
              title,
              date,
              location,
              orientation,
              jpegLength,
              path,
              width,
              height,
              mimeType);
      sSessionsToContentUris.put(imageUri, resultUri);
      sContentUrisToSessions.put(resultUri, imageUri);
    } else {
      // Update the MediaStore
      resolver.update(imageUri, values, null, null);
    }
    return resultUri;
  }
 private void refreshSize(Uri uri) {
   Point size = Storage.getSizeForSession(uri);
   mWidth = size.x;
   mHeight = size.y;
 }