Permalink
Browse files

针对未编辑图片场景做处理 增加Intent返回变量 IMAGE_IS_EDIT 标示是否编辑了图片

  • Loading branch information...
1 parent 3f03bf3 commit 715920ba54f8224dc8443a22f923129f4acff65a @siwangqishiq committed Oct 23, 2016
@@ -14,6 +14,7 @@
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.DisplayMetrics;
+import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
@@ -138,9 +139,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
private void handleEditorImage(Intent data) {
- String newFilePath = data.getStringExtra("save_file_path");
+ String newFilePath = data.getStringExtra(EditImageActivity.SAVE_FILE_PATH);
+ boolean isImageEdit = data.getBooleanExtra(EditImageActivity.IMAGE_IS_EDIT, false);
Toast.makeText(this, getString(R.string.save_path, newFilePath), Toast.LENGTH_LONG).show();
//System.out.println("newFilePath---->" + newFilePath);
+ Log.d("image is edit", isImageEdit + "");
LoadImageTask loadTask = new LoadImageTask();
loadTask.execute(newFilePath);
}
@@ -22,6 +22,7 @@
import com.xinlan.imageeditlibrary.editimage.fragment.MainMenuFragment;
import com.xinlan.imageeditlibrary.editimage.fragment.RotateFragment;
import com.xinlan.imageeditlibrary.editimage.fragment.StirckerFragment;
+import com.xinlan.imageeditlibrary.editimage.utils.FileUtil;
import com.xinlan.imageeditlibrary.editimage.view.CropImageView;
import com.xinlan.imageeditlibrary.editimage.view.CustomViewPager;
import com.xinlan.imageeditlibrary.editimage.view.RotateImageView;
@@ -41,6 +42,9 @@
public class EditImageActivity extends BaseActivity {
public static final String FILE_PATH = "file_path";
public static final String EXTRA_OUTPUT = "extra_output";
+ public static final String SAVE_FILE_PATH = "save_file_path";
+
+ public static final String IMAGE_IS_EDIT = "image_is_edit";
public static final int MODE_NONE = 0;
public static final int MODE_STICKERS = 1;// 贴图模式
@@ -205,6 +209,7 @@ public void loadImage(String filepath) {
private final class LoadImageTask extends AsyncTask<String, Void, Bitmap> {
@Override
protected Bitmap doInBackground(String... params) {
+
return BitmapUtils.getSampledBitmap(params[0], imageWidth,
imageHeight);
}
@@ -297,8 +302,15 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Intent returnIntent = new Intent();
- returnIntent.putExtra("save_file_path", saveFilePath);
- mContext.setResult(RESULT_OK, returnIntent);
+ if(FileUtil.checkFileExist(saveFilePath)){//图片被编辑过
+ returnIntent.putExtra(SAVE_FILE_PATH, saveFilePath);
+ returnIntent.putExtra(IMAGE_IS_EDIT, true);
+ mContext.setResult(RESULT_OK, returnIntent);
+ }else{
+ returnIntent.putExtra(SAVE_FILE_PATH, filePath);
+ returnIntent.putExtra(IMAGE_IS_EDIT, false);
+ mContext.setResult(RESULT_OK, returnIntent);
+ }//end if
mContext.finish();
}
}// end inner class
@@ -0,0 +1,18 @@
+package com.xinlan.imageeditlibrary.editimage.utils;
+
+import android.text.TextUtils;
+
+import java.io.File;
+
+/**
+ * Created by panyi on 16/10/23.
+ */
+public class FileUtil {
+ public static boolean checkFileExist(final String path){
+ if(TextUtils.isEmpty(path))
+ return false;
+
+ File file = new File(path);
+ return file.exists();
+ }
+}//end class

0 comments on commit 715920b

Please sign in to comment.