| | |
| | | package cn.com.basic.face.fragment;
|
| | |
|
| | | import android.app.Activity;
|
| | | import android.content.BroadcastReceiver;
|
| | | import android.content.Context;
|
| | | import android.content.Intent;
|
| | | import android.graphics.Bitmap;
|
| | |
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONArray;
|
| | | import com.bit.rfid.RFIDReader;
|
| | | import com.bit.rfid.ReaderExtra;
|
| | | import com.bsk.zhangbo.demoforbsk.R;
|
| | |
|
| | | import cn.com.basic.face.adapter.SurveillanceFragment;
|
| | |
| | | import cn.com.basic.face.service.SurveillanceMng;
|
| | | import cn.com.basic.face.util.BitmapUtil;
|
| | | import cn.com.basic.face.util.Constant;
|
| | | import cn.com.basic.face.util.FileUtil;
|
| | | import static cn.com.basic.face.util.FileUtil.*;
|
| | |
|
| | | import cn.com.basic.face.util.IdCard;
|
| | | import cn.com.basic.face.util.IdCardReaderThread;
|
| | | import cn.com.basic.face.util.NativeImg;
|
| | | import cn.com.basic.face.util.OkClickedListener;
|
| | |
|
| | |
| | | import cn.com.basic.face.widget.register.RegisterRightFieldTextView;
|
| | | import cn.com.basic.face.dialog.SelectDialog;
|
| | |
|
| | | import com.ivsign.android.IDCReader.IDCReaderSDK;
|
| | | import com.lidroid.xutils.view.annotation.ViewInject;
|
| | | import com.lidroid.xutils.view.annotation.event.OnClick;
|
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | |
|
| | | import java.io.BufferedOutputStream;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.FileOutputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.RandomAccessFile;
|
| | | import java.io.Reader;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | |
|
| | | private File idCardImageCaptureFile = null;
|
| | |
|
| | | private IdCardReaderThread idCardReaderThread = null;
|
| | |
|
| | | private String idCardHeadPath = "";
|
| | |
|
| | | private static RegisterFragment instance = new RegisterFragment();
|
| | |
|
| | | public static RegisterFragment getInstance() {
|
| | |
| | |
|
| | | @OnClick(R.id.fragment_register_save)
|
| | | public void fragment_register_save_click(View v) {
|
| | |
|
| | |
|
| | | 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();
|
| | |
| | | fragment_register_phone.requestFocus();
|
| | | return;
|
| | | }
|
| | | String gender = fragment_register_gender.getValue();
|
| | | if (gender.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "性别不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_gender.callOnClick();
|
| | | return;
|
| | | }
|
| | | String id_class = fragment_register_id_class.getValue();
|
| | | if (id_class.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "证件类型不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_id_class.callOnClick();
|
| | | return;
|
| | | }
|
| | | String country = fragment_register_country.getValue();
|
| | | if (country.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "国籍不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_country.callOnClick();
|
| | | return;
|
| | | }
|
| | | String id_num = fragment_register_id_num.getValue();
|
| | | if (id_num.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "证件编号不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_id_num.requestFocus();
|
| | | return;
|
| | | }
|
| | | String birthday = fragment_register_birthday.getValue();
|
| | | if (birthday.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "出生日期不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_birthday.callOnClick();
|
| | | return;
|
| | | }
|
| | | String company = fragment_register_company.getValue();
|
| | | if (company.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "公司名称不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_company.requestFocus();
|
| | | return;
|
| | | }
|
| | | String remark = fragment_register_remark.getValue();
|
| | | if (remark.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "备注不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_remark.requestFocus();
|
| | | return;
|
| | | }
|
| | | String visitor_class = fragment_register_visitor_class.getValue();
|
| | | if (visitor_class.trim().length() <= 0) {
|
| | | String visitor_type = fragment_register_visitor_class.getValue();
|
| | | if (visitor_type.trim().length() <= 0) {
|
| | | Toast.makeText(MainActivity.getInstance(), "访客类型不能为空", Toast.LENGTH_SHORT).show();
|
| | | fragment_register_visitor_class.callOnClick();
|
| | | return;
|
| | | }
|
| | | final PostData pd = new PostData();
|
| | |
|
| | | pd.addValue(Register.FieldNames.username, name);
|
| | | pd.addValue(Register.FieldNames.mobilePhone, phone);
|
| | | pd.addValue(Register.FieldNames.genderId, DictionaryMng.getInstance().getId(gender));
|
| | | pd.addValue(Register.FieldNames.identityTypeId, DictionaryMng.getInstance().getId(id_class));
|
| | | pd.addValue(Register.FieldNames.countryId, DictionaryMng.getInstance().getId(country));
|
| | | pd.addValue(Register.FieldNames.visitorTypeId, DictionaryMng.getInstance().getId(visitor_class));
|
| | | pd.addValue(Register.FieldNames.identifyNum, id_num);
|
| | | pd.addValue(Register.FieldNames.companyId, company);
|
| | | 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(fragment_register_gender.getValue()));
|
| | | params.addBodyParameter(Register.FieldNames.identityTypeId, DictionaryMng.getInstance().getId(fragment_register_id_class.getValue()));
|
| | | params.addBodyParameter(Register.FieldNames.countryId, DictionaryMng.getInstance().getId(fragment_register_country.getValue()));
|
| | | params.addBodyParameter(Register.FieldNames.visitorTypeId, DictionaryMng.getInstance().getId(visitor_type));
|
| | | params.addBodyParameter(Register.FieldNames.identifyNum, fragment_register_id_num.getValue());
|
| | | params.addBodyParameter(Register.FieldNames.companyId, company);
|
| | | params.addBodyParameter(Register.FieldNames.birthday, fragment_register_birthday.getValue());
|
| | | params.addBodyParameter(Register.FieldNames.remark, fragment_register_remark.getValue());
|
| | |
|
| | | if (surveillanceQueryItem_selectPhoto != null) {
|
| | | params.addBodyParameter("width", surveillanceQueryItem_selectPhoto.getWidth());
|
| | |
| | | for (int i = 0; i < nativeImg.size; i++) {
|
| | | imageBytes[i] = nativeImg.image[i];
|
| | | }
|
| | | pd.addData("rawSurveillancePhoto", "application/octet-stream", imageBytes);
|
| | | params.addBodyParameter("rawSurveillancePhoto", FileUtil.writeToFile("rawSurveillancePhoto", imageBytes));
|
| | | } else {
|
| | | params.addBodyParameter("rawSurveillancePhoto", FileUtil.writeToFile("rawSurveillancePhoto", new byte[]{}));
|
| | | }
|
| | |
|
| | | if (fragment_register_surveillance_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | 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", FileUtil.writeToFile("surveillancePhoto", imageBytes));
|
| | | } else {
|
| | | params.addBodyParameter("surveillancePhoto", FileUtil.writeToFile("surveillancePhoto", new byte[]{}));
|
| | | }
|
| | |
|
| | | if (fragment_register_upload_custom_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | 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", FileUtil.writeToFile("uploadCustomPhoto", imageBytes));
|
| | | } else {
|
| | | params.addBodyParameter("uploadCustomPhoto", FileUtil.writeToFile("uploadCustomPhoto", new byte[]{}));
|
| | | }
|
| | |
|
| | | if (fragment_register_id_card_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | 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", FileUtil.writeToFile("idCardPhoto", imageBytes));
|
| | | } else {
|
| | | params.addBodyParameter("idCardPhoto", FileUtil.writeToFile("idCardPhoto", new byte[]{}));
|
| | | }
|
| | |
|
| | |
|
| | | class ConnectionTask extends AsyncTask<String, Void, String> {
|
| | | private String json = "";
|
| | | @Override
|
| | | protected String doInBackground(String... urls) {
|
| | | try {
|
| | | Uploader uploader = new Uploader("", AppApi.BASE_URL + AppApi.REGISTER_ADD);
|
| | | json = uploader.upload("", pd);
|
| | | return json;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void onPostExecute(String result) {
|
| | | try {
|
| | | Toast.makeText(BaseApplication.getInstance(),"添加成功", Toast.LENGTH_SHORT).show();
|
| | | //RegisterFragment.getInstance().resetForm();
|
| | | } catch(Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | ConnectionTask task = new ConnectionTask();
|
| | | String[] params1 = new String[2];
|
| | | task.execute(params1);
|
| | | RegisterMng.getInstance().add(params, idCardHeadPath);
|
| | | }
|
| | |
|
| | | public void set_fragment_register_surveillance_photo(SurveillanceQueryItem item) {
|
| | |
| | | selectedCustomPhotoId = -1;
|
| | | selectedSurveillancePhotoId = -1;
|
| | |
|
| | | idCardHeadPath = "";
|
| | |
|
| | | fragment_register_name.setValue("徐修溪"+Math.random());
|
| | | fragment_register_phone.setValue("13691348767");
|
| | | fragment_register_id_num.setValue("36041419292222222");
|
| | |
| | | fragment_register_remark.setValue("备注");
|
| | |
|
| | | fragment_register_name.setValue("");
|
| | | fragment_register_phone.setValue("");
|
| | | fragment_register_id_num.setValue("");
|
| | | fragment_register_birthday.setValue("");
|
| | | fragment_register_company.setValue("");
|
| | | fragment_register_remark.setValue("");
|
| | |
|
| | | fragment_register_gender.setValue("男");
|
| | | fragment_register_id_class.setValue("身份证");
|
| | |
| | | @Override
|
| | | protected void initData() {
|
| | | resetForm();
|
| | | idCardReaderThread = new IdCardReaderThread();
|
| | | idCardReaderThread.start();
|
| | | }
|
| | |
|
| | | public void fillFormWithIdCard(IdCard idCard) {
|
| | | try {
|
| | | fragment_register_name.setValue(idCard.getName());
|
| | | fragment_register_id_num.setValue(idCard.getCardNumber());
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
|
| | |
|
| | | fragment_register_birthday.setValue(sdf1.format(sdf.parse(idCard.getBirthday())));
|
| | | fragment_register_gender.setValue(idCard.getGender());
|
| | | fragment_register_id_class.setValue("身份证");
|
| | | BitmapFactory.Options options = new BitmapFactory.Options();
|
| | | options.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
| | | Bitmap bitmap = BitmapFactory.decodeFile(idCard.getHeadPath(), options);
|
| | | fragment_register_id_card_photo.setImageBitmap(bitmap);
|
| | | fragment_register_id_card_photo_placeholder_image.setVisibility(View.INVISIBLE);
|
| | | fragment_register_id_card_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
|
| | | idCardHeadPath = idCard.getHeadPath();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private boolean registerFragmentVisible = false;
|
| | |
|
| | | @Override
|
| | | public void setMenuVisibility(boolean menuVisible) {
|
| | | super.setMenuVisibility(menuVisible);
|
| | | registerFragmentVisible = menuVisible;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | }
|