From b37c7f21ff92cf0af06f47eac85062b8af7d8b2f Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 14 七月 2017 11:58:29 +0800
Subject: [PATCH] 

---
 VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java |  886 +---------------------------------------------------------
 1 files changed, 19 insertions(+), 867 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 5a6a0bd..8ebee3f 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
@@ -1,898 +1,50 @@
 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 android.graphics.BitmapFactory;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.util.Base64;
-import android.util.DisplayMetrics;
-import android.view.MotionEvent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
 import android.view.View;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
 
-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.base.BaseApplication;
-import cn.com.basic.face.base.BaseFragment;
-import cn.com.basic.face.base.PictureTaker;
-import cn.com.basic.face.dialog.SurveillancePhotoDialog;
-import cn.com.basic.face.discern.common.CommonVariables;
-import cn.com.basic.face.discern.common.ResultBean;
-import cn.com.basic.face.discern.entity.Register;
-import cn.com.basic.face.discern.query.item.CheckInQueryItem;
-import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
-import cn.com.basic.face.service.DictionaryMng;
-import cn.com.basic.face.service.RegisterMng;
-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.NativeImg;
-import cn.com.basic.face.util.OkClickedListener;
-
-import cn.com.basic.face.util.AppApi;
-import cn.com.basic.face.dialog.DateSelectDialog;
-import cn.com.basic.face.dialog.CountryDialog;
-import cn.com.basic.face.util.PostData;
-import cn.com.basic.face.util.Uploader;
-import cn.com.basic.face.widget.register.RegisterRightFieldLabelView;
-import cn.com.basic.face.widget.register.RegisterRightFieldTextView;
-import cn.com.basic.face.dialog.SelectDialog;
-
-import com.facebook.common.file.FileUtils;
-import com.ivsign.android.IDCReader.IDCReaderSDK;
-import com.lidroid.xutils.view.annotation.ViewInject;
 import com.lidroid.xutils.view.annotation.event.OnClick;
 
-import org.xutils.common.util.FileUtil;
-import org.xutils.common.util.IOUtil;
-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;
-import java.util.List;
-
+import cn.com.basic.face.base.BaseFragment;
 import cn.com.basic.face.base.MainActivity;
 
