2016-11-18 48 views
1

我能够在全屏模式下看到旋转和弯曲的图像,但不知何故它不会在缩略图部分更新。旋转和裁剪图像,然后将该图像保存在相同的路径

1)我从图库中选择一个图像,并显示在包含imageview的recyclerview中。
2)然后我点击的ImageView这在全屏打开,做旋转和剪切然后保存栽跟头库 3的形象)然后它不会在recyclerview更新,但是当我的形象上点击则显示croped和旋转图像在全屏模式下。

我想在我的recyclerview显示图像和全屏模式

下面是我的代码...

//override method for cropper library 
@Override 
public void onCropImageComplete(CropImageView view,CropImageView.CropResult result) { 

    handleCropResult(result, view); 
} 

     private void handleCropResult(CropImageView.CropResult result, CropImageView view) 
    { 
    if (result.getError() == null) { 
     view.setImageBitmap(view.getCroppedImage()); 
     saveImageInGallery(view.getCroppedImage(),   String.valueOf(view.getTag())); 
     Log.i("UriResult", String.valueOf(result.getUri())); 
    } else { 
     Log.e("AIC", "Failed to crop image", result.getError()); 
     Toast.makeText(_activity, "Image crop failed: " + result.getError().getMessage(), Toast.LENGTH_LONG).show(); 
    } 
} 



    private void saveImageInGallery(Bitmap bitmap, String imagePath) { 
    File file = new File(imagePath); 
    if (file.exists()) { 
     if (file.delete()) { 
      Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); 
      Uri contentUri = Uri.fromFile(file); 
      mediaScanIntent.setData(contentUri); 
      _activity.sendBroadcast(mediaScanIntent); 
     } 
    } 

    try { 
     File mNewFile = new File(imagePath); 
     FileOutputStream out = new FileOutputStream(mNewFile); 
     bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); 
     bitmap.recycle(); 


     Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); 
     Uri contentUri = Uri.fromFile(mNewFile); 
     mediaScanIntent.setData(contentUri); 
     _activity.sendBroadcast(mediaScanIntent); 

     out.flush(); 
     out.close(); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 
+0

这可能会帮助你https://code.tutsplus.com/tutorials/capture-and-crop-an-image-with-the-device-camera--mobile-11458 –

+0

你去另一个活动旋转? –

+0

@masoudvali是的先生。 – Rajat

回答

0

在活动通话的onResume部分adapter.notifyDataSetChanged()

+0

我已经做了这个先生,但它没有奏效。 – Rajat

+0

如果你的列表不太长,只需在onResume中创建另一个适配器对象 –

0

我以前显示的图像与滑行和现在我与

holder.imageView.setImageURI(Uri.parse(替换为“文件://” +图像列表。得到(位置).getImageName()));

现在的作品。