From 5ade7f3782a57abdf418361bd2f9baeb6ad3707e Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 07 七月 2017 12:51:52 +0800
Subject: [PATCH] 

---
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java |  131 ++++++++++++++++++-------------------------
 1 files changed, 54 insertions(+), 77 deletions(-)

diff --git a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java
index b9dc589..849fbc4 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/RegisterMng.java
@@ -15,6 +15,7 @@
 import java.util.List;
 
 import cn.com.basic.face.discern.common.BaseCommonCallBack;
+import cn.com.basic.face.util.IdCard;
 
 public class RegisterMng {
 
@@ -28,82 +29,58 @@
         if (!BaseApplication.deviceAvailable) {
             return;
         }
-//        params = new RequestParams();
         try {
-//            params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD);
-//            x.http().post(params, new BaseCommonCallBack() {
-//                @Override
-//                public void success() {
-//                    Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show();
-//                    //RegisterFragment.getInstance().resetForm();
-//                }
-//            });
-
-
-            try {
-                File path = BaseApplication.getInstance().getFilesDir();
-                File f1 = new File(path, "rawSurveillancePhoto");
-                if (!f1.exists()) {
-                    f1.createNewFile();
-                }
-                File f0 = new File(path, "f0");
-                if (!f0.exists()) {
-                    f0.createNewFile();
-                }
-                File f2 = new File(path, "surveillancePhoto");
-                if (!f2.exists()) {
-                    f2.createNewFile();
-                }
-                File f3 = new File(path, "uploadCustomPhoto");
-                if (!f3.exists()) {
-                    f3.createNewFile();
-                }
-                File f4 = new File(path, "idCardPhoto");
-                if (!f4.exists()) {
-                    f4.createNewFile();
-                }
-
-                FileWriter fw0 = new FileWriter(f0);
-                fw0.write("test1");
-                fw0.close();
-//                FileWriter fw1 = new FileWriter(f1);
-//                fw1.write("test1");
-//                fw1.close();
-//                FileWriter fw2 = new FileWriter(f2);
-//                fw2.write("test2");
-//                fw2.close();
-                params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD);
-                params.addBodyParameter("f0", f0);
-                params.addBodyParameter("rawSurveillancePhoto", f1);
-                params.addBodyParameter("surveillancePhoto", f2);
-                params.addBodyParameter("uploadCustomPhoto", f3);
-                params.addBodyParameter("idCardPhoto", f4);
-                if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) {
-                    File f5 = new File(idCardHeadPhoto);
-                    if (!f5.exists()) {
-                        f5.createNewFile();
-                    }
-                    params.addBodyParameter("idCardHeadPhoto", f5);
-                }
-                x.http().post(params, new BaseCommonCallBack() {
-                    @Override
-                    public void success() {
-                        Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show();
-                        RegisterFragment.getInstance().resetForm();
-                    }
-                });
-            }catch(Exception e) {
-                e.printStackTrace();
+            File path = BaseApplication.getInstance().getFilesDir();
+            File rawSurveillancePhotoFile = new File(path, "rawSurveillancePhoto");
+            if (!rawSurveillancePhotoFile.exists()) {
+                rawSurveillancePhotoFile.createNewFile();
+            }
+            File f0 = new File(path, "f0");
+            if (!f0.exists()) {
+                f0.createNewFile();
+            }
+            File surveillancePhotoFile = new File(path, "surveillancePhoto");
+            if (!surveillancePhotoFile.exists()) {
+                surveillancePhotoFile.createNewFile();
+            }
+            File uploadCustomPhotoFile = new File(path, "uploadCustomPhoto");
+            if (!uploadCustomPhotoFile.exists()) {
+                uploadCustomPhotoFile.createNewFile();
+            }
+            File idCardPhotoFile = new File(path, "idCardPhoto");
+            if (!idCardPhotoFile.exists()) {
+                idCardPhotoFile.createNewFile();
             }
 
+            FileWriter fw0 = new FileWriter(f0);
+            fw0.write("test1");
+            fw0.close();
+            params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ADD);
+            params.addBodyParameter("f0", f0);
+            params.addBodyParameter("rawSurveillancePhoto", rawSurveillancePhotoFile);
+            params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
+            params.addBodyParameter("uploadCustomPhoto", uploadCustomPhotoFile);
+            params.addBodyParameter("idCardPhoto", idCardPhotoFile);
+            if (idCardHeadPhoto != null && !"".equals(idCardHeadPhoto)) {
+                File f5 = new File(idCardHeadPhoto);
+                if (!f5.exists()) {
+                    f5.createNewFile();
+                }
+                params.addBodyParameter("idCardHeadPhoto", f5);
+            }
+            x.http().post(params, new BaseCommonCallBack() {
+                @Override
+                public void success() {
+                    Toast.makeText(BaseApplication.getInstance(),"娣诲姞鎴愬姛", Toast.LENGTH_SHORT).show();
+                    RegisterFragment.getInstance().resetForm();
+                }
+            });
         }catch(Exception e) {
             e.printStackTrace();
-
         }
     }
 
-
-    public void compareSurveillancePhotoAndIdCardPhoto(RequestParams params) {
+    public void compareSurveillancePhotoAndIdCardPhoto(RequestParams params, final IdCard idCard) {
         if (!BaseApplication.deviceAvailable) {
             return;
         }
@@ -113,13 +90,13 @@
             if (!f0.exists()) {
                 f0.createNewFile();
             }
-            File f2 = new File(path, "surveillancePhoto");
-            if (!f2.exists()) {
-                f2.createNewFile();
+            File surveillancePhotoFile = new File(path, "surveillancePhoto");
+            if (!surveillancePhotoFile.exists()) {
+                surveillancePhotoFile.createNewFile();
             }
-            File f4 = new File(path, "idCardHeadPhoto");
-            if (!f4.exists()) {
-                f4.createNewFile();
+            File idCardHeadPhotoFile = new File(path, "idCardHeadPhoto");
+            if (!idCardHeadPhotoFile.exists()) {
+                idCardHeadPhotoFile.createNewFile();
             }
             FileWriter fw0 = new FileWriter(f0);
             fw0.write("test1");
@@ -127,8 +104,8 @@
 
             params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ID_CARD_AUTH);
             params.addBodyParameter("f0", f0);
-            params.addBodyParameter("surveillancePhoto", f2);
-            params.addBodyParameter("idCardPhoto", f4);
+            params.addBodyParameter("surveillancePhoto", surveillancePhotoFile);
+            params.addBodyParameter("idCardPhoto", idCardHeadPhotoFile);
             x.http().post(params, new BaseCommonCallBack() {
                 @Override
                 public void success() {
@@ -140,7 +117,7 @@
                         double percent = percents.get(0);
                         if (percent >= 70) {
                             Toast.makeText(BaseApplication.getInstance(),"璁よ瘉閫氳繃", Toast.LENGTH_SHORT).show();
-                            RegisterFragment.getInstance().fillFormWithIdCard();
+                            RegisterFragment.getInstance().fillFormWithIdCard(idCard);
                             return;
                         }
                         System.out.println("percent="+percent);

--
Gitblit v1.8.0