xuxiuxi
2017-06-29 26201eca8dc6a86f37b5d30469edeab367786cd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package cn.com.basic.face.service;
 
import android.widget.Toast;
 
import cn.com.basic.face.base.BaseApplication;
import cn.com.basic.face.fragment.RegisterFragment;
import cn.com.basic.face.util.AppApi;
 
import org.xutils.http.RequestParams;
import org.xutils.x;
 
import java.io.File;
import java.io.FileWriter;
 
import cn.com.basic.face.discern.common.BaseCommonCallBack;
 
public class RegisterMng {
 
    public static RegisterMng instance = new RegisterMng();
 
    public static RegisterMng getInstance() {
        return instance;
    }
 
    public void add(RequestParams params) {
        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);
                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();
            }
 
        }catch(Exception e) {
            e.printStackTrace();
 
        }
    }
 
 
    public void compareSurveillancePhotoAndIdCardPhoto(RequestParams params) {
        if (!BaseApplication.deviceAvailable) {
            return;
        }
        try {
            File path = BaseApplication.getInstance().getFilesDir();
            File f0 = new File(path, "f0");
            if (!f0.exists()) {
                f0.createNewFile();
            }
            File f2 = new File(path, "surveillancePhoto");
            if (!f2.exists()) {
                f2.createNewFile();
            }
            File f4 = new File(path, "idCardPhoto");
            if (!f4.exists()) {
                f4.createNewFile();
            }
            FileWriter fw0 = new FileWriter(f0);
            fw0.write("test1");
            fw0.close();
 
            params.setUri(AppApi.BASE_URL +AppApi.REGISTER_ID_CARD_AUTH);
            params.addBodyParameter("f0", f0);
            params.addBodyParameter("surveillancePhoto", f2);
            params.addBodyParameter("idCardPhoto", f4);
            x.http().post(params, new BaseCommonCallBack() {
                @Override
                public void success() {
                    Toast.makeText(BaseApplication.getInstance(),"测试相似度", Toast.LENGTH_SHORT).show();
                }
            });
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
 
 
}