更正基础类库,方便调试,继续调试。。。
This commit is contained in:
@@ -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 (mfTempCropPicture.exists()) {
|
||||
mfTempCropPicture.delete();
|
||||
if (_mSourceCropTempFile.exists()) {
|
||||
_mSourceCropTempFile.delete();
|
||||
}
|
||||
|
||||
try {
|
||||
mfTempCropPicture.createNewFile();
|
||||
_mSourceCropTempFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
ToastUtils.show("剪裁临时文件创建失败");
|
||||
return;
|
||||
}
|
||||
|
||||
Uri cropOutPutUri = Uri.fromFile(mfTempCropPicture);
|
||||
LogUtils.d(TAG, "mfTempCropPicture : " + mfTempCropPicture.getPath());
|
||||
Uri cropOutPutUri = Uri.fromFile(_mSourceCropTempFile);
|
||||
LogUtils.d(TAG, "mfTempCropPicture : " + _mSourceCropTempFile.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 (mfTempCropPicture.exists()) {
|
||||
cropBitmap = BitmapFactory.decodeFile(mfTempCropPicture.getPath());
|
||||
} else if (_mSourceCropTempFile.exists()) {
|
||||
LogUtils.d(TAG, String.format("_mSourceCropTempFile Exists, Path is :%s ", _mSourceCropTempFile.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.saveToBackgroundSources(preViewFilePathBackgroundView);
|
||||
bvPreviewBackground.setImageViewSource(preViewFilePathBackgroundView);
|
||||
isCommitSettings = true;
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class BackgroundView extends RelativeLayout {
|
||||
/**
|
||||
* 拷贝图片文件到背景资源目录(正式背景)
|
||||
*/
|
||||
public void saveToBackgroundSources(String srcBackgroundPath) {
|
||||
public void setImageViewSource(String srcBackgroundPath) {
|
||||
initBackgroundImagePath();
|
||||
if (backgroundSourceFilePath == null) {
|
||||
LogUtils.e(TAG, "目标路径初始化失败,无法保存背景图片");
|
||||
|
||||
Reference in New Issue
Block a user