|
|
@@ -20,6 +20,7 @@ import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.finalteam.rxgalleryfinal.utils.CameraUtil;
|
|
|
import me.iwf.photopicker.PhotoPicker;
|
|
|
|
|
|
/**
|
|
|
@@ -40,11 +41,12 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
public static final int DEFAULT_MAX_COUNT = 7;//上传任务截图的最大个数
|
|
|
|
|
|
public void showChooseDialog() {
|
|
|
- showChooseDialog(true, true,1);
|
|
|
+ showChooseDialog(true, true, 1);
|
|
|
}
|
|
|
|
|
|
public void showChooseDialog(boolean isCrop, boolean isUpload, int photoCount) {
|
|
|
- photoCount = Math.max(1,photoCount);
|
|
|
+ if (!CameraUtil.checkCameraPermission(this)) return;
|
|
|
+ photoCount = Math.max(1, photoCount);
|
|
|
this.isUpload = isUpload;
|
|
|
this.isCrop = isCrop && photoCount == 1;
|
|
|
this.photoCount = photoCount;
|
|
|
@@ -58,10 +60,12 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
.setPreviewEnabled(true)
|
|
|
.start(this, PhotoPicker.REQUEST_CODE);
|
|
|
}
|
|
|
+
|
|
|
public void showChooseDialog(boolean isCrop, boolean isUpload, int photoCount, File dir) {
|
|
|
+ if (!CameraUtil.checkCameraPermission(this)) return;
|
|
|
LogUtil.println("showChooseDialog", dir.getAbsolutePath(), dir.exists());
|
|
|
File[] files = dir.listFiles();
|
|
|
- if(dir.exists() && files != null && files.length > 0) {
|
|
|
+ if (dir.exists() && files != null && files.length > 0) {
|
|
|
photoCount = Math.max(1, photoCount);
|
|
|
this.isUpload = isUpload;
|
|
|
this.isCrop = isCrop && photoCount == 1;
|
|
|
@@ -85,8 +89,10 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
G.showToast("暂无截图(若您已经截图,请查看是否开启查看应用使用情况等权限!)");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public void showChooseListDialog(boolean isCrop, boolean isUpload, int photoCount, ArrayList<String> imageUriList) {
|
|
|
- if(!ListUtil.isEmpty(imageUriList)) {
|
|
|
+ if (!CameraUtil.checkCameraPermission(this)) return;
|
|
|
+ if (!ListUtil.isEmpty(imageUriList)) {
|
|
|
photoCount = Math.max(1, photoCount);
|
|
|
this.isUpload = isUpload;
|
|
|
this.isCrop = isCrop && photoCount == 1;
|
|
|
@@ -105,8 +111,10 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
G.showToast("暂无截图(若您已经截图,请查看是否开启查看应用使用情况等权限!)");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public void showChooseDialog(boolean isCrop, boolean isUpload, int photoCount, ArrayList<String> imageUriList) {
|
|
|
- photoCount = Math.max(1,photoCount);
|
|
|
+ if (showCamera && !CameraUtil.checkCameraPermission(this)) return;
|
|
|
+ photoCount = Math.max(1, photoCount);
|
|
|
this.isUpload = isUpload;
|
|
|
this.isCrop = isCrop && photoCount == 1;
|
|
|
this.photoCount = photoCount;
|
|
|
@@ -123,6 +131,7 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
.setPicker(imageUriList)
|
|
|
.start(this, PhotoPicker.REQUEST_CODE);
|
|
|
}
|
|
|
+
|
|
|
private boolean showCamera = false;
|
|
|
|
|
|
public void setShowCamera(boolean showCamera) {
|
|
|
@@ -151,34 +160,34 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
onNotGetImage("没有数据");
|
|
|
} else if (requestCode == UCrop.REQUEST_CROP) {//裁剪
|
|
|
Uri resultUri;
|
|
|
- if (data != null && (resultUri = UCrop.getOutput(data))!=null) {
|
|
|
+ if (data != null && (resultUri = UCrop.getOutput(data)) != null) {
|
|
|
String cropPath;
|
|
|
- if(!TextUtils.isEmpty(cropPath = resultUri.getPath())){
|
|
|
+ if (!TextUtils.isEmpty(cropPath = resultUri.getPath())) {
|
|
|
path = cropPath;
|
|
|
notCrop();
|
|
|
}
|
|
|
|
|
|
- } else if(!TextUtils.isEmpty(path)){
|
|
|
- notCrop();
|
|
|
+ } else if (!TextUtils.isEmpty(path)) {
|
|
|
+ notCrop();
|
|
|
}
|
|
|
}
|
|
|
} else if (resultCode == UCrop.RESULT_ERROR) {//裁剪出错
|
|
|
- if(!TextUtils.isEmpty(path))
|
|
|
+ if (!TextUtils.isEmpty(path))
|
|
|
notCrop();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void notCrop() {
|
|
|
- if(photoCount == 1) {
|
|
|
+ if (photoCount == 1) {
|
|
|
onGetImage(path);
|
|
|
if (isUpload) {
|
|
|
AbsChooseImageActivity.this.dialogShowLoading = DialogProgress.showDialog(AbsChooseImageActivity.this);
|
|
|
UpFileUtils.upImage(new File(path), AbsChooseImageActivity.this);
|
|
|
}
|
|
|
- } else if(photos != null && !photos.isEmpty()){
|
|
|
+ } else if (photos != null && !photos.isEmpty()) {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (int i = 0; i < photos.size(); i++) {
|
|
|
- if(i != 0)
|
|
|
+ if (i != 0)
|
|
|
sb.append(";");
|
|
|
sb.append(photos.get(i));
|
|
|
}
|
|
|
@@ -200,18 +209,19 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
|
|
|
/**
|
|
|
* 上传图片前的回调
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- protected ICallBack<Boolean> getCallBack(){
|
|
|
+ protected ICallBack<Boolean> getCallBack() {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void Success(String msg, int index) {
|
|
|
- if(index == -1 && !urls.isEmpty()) {//多图
|
|
|
+ if (index == -1 && !urls.isEmpty()) {//多图
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (int i = 0; i < urls.size(); i++) {
|
|
|
- if(i != 0)
|
|
|
+ if (i != 0)
|
|
|
sb.append(";");
|
|
|
sb.append(urls.get(i));
|
|
|
}
|
|
|
@@ -223,14 +233,15 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
updateError("失败");
|
|
|
return;
|
|
|
}
|
|
|
- if(photoCount == 1) {
|
|
|
+ if (photoCount == 1) {
|
|
|
onSetNetImageUrl(data);
|
|
|
} else {
|
|
|
urls.add(data);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- protected String parseMsg(String msg){
|
|
|
+
|
|
|
+ protected String parseMsg(String msg) {
|
|
|
String json;
|
|
|
if (TextUtils.isEmpty(msg)) {
|
|
|
return null;
|
|
|
@@ -255,6 +266,7 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
protected void setLoaddingText(String msg) {
|
|
|
dialogShowLoading.getTextView().setText(msg);
|
|
|
}
|
|
|
+
|
|
|
protected void dismissLoaddingDialog() {
|
|
|
dialogShowLoading.getAlertDialog().dismiss();
|
|
|
}
|
|
|
@@ -269,14 +281,15 @@ public abstract class AbsChooseImageActivity extends BaseActivity implements UpF
|
|
|
public void Progress(String progress, int index) {
|
|
|
dialogShowLoading.getTextView().setText(progress);
|
|
|
dialogShowLoading.getTextView().append("%");
|
|
|
- if(index != -1 && photos != null && photos.size() != 1)
|
|
|
- dialogShowLoading.getTextView().append(" "+(index+1)+"/"+photos.size());
|
|
|
+ if (index != -1 && photos != null && photos.size() != 1)
|
|
|
+ dialogShowLoading.getTextView().append(" " + (index + 1) + "/" + photos.size());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void Failure(String err) {
|
|
|
onNotGetImage(err);
|
|
|
}
|
|
|
+
|
|
|
//流程:获取图片、裁剪图片、上传图片、设置或者更新图片
|
|
|
protected abstract void onNotGetImage(String msg);//失败后回调
|
|
|
|