|
@@ -4,6 +4,7 @@ import android.content.Context;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import com.framework.mvvm.mv.AdmViewModel;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.sybotan.android.demo.retrofit.Constant;
|
|
|
import com.yuyh.library.imgsel.utils.LogUtils;
|
|
@@ -12,6 +13,8 @@ import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
import java.io.File;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author wangjie
|
|
@@ -31,37 +34,44 @@ public class OfflineSendRequest {
|
|
|
* 新的离线图片存储上传
|
|
|
*
|
|
|
* @param context
|
|
|
+ * @param mVm
|
|
|
*/
|
|
|
- public void uploadImageNew(Context context) {
|
|
|
+ public void uploadImageNew(Context context, AdmViewModel mVm, String projectId, String groupCode) {
|
|
|
String imageFilePath = LocalDataOperation.getInstance().getOfflineImageFilePath(context);
|
|
|
File imageFile = new File(imageFilePath);
|
|
|
if (imageFile.exists()) {
|
|
|
File[] files = imageFile.listFiles();
|
|
|
if (files != null && files.length > 0) {
|
|
|
for (File file : files) {
|
|
|
- if (!TextUtils.isEmpty(file.getName()) && !file.getName().startsWith("uploaded")) {
|
|
|
- final String url = Constant.ServerImgIPUp + file.getName();
|
|
|
- Log.e("uploadImageNew url", url);
|
|
|
- String result = UploadImage.uploadFiles(file, url);
|
|
|
- if (!TextUtils.isEmpty(result)) {
|
|
|
- String resultString = null;
|
|
|
- try {
|
|
|
- JSONObject object = new JSONObject(result);
|
|
|
- resultString = object.getString("Result");
|
|
|
- Log.e("resultString", resultString);
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if ("success".equals(resultString)) {
|
|
|
- //不管是那种情况,只要成功都需要从本地删除该图片
|
|
|
- boolean b = file.renameTo(new File(imageFilePath + File.separator + "uploaded" + file.getName()));
|
|
|
- //file.delete();
|
|
|
- LogUtils.e("uploadImageNew", "上传成功" + b + file.getName());
|
|
|
- } else {
|
|
|
- LogUtils.e("uploadImageNew", "上传失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ Map param = new HashMap<String, String>();
|
|
|
+ param.put("appId", "adm");
|
|
|
+ param.put("userId", "bdtp");
|
|
|
+ param.put("groupCode", groupCode);
|
|
|
+ param.put("projectId", projectId);
|
|
|
+ mVm.fileUpload(param, file);
|
|
|
+// if (!TextUtils.isEmpty(file.getName()) && !file.getName().startsWith("uploaded")) {
|
|
|
+// final String url = Constant.ServerImgIPUp + file.getName();
|
|
|
+// Log.e("uploadImageNew url", url);
|
|
|
+// String result = UploadImage.uploadFiles(file, url);
|
|
|
+// if (!TextUtils.isEmpty(result)) {
|
|
|
+// String resultString = null;
|
|
|
+// try {
|
|
|
+// JSONObject object = new JSONObject(result);
|
|
|
+// resultString = object.getString("Result");
|
|
|
+// Log.e("resultString", resultString);
|
|
|
+// } catch (JSONException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// if ("success".equals(resultString)) {
|
|
|
+// //不管是那种情况,只要成功都需要从本地删除该图片
|
|
|
+// boolean b = file.renameTo(new File(imageFilePath + File.separator + "uploaded" + file.getName()));
|
|
|
+// //file.delete();
|
|
|
+// LogUtils.e("uploadImageNew", "上传成功" + b + file.getName());
|
|
|
+// } else {
|
|
|
+// LogUtils.e("uploadImageNew", "上传失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|