@@ -53,16 +53,18 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
private File mfPictureDir ; // 拍照与剪裁临时文件夹
private File mfTakePhoto ; // 拍照文件
private File mfRecivedPicture ; // 接收的图片文件
private File mfTempCropPicture ; // 剪裁临时文件
// 背景视图预览图片的文件名
private String preViewFilePathBackgroundView = " " ;
BackgroundView bvPreviewBackground ;
boolean isCommitSettings = false ;
// 静态变量
//public static String _mszRecivedCropPicture = "RecivedCrop.jpg";
// 源文件的剪裁图片保存名称
// 源文件的临时剪裁图片保存名称
private static String _mSourceCropTempFileName = " SourceCropTemp.jpg " ;
// 源文件的临时剪裁图片保存文件对象
private static File _mSourceCropTempFile ;
// 源文件的剪裁图片保存名称
private static String _mSourceCroppedFileName = " SourceCropped.jpg " ;
// 源文件的剪裁图片保存文件对象
private static File _mSourceCroppedFile ;
@@ -102,9 +104,10 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
// 初始化文件对象
mfTakePhoto = new File ( mfPictureDir , " TakePhoto.jpg " ) ;
mfTempCropPicture = new File ( mfPictureDir, " TempCrop.jpg" ) ;
// mfTempCropPicture = new File( mfPictureDir, " TempCrop.jpg") ;
mfRecivedPicture = getRecivedPictureFile ( ) ;
_mSourceCropTempFile = new File ( mfBackgroundDir , _mSourceCropTempFileName ) ;
_mSourceCroppedFile = new File ( mfBackgroundDir , _mSourceCroppedFileName ) ;
_mSourceCroppedFilePath = _mSourceCroppedFile . getAbsolutePath ( ) . toString ( ) ;
LogUtils . d ( TAG , String . format ( " _mSourceCroppedFilePath : %s " , _mSourceCroppedFilePath ) ) ;
@@ -359,19 +362,20 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
Uri uri = UriUtil . getUriForFile ( this , mfRecivedPicture ) ;
LogUtils . d ( TAG , " uri : " + uri . toString ( ) ) ;
if ( mfTempCropPictur e. exists ( ) ) {
mfTempCropPictur e. delete ( ) ;
if ( _mSourceCropTempFil e. exists ( ) ) {
_mSourceCropTempFil e. delete ( ) ;
}
try {
mfTempCropPictur e. createNewFile ( ) ;
_mSourceCropTempFil e. createNewFile ( ) ;
} catch ( IOException e ) {
LogUtils . d ( TAG , e , Thread . currentThread ( ) . getStackTrace ( ) ) ;
ToastUtils . show ( " 剪裁临时文件创建失败 " ) ;
return ;
}
Uri cropOutPutUri = Uri . fromFile ( mfTempCropPictur e) ;
LogUtils . d ( TAG , " mfTempCropPicture : " + mfTempCropPictur e. getPath ( ) ) ;
Uri cropOutPutUri = Uri . fromFile ( _mSourceCropTempFil e) ;
LogUtils . d ( TAG , " mfTempCropPicture : " + _mSourceCropTempFil e. getPath ( ) ) ;
Intent intent = new Intent ( " com.android.camera.action.CROP " ) ;
intent . setDataAndType ( uri , " image/ " + _mszCommonFileType ) ;
@@ -547,8 +551,9 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
// 方案1: 通过Intent获取剪裁后的Bitmap
if ( data ! = null & & data . hasExtra ( " data " ) ) {
cropBitmap = data . getParcelableExtra ( " data " ) ;
} else if ( mfTempCropPictur e. exists ( ) ) {
cropBitmap = BitmapFactory . decodeFile ( mfTempCropPictur e. getPath ( ) ) ;
} else if ( _mSourceCropTempFil e. exists ( ) ) {
LogUtils . d ( TAG , String . format ( " _mSourceCropTempFile Exists, Path is : %s " , _mSourceCropTempFil e. getPath ( ) ) ) ;
cropBitmap = BitmapFactory . decodeFile ( _mSourceCropTempFile . getPath ( ) ) ;
} else {
ToastUtils . show ( " 剪裁文件不存在 " ) ;
return ;
@@ -696,7 +701,7 @@ public class BackgroundPictureActivity extends WinBoLLActivity implements Backgr
@Override
public void onYes ( ) {
bvPreviewBackground . saveToBackground Sources ( preViewFilePathBackgroundView ) ;
bvPreviewBackground . setImageView Source ( preViewFilePathBackgroundView ) ;
isCommitSettings = true ;
finish ( ) ;
}