2016-11-18 11 views
1

フルスクリーンモードで回転イメージとクロップイメージを表示できますが、サムネイル部分では何らかの形で更新されません。イメージを回転してクロップしてそのイメージを同じパスに保存します

1)ギャラリーから1つのイメージを選択し、イメージビューを含むrecyclerviewで表示します。
2)次にフルスクリーンで開いているimageviewをクリックし、回転とトリミングを行い、クロッターライブラリ で画像を保存します。3)recyclerviewで更新されませんが、画像をクリックすると、フルスクリーンモード。

私は私が以前持っているあなたの活動コールadapter.notifyDataSetChanged()

+0

これは、https://code.tutsplus.com/tutorials/capture-and-crop-animage-with-the-device-camera--mobile-11458 –

+0

あなたが回転のための別のアクティビティに行くのを助けます? –

+0

@masoudvaliはいサー。 – Rajat

答えて

0

...以下

が私のコードで私のrecyclerviewでフルスクリーンモードと同じ画像を表示したいですグライドを使って画像を表示すると、今私は

holder.imageView.setImageURI(Uri.parse( "file://" + imageList。 get(position).getImageName()));

作品が更新されました。

+0

私はこの卿をしたが、うまくいかなかった。 – Rajat

+0

あなたのリストがあまり長くない場合は、onResumeにアダプタの別のオブジェクトを作成してください –

0

のonResumeセクションで

//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(); 
    } 
} 
関連する問題