| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | 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());
|
| | |
| | | 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) {
|
| | |
| | | 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) {
|
| | |
| | | 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) {
|
| | |
| | | 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[]{}));
|
| | | }
|
| | |
|
| | |
|
| | |
| | | @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();
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | 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) {
|