From 8c5beca7503606493ea807223ca5c6b3f3eef016 Mon Sep 17 00:00:00 2001
From: lihongtao <lihongtao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期三, 28 六月 2017 15:01:33 +0800
Subject: [PATCH]
---
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java | 71 +++++++++++++++++++++++++++++++++--
1 files changed, 66 insertions(+), 5 deletions(-)
diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
index c11daf8..2962278 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
@@ -53,10 +53,13 @@
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
+import org.xutils.common.util.FileUtil;
import org.xutils.http.RequestParams;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -138,13 +141,42 @@
resetForm();
}
+ private File writeToFile(String fileName, byte[] fileBytes) {
+ try {
+ String dir = MainActivity.getInstance().getFilesDir().getAbsolutePath();
+
+ File file = new File(dir, fileName);
+ if (file.exists()) {
+ file.delete();
+ }
+ file.createNewFile();
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File(dir, fileName)));
+ bos.write(fileBytes);
+ bos.flush();
+ bos.close();
+ return new File(dir, fileName);
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
@OnClick(R.id.fragment_register_save)
public void fragment_register_save_click(View v) {
+// RegisterMng.getInstance().add(null);
+// if (1==1) {
+// return;
+// }
if (!BaseApplication.deviceAvailable) {
return;
}
+// SurveillanceMng.getInstance().addBitmap(new ArrayList(), new byte[]{1,2,3}, 3, "1");
+//
+// if (1==1) {
+// return;
+// }
RequestParams params = new RequestParams();
String name = fragment_register_name.getValue();
@@ -220,6 +252,17 @@
pd.addValue(Register.FieldNames.birthday, birthday);
+ params.addBodyParameter(Register.FieldNames.username, name);
+ params.addBodyParameter(Register.FieldNames.mobilePhone, phone);
+ params.addBodyParameter(Register.FieldNames.genderId, DictionaryMng.getInstance().getId(gender));
+ params.addBodyParameter(Register.FieldNames.identityTypeId, DictionaryMng.getInstance().getId(id_class));
+ params.addBodyParameter(Register.FieldNames.countryId, DictionaryMng.getInstance().getId(country));
+ params.addBodyParameter(Register.FieldNames.visitorTypeId, DictionaryMng.getInstance().getId(visitor_class));
+ params.addBodyParameter(Register.FieldNames.identifyNum, id_num);
+ params.addBodyParameter(Register.FieldNames.companyId, company);
+ params.addBodyParameter(Register.FieldNames.birthday, birthday);
+
+
if (surveillanceQueryItem_selectPhoto != null) {
params.addBodyParameter("width", surveillanceQueryItem_selectPhoto.getWidth());
params.addBodyParameter("height", surveillanceQueryItem_selectPhoto.getHeight());
@@ -231,6 +274,10 @@
imageBytes[i] = nativeImg.image[i];
}
pd.addData("rawSurveillancePhoto", "application/octet-stream", imageBytes);
+
+ params.addBodyParameter("rawSurveillancePhoto", writeToFile("rawSurveillancePhoto", imageBytes));
+ } else {
+ params.addBodyParameter("rawSurveillancePhoto", writeToFile("rawSurveillancePhoto", new byte[]{}));
}
if (fragment_register_surveillance_photo_img != null) {
@@ -238,6 +285,10 @@
fragment_register_surveillance_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] imageBytes = byteArrayOutputStream.toByteArray();
pd.addData(Register.FieldNames.surveillancePhoto, "application/octet-stream", imageBytes);
+
+ params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", imageBytes));
+ } else {
+ params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", new byte[]{}));
}
if (fragment_register_upload_custom_photo_img != null) {
@@ -245,6 +296,10 @@
fragment_register_upload_custom_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] imageBytes = byteArrayOutputStream.toByteArray();
pd.addData(Register.FieldNames.uploadCustomPhoto, "application/octet-stream", imageBytes);
+
+ params.addBodyParameter("uploadCustomPhoto", writeToFile("uploadCustomPhoto", imageBytes));
+ } else {
+ params.addBodyParameter("uploadCustomPhoto", writeToFile("uploadCustomPhoto", new byte[]{}));
}
if (fragment_register_id_card_photo_img != null) {
@@ -252,6 +307,10 @@
fragment_register_id_card_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
byte[] imageBytes = byteArrayOutputStream.toByteArray();
pd.addData(Register.FieldNames.idCardPhoto, "application/octet-stream", imageBytes);
+
+ params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", imageBytes));
+ } else {
+ params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", new byte[]{}));
}
@@ -260,8 +319,8 @@
@Override
protected String doInBackground(String... urls) {
try {
- Uploader uploader = new Uploader("", AppApi.BASE_URL + AppApi.REGISTER_ADD);
- json = uploader.upload("", pd);
+// Uploader uploader = new Uploader("", AppApi.BASE_URL + AppApi.REGISTER_ADD);
+// json = uploader.upload("", pd);
return json;
} catch (Exception e) {
e.printStackTrace();
@@ -280,9 +339,11 @@
}
}
- ConnectionTask task = new ConnectionTask();
- String[] params1 = new String[2];
- task.execute(params1);
+// ConnectionTask task = new ConnectionTask();
+// String[] params1 = new String[2];
+// task.execute(params1);
+
+ RegisterMng.getInstance().add(params);
}
public void set_fragment_register_surveillance_photo(SurveillanceQueryItem item) {
--
Gitblit v1.8.0