| | |
| | |
|
| | | import android.app.Activity;
|
| | | import android.content.Intent;
|
| | | import android.database.Cursor;
|
| | | import android.graphics.Bitmap;
|
| | | import android.net.Uri;
|
| | | import android.provider.MediaStore;
|
| | | import android.util.Base64;
|
| | | import android.view.View;
|
| | | import android.widget.ImageView;
|
| | | import android.widget.LinearLayout;
|
| | | import android.widget.TextView;
|
| | | import android.widget.Toast;
|
| | |
|
| | | import com.bsk.zhangbo.demoforbsk.R;
|
| | |
| | | import cn.com.basic.face.discern.query.item.CheckInQueryItem;
|
| | | 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.Constant;
|
| | | import cn.com.basic.face.util.OkClickedListener;
|
| | |
|
| | |
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | |
|
| | | import java.io.ByteArrayOutputStream;
|
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | |
|
| | |
| | | @ViewInject(R.id.fragment_register_remark)
|
| | | private RegisterRightFieldTextView fragment_register_remark;
|
| | | @ViewInject(R.id.fragment_register_choose_photo)
|
| | | private SimpleDraweeView fragment_register_choose_photo;
|
| | | private ImageView fragment_register_choose_photo;
|
| | | @ViewInject(R.id.fragment_register_update_photo)
|
| | | private ImageView fragment_register_update__photo;
|
| | | private ImageView fragment_register_update_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;
|
| | |
|
| | | private static final int PICK_IMAGE_REQUEST = 1;
|
| | | @ViewInject(R.id.fragment_register_choose_photo_placeholder_image)
|
| | | private ImageView fragment_register_choose_photo_placeholder_image;
|
| | | @ViewInject(R.id.fragment_register_update_photo_placeholder_image)
|
| | | private ImageView fragment_register_update_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_choose_photo_placeholder_text_view)
|
| | | private TextView fragment_register_choose_photo_placeholder_text_view;
|
| | | @ViewInject(R.id.fragment_register_update_photo_placeholder_text_view)
|
| | | private TextView fragment_register_update_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_choose_photo_ = 1;
|
| | | private static final int fragment_register_update_photo_ = 2;
|
| | | private static final int fragment_register_id_card_photo_ = 3;
|
| | |
|
| | | private Bitmap fragment_register_choose_photo_img;
|
| | | private Bitmap fragment_register_update_photo_img;
|
| | | private Bitmap fragment_register_id_card_photo_img;
|
| | |
|
| | | private static RegisterFragment instance = new RegisterFragment();
|
| | |
|
| | |
| | | params.addBodyParameter(Register.FieldNames.companyId, company);
|
| | | params.addBodyParameter(Register.FieldNames.birthday, birthday);
|
| | |
|
| | | if (fragment_register_choose_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | fragment_register_choose_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
|
| | | byte[] imageBytes = byteArrayOutputStream.toByteArray();
|
| | | String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
|
| | | params.addBodyParameter("choosePhoto", encodedImage);
|
| | | }
|
| | |
|
| | | if (fragment_register_update_photo_img != null) {
|
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| | | fragment_register_update_photo_img.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
|
| | | byte[] imageBytes = byteArrayOutputStream.toByteArray();
|
| | | String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
|
| | | params.addBodyParameter("uploadPhoto", encodedImage);
|
| | | }
|
| | |
|
| | | 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();
|
| | | String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
|
| | | params.addBodyParameter("idPhoto", encodedImage);
|
| | | }
|
| | |
|
| | | RegisterMng.getInstance().add(params);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
| | | super.onActivityResult(requestCode, resultCode, data);
|
| | |
|
| | | if (requestCode == PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
|
| | | if (requestCode == fragment_register_choose_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_update__photo.setImageBitmap(bitmap);
|
| | | } catch (IOException e) {
|
| | | fragment_register_choose_photo.setImageBitmap(bitmap);
|
| | | fragment_register_choose_photo_img = bitmap;
|
| | |
|
| | | fragment_register_choose_photo_placeholder_image.setVisibility(View.INVISIBLE);
|
| | | fragment_register_choose_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (requestCode == fragment_register_update_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_update_photo.setImageBitmap(bitmap);
|
| | | fragment_register_update_photo_img = bitmap;
|
| | |
|
| | | fragment_register_update_photo_placeholder_image.setVisibility(View.INVISIBLE);
|
| | | fragment_register_update_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
|
| | |
|
| | | List<Bitmap> bitmapList = new ArrayList<>();
|
| | | bitmapList.add(0, bitmap);
|
| | |
|
| | | SurveillanceMng.getInstance().addBitmap(bitmapList, null, 0);
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (requestCode == fragment_register_id_card_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_id_card_photo.setImageBitmap(bitmap);
|
| | | fragment_register_id_card_photo_img = 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();
|
| | | }
|
| | | }
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | @OnClick(R.id.fragment_register_back)
|
| | | public void fragment_register_back_click(View view) {
|
| | | MainActivity.selectPage(0);
|
| | | }
|
| | |
|
| | | @OnClick(R.id.fragment_register_choose_photo)
|
| | | public void fragment_register_choose_photo_click(View view) {
|
| | | Toast.makeText(getActivity(), "选择人物快照", Toast.LENGTH_SHORT).show();
|
| | | Intent intent = new Intent();
|
| | | intent.setType("image/*");
|
| | | intent.setAction(Intent.ACTION_GET_CONTENT);
|
| | | startActivityForResult(Intent.createChooser(intent, "选择图片"), fragment_register_choose_photo_);
|
| | | }
|
| | |
|
| | | @OnClick(R.id.fragment_register_update_photo)
|
| | |
| | | Intent intent = new Intent();
|
| | | intent.setType("image/*");
|
| | | intent.setAction(Intent.ACTION_GET_CONTENT);
|
| | | startActivityForResult(Intent.createChooser(intent, "选择图片"), PICK_IMAGE_REQUEST);
|
| | | }
|
| | |
|
| | | @OnClick(R.id.fragment_register_back)
|
| | | public void fragment_register_back_click(View view) {
|
| | | MainActivity.selectPage(0);
|
| | | startActivityForResult(Intent.createChooser(intent, "选择图片"), fragment_register_update_photo_);
|
| | | }
|
| | |
|
| | | @OnClick(R.id.fragment_register_id_card_photo)
|
| | | public void fragment_register_id_card_photo_click(View view) {
|
| | | Toast.makeText(getActivity(), "证件快照", Toast.LENGTH_SHORT).show();
|
| | | Intent intent = new Intent();
|
| | | intent.setType("image/*");
|
| | | intent.setAction(Intent.ACTION_GET_CONTENT);
|
| | | startActivityForResult(Intent.createChooser(intent, "选择图片"), fragment_register_id_card_photo_);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onClick(View v) {}
|
| | |
|
| | | public void setRegisterInfo(CheckInQueryItem item) {
|
| | | fragment_register_choose_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE + item.getImagePath()));
|
| | | fragment_register_choose_photo.setImageURI(Uri.parse(AppApi.IMAGE_URL_BASE + item.getSurveillancePhoto()));
|
| | | }
|
| | |
|
| | | public ImageView get_fragment_register_choose_photo() {
|
| | | return fragment_register_choose_photo;
|
| | | }
|
| | |
|
| | | public void setChoosePhoto(Bitmap bitmap) {
|
| | | fragment_register_choose_photo.setImageBitmap(bitmap);
|
| | | fragment_register_choose_photo_placeholder_text_view.setVisibility(View.INVISIBLE);
|
| | | fragment_register_choose_photo_placeholder_image.setVisibility(View.INVISIBLE);
|
| | | }
|
| | |
|
| | | }
|