-public class RegisterFragment extends BaseFragment implements View.OnClickListener{
+/**
+ * Created by xiuxi on 2017/7/12.
+ */
 
-    @ViewInject(R.id.fragment_register_name)
-    private RegisterRightFieldTextView fragment_register_name;
-    @ViewInject(R.id.fragment_register_gender)
-    private RegisterRightFieldLabelView fragment_register_gender;
-    @ViewInject(R.id.fragment_register_country)
-    private RegisterRightFieldLabelView fragment_register_country;
-    @ViewInject(R.id.fragment_register_birthday)
-    private RegisterRightFieldLabelView fragment_register_birthday;
-    @ViewInject(R.id.fragment_register_visitor_class)
-    private RegisterRightFieldLabelView fragment_register_visitor_class;
-    @ViewInject(R.id.fragment_register_phone)
-    private RegisterRightFieldTextView fragment_register_phone;
-    @ViewInject(R.id.fragment_register_id_class)
-    private RegisterRightFieldLabelView fragment_register_id_class;
-    @ViewInject(R.id.fragment_register_id_num)
-    private RegisterRightFieldTextView fragment_register_id_num;
-    @ViewInject(R.id.fragment_register_company)
-    private RegisterRightFieldTextView fragment_register_company;
-    @ViewInject(R.id.fragment_register_remark)
-    private RegisterRightFieldTextView fragment_register_remark;
-    @ViewInject(R.id.fragment_register_surveillance_photo)
-    private ImageView fragment_register_surveillance_photo;
-    @ViewInject(R.id.fragment_register_upload_custom_photo)
-    private ImageView fragment_register_upload_custom_photo;
-    @ViewInject(R.id.fragment_register_id_card_photo)
-    private ImageView fragment_register_id_card_photo;
-    @ViewInject(R.id.fragment_register_linear_layout)
-    private LinearLayout fragment_register_linear_layout;
-    @ViewInject(R.id.fragment_register_surveillance_photo_placeholder_image)
-    private ImageView fragment_register_surveillance_photo_placeholder_image;
-    @ViewInject(R.id.fragment_register_upload_custom_photo_placeholder_image)
-    private ImageView fragment_register_upload_custom_photo_placeholder_image;
-    @ViewInject(R.id.fragment_register_id_card_photo_placeholder_image)
-    private ImageView fragment_register_id_card_photo_placeholder_image;
-    @ViewInject(R.id.fragment_register_surveillance_photo_placeholder_text_view)
-    private TextView fragment_register_surveillance_photo_placeholder_text_view;
-    @ViewInject(R.id.fragment_register_upload_custom_photo_placeholder_text_view)
-    private TextView fragment_register_upload_custom_photo_placeholder_text_view;
-    @ViewInject(R.id.fragment_register_id_card_photo_placeholder_text_view)
-    private TextView fragment_register_id_card_photo_placeholder_text_view;
-
-    private static final int fragment_register_surveillance_photo_ = 1;
-    private static final int fragment_register_upload_custom_photo_ = 2;
-    private static final int fragment_register_id_card_photo_ = 3;
-
-    private Bitmap fragment_register_surveillance_photo_img;
-    private Bitmap fragment_register_upload_custom_photo_img;
-    private Bitmap fragment_register_id_card_photo_img;
-
-    private SurveillanceQueryItem surveillanceQueryItem_selectPhoto;
-    private SurveillanceQueryItem surveillanceQueryItem_uploadPhoto;
-
-    public static long selectedSurveillancePhotoId = -1;
-    public static long selectedCustomPhotoId = -1;
-
-    private File idCardImageCaptureFile = null;
-
-    private String idCardHeadPhotoPath = "";
+public class RegisterFragment extends BaseFragment {
 
     private static RegisterFragment instance = new RegisterFragment();
-
     public static RegisterFragment getInstance() {
         return instance;
     }
+
     @Override
     protected int getLayoutId() {
         return R.layout.fragment_register;
     }
 
-    @OnClick(R.id.fragment_register_add)
-    public void fragment_register_add_click(View view) {
-        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) {
-        RequestParams params = new RequestParams();
-
-        String name = fragment_register_name.getValue();
-        if (name.trim().length() <= 0) {
-            Toast.makeText(MainActivity.getInstance(), "濮撳悕涓嶈兘涓虹┖", Toast.LENGTH_SHORT).show();
-            fragment_register_name.requestFocus();
-            return;
-        }
-        String phone = fragment_register_phone.getValue();
-        if (phone.trim().length() <= 0) {
-            Toast.makeText(MainActivity.getInstance(), "鐢佃瘽涓嶈兘涓虹┖", Toast.LENGTH_SHORT).show();
-            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) {
-            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(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());
-            fragment_register_surveillance_photo_img = surveillanceQueryItem_selectPhoto.getBitmap();
-
-            NativeImg nativeImg = surveillanceQueryItem_selectPhoto.getNativeImg();
-            byte[] imageBytes = new byte[nativeImg.size];
-            for (int i = 0; i < nativeImg.size; i++) {
-                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) {
-            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", writeToFile("surveillancePhoto", imageBytes));
-        } else {
-            params.addBodyParameter("surveillancePhoto", 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", writeToFile("uploadCustomPhoto", imageBytes));
-        } else {
-            params.addBodyParameter("uploadCustomPhoto", 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", writeToFile("idCardPhoto", imageBytes));
-        } else {
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", new byte[]{}));
-        }
-        RegisterMng.getInstance().add(params, idCardHeadPhotoPath);
-    }
-
-    public void set_fragment_register_surveillance_photo(SurveillanceQueryItem item) {
-        surveillanceQueryItem_selectPhoto = item;
-        fragment_register_surveillance_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(item.getBitmap(),
-                (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp)));
-        fragment_register_surveillance_photo_img = item.getBitmap();
-        fragment_register_surveillance_photo_placeholder_image.setVisibility(View.INVISIBLE);
-        fragment_register_surveillance_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-    }
-
-    public void set_fragment_register_upload_custom_photo(SurveillanceQueryItem item) {
-        surveillanceQueryItem_uploadPhoto = item;
-        fragment_register_upload_custom_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(item.getBitmap(),
-                (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp)));
-        fragment_register_upload_custom_photo_img = item.getBitmap();
-
-        fragment_register_upload_custom_photo_placeholder_image.setVisibility(View.INVISIBLE);
-        fragment_register_upload_custom_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-    }
-
     @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-        if (requestCode == fragment_register_surveillance_photo_ && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
-            Uri uri = data.getData();
-            try {
-                Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri);
-                fragment_register_surveillance_photo.setImageBitmap(bitmap);
-                fragment_register_surveillance_photo_img = bitmap;
-
-                fragment_register_surveillance_photo_placeholder_image.setVisibility(View.INVISIBLE);
-                fragment_register_surveillance_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        if (requestCode == fragment_register_upload_custom_photo_ && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
-            Uri uri = data.getData();
-            try {
-                Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri);
-                fragment_register_upload_custom_photo.setImageBitmap(bitmap);
-
-                fragment_register_upload_custom_photo_placeholder_image.setVisibility(View.INVISIBLE);
-                fragment_register_upload_custom_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-
-                List<SurveillanceQueryItem> bitmapList = new ArrayList<>();
-                SurveillanceQueryItem item = new SurveillanceQueryItem();
-                item.setWidth(bitmap.getWidth()+"");
-                item.setHeight(bitmap.getHeight()+"");
-                item.setLocalUri(uri);
-
-                setSurveillanceQueryItem_selectPhoto(item);
-                bitmapList.add(item);
-                bitmapList.add(item);
-                bitmapList.add(item);
-
-                SurveillanceMng.getInstance().addBitmap(bitmapList, null, 0, CommonVariables.Camera.IN);
-
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        if (requestCode == fragment_register_id_card_photo_ && resultCode == Activity.RESULT_OK) {
-
-            try {
-                if (data != null && data.getData() != null) {
-                    Uri uri = data.getData();
-                    Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri);
-                    fragment_register_id_card_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(bitmap,
-                            (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp)));
-                    fragment_register_id_card_photo_img = bitmap;
-                    MainActivity.getInstance().getContentResolver().delete(uri, null, null);
-
-                    fragment_register_id_card_photo_placeholder_image.setVisibility(View.INVISIBLE);
-                    fragment_register_id_card_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-                } else if (idCardImageCaptureFile != null){
-                    if (idCardImageCaptureFile.exists()) {
-                        BitmapFactory.Options options = new BitmapFactory.Options();
-                        options.inJustDecodeBounds = true;
-                        BitmapFactory.decodeFile(idCardImageCaptureFile.getAbsolutePath(), options);
-                        int width = options.outWidth;
-                        int height = options.outHeight;
-                        WindowManager wm = (WindowManager) MainActivity.getInstance().getSystemService(Context.WINDOW_SERVICE);
-                        int screenWidth = wm.getDefaultDisplay().getWidth();
-                        int screenHeight = wm.getDefaultDisplay().getHeight();
-                        int dx = width / screenWidth;
-                        int dy = height / screenHeight;
-                        int scale = 1;
-                        if (dx > dy && dy >= 1) {
-                            scale = dx;
-                        }
-                        if (dy > dx && dx >= 1) {
-                            scale = dy;
-                        }
-                        options.inSampleSize = scale;
-                        options.inJustDecodeBounds = false;
-                        Bitmap bitmap = BitmapFactory.decodeFile(idCardImageCaptureFile.getAbsolutePath(), options);
-
-                        fragment_register_id_card_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(bitmap,
-                                (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp)));
-                        fragment_register_id_card_photo_img = bitmap;
-                        MainActivity.getInstance().getContentResolver().delete(Uri.fromFile(idCardImageCaptureFile), null, null);
-
-                        fragment_register_id_card_photo_placeholder_image.setVisibility(View.INVISIBLE);
-                        fragment_register_id_card_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-                        idCardImageCaptureFile = null;
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public void resetForm() {
-        selectedCustomPhotoId = -1;
-        selectedSurveillancePhotoId = -1;
-
-        idCardHeadPhotoPath = "";
-
-        fragment_register_name.setValue("寰愪慨婧�"+Math.random());
-        fragment_register_phone.setValue("13691348767");
-        fragment_register_id_num.setValue("36041419292222222");
-        fragment_register_birthday.setValue("1985-08-12");
-        fragment_register_company.setValue("璐濇�濈");
-        fragment_register_remark.setValue("澶囨敞");
-
-        fragment_register_name.setValue("");
-        fragment_register_id_num.setValue("");
-        fragment_register_birthday.setValue("");
-
-        fragment_register_gender.setValue("鐢�");
-        fragment_register_id_class.setValue("韬唤璇�");
-        fragment_register_country.setValue("涓浗");
-        fragment_register_visitor_class.setValue("鏅�氳瀹�");
-        fragment_register_surveillance_photo_img = null;
-        fragment_register_upload_custom_photo_img = null;
-        fragment_register_id_card_photo_img = null;
-        fragment_register_surveillance_photo.setImageBitmap(null);
-        fragment_register_upload_custom_photo.setImageBitmap(null);
-        fragment_register_id_card_photo.setImageBitmap(null);
-        fragment_register_surveillance_photo_placeholder_image.setVisibility(View.VISIBLE);
-        fragment_register_surveillance_photo_placeholder_text_view.setVisibility(View.VISIBLE);
-        fragment_register_upload_custom_photo_placeholder_image.setVisibility(View.VISIBLE);
-        fragment_register_upload_custom_photo_placeholder_text_view.setVisibility(View.VISIBLE);
-        fragment_register_id_card_photo_placeholder_image.setVisibility(View.VISIBLE);
-        fragment_register_id_card_photo_placeholder_text_view.setVisibility(View.VISIBLE);
-        this.surveillanceQueryItem_selectPhoto = null;
-        this.surveillanceQueryItem_uploadPhoto = null;
-    }
-
-    //@OnClick(R.id.fragment_register_country)
-    public void fragment_register_country_click(View view) {
-        new CountryDialog(fragment_register_linear_layout, new OkClickedListener() {
-            public void onSelected(String value) {
-                fragment_register_country.setValue(value);
-            }
-        },fragment_register_country.getValue());
-    }
-
-    //@OnClick(R.id.fragment_register_gender)
-    public void fragment_register_gender_click(View view) {
-        new SelectDialog(fragment_register_linear_layout, Constant.DialogSelectType.GENDER, new OkClickedListener() {
-            public void onSelected(String value) {
-                fragment_register_gender.setValue(value);
-            }
-        }, fragment_register_gender.getValue());
-    }
-
-    //@OnClick(R.id.fragment_register_birthday)
-    public void fragment_register_birthday_click(View view) {
-        String birthdayStr = fragment_register_birthday.getValue();
-        Date birthday = new Date();
-        if (birthdayStr != null && !"".equals(birthdayStr)) {
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-            try {
-                birthday = sdf.parse(birthdayStr);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-
-        new DateSelectDialog(
-                new OkClickedListener(){
-                    public void onSelected(String value) {
-                        fragment_register_birthday.setValue(value);
-                    }
-                }, birthday);
-    }
-
-    //@OnClick(R.id.fragment_register_visitor_class)
-    public void fragment_register_visitor_class_click(View view) {
-        new SelectDialog(fragment_register_linear_layout, Constant.DialogSelectType.VISITOR_TYPE, new OkClickedListener() {
-            public void onSelected(String value) {
-                fragment_register_visitor_class.setValue(value);
-            }
-        }, fragment_register_visitor_class.getValue());
-    }
-
-    //@OnClick(R.id.fragment_register_id_class)
-    public void fragment_register_id_class_click(View view) {
-        new SelectDialog(fragment_register_linear_layout, Constant.DialogSelectType.ID_TYPE, new OkClickedListener() {
-            public void onSelected(String value) {
-                fragment_register_id_class.setValue(value);
-            }
-        }, fragment_register_id_class.getValue());
-    }
-
-    @OnClick(R.id.fragment_register_back)
-    public void fragment_register_back_click(View view) {
-        MainActivity.selectPage(0);
-    }
-
-    @OnClick(R.id.fragment_register_surveillance_photo)
-    public void fragment_register_surveillance_photo_click(View view) {
-        SurveillanceFragment.SurveillancePhotoSelectListViewAdapter.selectPhotoOrUploadPhoto = CommonVariables.SelectPhotoType.SELECT_PHOTO;
-        new SurveillancePhotoDialog(fragment_register_linear_layout, Constant.DialogSelectType.ID_TYPE, new OkClickedListener() {
-            public void onSelected(String value) {
-            }
-        }, selectedSurveillancePhotoId);
-    }
-
-    @OnClick(R.id.fragment_register_upload_custom_photo)
-    public void fragment_register_upload_custom_photo_click(View view) {
-        SurveillanceFragment.SurveillancePhotoSelectListViewAdapter.selectPhotoOrUploadPhoto = CommonVariables.SelectPhotoType.UPLOAD_PHOTO;
-        new SurveillancePhotoDialog(fragment_register_linear_layout, Constant.DialogSelectType.ID_TYPE, new OkClickedListener() {
-            public void onSelected(String value) {
-            }
-        }, selectedCustomPhotoId);
-    }
-
-    @OnClick(R.id.fragment_register_id_card_photo)
-    public void fragment_register_id_card_photo_click(View view) {
-        Intent intent = new Intent();
-        intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
-        idCardImageCaptureFile = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis()+".jpg");
-        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(idCardImageCaptureFile));
-        startActivityForResult(intent, fragment_register_id_card_photo_);
-    }
-
-    @Override
-    public void onClick(View v) {}
-
-    public void setRegisterInfo(CheckInQueryItem item) {
-        fragment_register_surveillance_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE + item.getSurveillancePhoto()));
-    }
-
-    public ImageView get_fragment_register_choose_photo() {
-        return fragment_register_surveillance_photo;
-    }
-
-    public void setChoosePhoto(Bitmap bitmap) {
-        fragment_register_surveillance_photo.setImageBitmap(BitmapUtil.getRoundedCornerBitmap(bitmap,
-                (int)MainActivity.getInstance().getResources().getDimension(R.dimen.w10dp)));
-        fragment_register_surveillance_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
-        fragment_register_surveillance_photo_placeholder_image.setVisibility(View.INVISIBLE);
-    }
-
-    public void setSurveillanceQueryItem_selectPhoto(SurveillanceQueryItem item) {
-        this.surveillanceQueryItem_selectPhoto = item;
-    }
-
-    @Override
-    protected void initData() {
-        resetForm();
-        new ReadIdCardThread().start();
-    }
-
-    public void fillFormWithIdCard() {
-        try {
-            fragment_register_name.setValue(idCard_name);
-            fragment_register_id_num.setValue(idCard_idNumber);
-
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
-
-            fragment_register_birthday.setValue(sdf1.format(sdf.parse(idCard_birth)));
-            fragment_register_gender.setValue(idCard_sex);
-            fragment_register_id_class.setValue("韬唤璇�");
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, 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);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    private String idCard_name = "";
-    private String idCard_idNumber = "";
-    private String idCard_birth = "";
-    private String idCard_sex = "";
-
-    class ReadIdCardThread extends Thread {
-
-        @Override
-        public void run() {
-            while(true) {
-                try{
-                    Thread.sleep(1000);
-                    readIdCard();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-
-    public void readIdCard() {
-        try {
-            if (!registerFragmentVisible) {
-                return;
-            }
-
-            RFIDReader idCardReader = RFIDReader.getInstance(BaseApplication.getInstance(), "uart");
-            idCardReader.setUartDeviceName("/dev/ttyS1");
-            ByteArrayInputStream type = new ByteArrayInputStream("uart".getBytes());
-            idCardReader.control(ReaderExtra.CONNECT, type);
-
-            idCardReader.open("id_card");
-            String cardId = byteArrayToHexString(idCardReader.getUid());
-
-            idCardReader.open("id_sam");
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            idCardReader.control(ReaderExtra.ID_READ_TEXT_PHOTO, baos);
-            String textPhoto = byteArrayToHexString(baos.toByteArray());
-            if (textPhoto != null) {
-                final String[] decodeInfo = new String[10];
-                final StringBuilder imagePath = new StringBuilder();
-                String path = MainActivity.getInstance().getFilesDir().getAbsolutePath();
-                IDCReaderSDK.initialize(path);
-                IDCReaderSDK.decodeSamAck(textPhoto, decodeInfo, imagePath);
-                idCard_name = decodeInfo[0];
-                idCard_sex = decodeInfo[1];
-                idCard_idNumber = decodeInfo[5];
-                idCard_birth = decodeInfo[3];
-//                final String idCardNation = decodeInfo[2];
-//                final String idCardAddress = decodeInfo[4];
-//                final String idCardIssuingAuthority = decodeInfo[6];
-//                final String idCardValidBegin = decodeInfo[7];
-//                final String idCardValidEnd = decodeInfo[8];
-
-                idCardHeadPhotoPath = imagePath.toString();
-
-                if (fragment_register_surveillance_photo_img == null) {
-//                    MainActivity.getInstance().runOnUiThread(new Runnable() {
-//                        @Override
-//                        public void run() {
-//                            Toast.makeText(BaseApplication.getInstance(),"璇峰厛閫夋嫨浜虹墿鐓х墖", Toast.LENGTH_SHORT).show();
-//                        }
-//                    });
-                    //return;
-                    testComparePicturesWithJpeg();
-                } else {
-                    testComparePicturesWithJpeg();
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    private boolean registerFragmentVisible = false;
-
-    @Override
-    public void setMenuVisibility(boolean menuVisible) {
-        super.setMenuVisibility(menuVisible);
-        registerFragmentVisible = menuVisible;
-    }
-
-    private void testComparePicturesWithJpeg() {
-
-        RequestParams params = new RequestParams();
-
-        if (idCardHeadPhotoPath != null && !"".equals(idCardHeadPhotoPath)) {
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-
-            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
-            byte[] imageBytes = byteArrayOutputStream.toByteArray();
-
-            params.addBodyParameter("surveillancePhotoW",bitmap.getWidth()+"");
-            params.addBodyParameter("surveillancePhotoH",bitmap.getWidth()+"");
-            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", imageBytes));
-        } else {
-            params.addBodyParameter("surveillancePhotoW", "0");
-            params.addBodyParameter("surveillancePhotoH", "0");
-            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", new byte[]{}));
-        }
-
-
-        if (idCardHeadPhotoPath != null && !"".equals(idCardHeadPhotoPath)) {
-
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-
-            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
-            byte[] imageBytes = byteArrayOutputStream.toByteArray();
-
-            params.addBodyParameter("idCardPhotoW",bitmap.getWidth()+"");
-            params.addBodyParameter("idCardPhotoH",bitmap.getWidth()+"");
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", imageBytes));
-        } else {
-            params.addBodyParameter("idCardPhotoW","0");
-            params.addBodyParameter("idCardPhotoH","0");
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardHeadPhoto", new byte[]{}));
-        }
-
-        RegisterMng.getInstance().compareSurveillancePhotoAndIdCardPhoto(params);
-    }
-
-    private void testComparePicturesWithBmp() {
-
-        RequestParams params = new RequestParams();
-
-        if (idCardHeadPhotoPath != null && !"".equals(idCardHeadPhotoPath)) {
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-            params.addBodyParameter("surveillancePhotoW", bitmap.getWidth() + "");
-            params.addBodyParameter("surveillancePhotoH", bitmap.getWidth() + "");
-            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", readFile(new File(idCardHeadPhotoPath))));
-        } else {
-            params.addBodyParameter("surveillancePhotoW", "0");
-            params.addBodyParameter("surveillancePhotoH", "0");
-            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", new byte[]{}));
-        }
-
-
-        if (idCardHeadPhotoPath != null && !"".equals(idCardHeadPhotoPath)) {
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-
-
-            params.addBodyParameter("idCardPhotoW",bitmap.getWidth()+"");
-            params.addBodyParameter("idCardPhotoH",bitmap.getWidth()+"");
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", readFile(new File(idCardHeadPhotoPath))));
-        } else {
-            params.addBodyParameter("idCardPhotoW","0");
-            params.addBodyParameter("idCardPhotoH","0");
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", new byte[]{}));
-        }
-
-        RegisterMng.getInstance().compareSurveillancePhotoAndIdCardPhoto(params);
-    }
-
-    private void comparePictures() {
-
-        RequestParams params = new RequestParams();
-
-//        if (fragment_register_surveillance_photo_img != null) {
-//            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-//            fragment_register_surveillance_photo_img.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
-//            byte[] imageBytes = byteArrayOutputStream.toByteArray();
+    public void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+//        FragmentManager fragmentManager =  MainActivity.getInstance().getSupportFragmentManager();
+//        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
 //
-//            params.addBodyParameter("surveillancePhotoW",fragment_register_surveillance_photo_img.getWidth()+"");
-//            params.addBodyParameter("surveillancePhotoH",fragment_register_surveillance_photo_img.getHeight()+"");
+//        fragmentTransaction.replace(R.id.fragment_register_linear_layout, VisitorRegisterFragment.getInstance());
 //
-//            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", imageBytes));
-//        } else {
-//            params.addBodyParameter("surveillancePhotoW","0");
-//            params.addBodyParameter("surveillancePhotoH","0");
-//            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", new byte[]{}));
-//        }
-
-        if (idCardHeadPhotoPath != null && !"".equals(idCardHeadPhotoPath)) {
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-
-            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
-            byte[] imageBytes = byteArrayOutputStream.toByteArray();
-
-            params.addBodyParameter("surveillancePhotoW",bitmap.getWidth()+"");
-            params.addBodyParameter("surveillancePhotoH",bitmap.getWidth()+"");
-            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", imageBytes));
-
-
-            ///////////////////////////////////
+//        fragmentTransaction.commit();
 
 
 
-            /////////////////////////////////
-//            BitmapFactory.Options options = new BitmapFactory.Options();
-//            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-//            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-//            params.addBodyParameter("surveillancePhotoW", bitmap.getWidth() + "");
-//            params.addBodyParameter("surveillancePhotoH", bitmap.getWidth() + "");
-//            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", readFile(new File(idCardHeadPhotoPath))));
-        } else {
-            params.addBodyParameter("surveillancePhotoW", "0");
-            params.addBodyParameter("surveillancePhotoH", "0");
-            params.addBodyParameter("surveillancePhoto", writeToFile("surveillancePhoto", new byte[]{}));
-        }
-
-
-        if (idCardHeadPhotoPath != null && !"".equals(idCardHeadPhotoPath)) {
-
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-
-            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
-            byte[] imageBytes = byteArrayOutputStream.toByteArray();
-
-            params.addBodyParameter("idCardPhotoW",bitmap.getWidth()+"");
-            params.addBodyParameter("idCardPhotoH",bitmap.getWidth()+"");
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", imageBytes));
-
-
-            ///////////////////////////////////
-
-//            BitmapFactory.Options options = new BitmapFactory.Options();
-//            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
-//            Bitmap bitmap = BitmapFactory.decodeFile(idCardHeadPhotoPath, options);
-//
-//
-//            params.addBodyParameter("idCardPhotoW",bitmap.getWidth()+"");
-//            params.addBodyParameter("idCardPhotoH",bitmap.getWidth()+"");
-//            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", readFile(new File(idCardHeadPhotoPath))));
-        } else {
-            params.addBodyParameter("idCardPhotoW","0");
-            params.addBodyParameter("idCardPhotoH","0");
-            params.addBodyParameter("idCardPhoto", writeToFile("idCardPhoto", new byte[]{}));
-        }
-
-        RegisterMng.getInstance().compareSurveillancePhotoAndIdCardPhoto(params);
     }
 
-    protected static final char[] a = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-    public static String byteArrayToHexString(byte[] bytes) {
-        if(bytes == null) {
-            return null;
-        } else {
-            char[] hexChars = new char[bytes.length * 2];
-
-            for(int j = 0; j < bytes.length; ++j) {
-                int v = bytes[j] & 255;
-                hexChars[j * 2] = a[v >>> 4];
-                hexChars[j * 2 + 1] = a[v & 15];
-            }
-
-            return new String(hexChars);
-        }
+    @OnClick(R.id.test)
+    public void test(View view) {
+        //MainActivity.getInstance().myFragmentPagerAdapter.setFragment(1, VisitorRegisterFragment.getInstance());
     }
-    public static byte[] readFile(File file) {
-        // Open file
-        RandomAccessFile f = null;
-        try {
-            f = new RandomAccessFile(file, "r");
-            // Get and check length
-            long longlength = f.length();
-            int length = (int) longlength;
-            if (length != longlength)
-                throw new IOException("File size >= 2 GB");
-            // Read file and return data
-            byte[] data = new byte[length];
-            f.readFully(data);
-            return data;
-        } catch (Exception e){
-            e.printStackTrace();
-        } finally {
-            try {
-                f.close();
-            }catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        return new byte[]{};
-    }
-
 
 }

--
Gitblit v1.8.0