| | |
| | | package com.bsk.zhangbo.demoforbsk.ui.fragment;
|
| | |
|
| | | import android.app.Activity;
|
| | | import android.content.Intent;
|
| | | import android.graphics.Bitmap;
|
| | | import android.net.Uri;
|
| | | import android.os.Bundle;
|
| | | import android.provider.MediaStore;
|
| | | import android.view.Gravity;
|
| | | import android.view.View;
|
| | | import android.widget.DatePicker;
|
| | | import android.widget.EditText;
|
| | | import android.widget.ImageView;
|
| | | import android.widget.LinearLayout;
|
| | | import android.widget.TextView;
|
| | | import android.widget.Toast;
|
| | |
| | | import com.bsk.zhangbo.demoforbsk.R;
|
| | | import com.bsk.zhangbo.demoforbsk.base.BaseFragment;
|
| | | import com.bsk.zhangbo.demoforbsk.service.DictionaryMng;
|
| | | import com.bsk.zhangbo.demoforbsk.service.RegisterMng;
|
| | | import com.bsk.zhangbo.demoforbsk.service.VisitorTypeMng;
|
| | | import com.bsk.zhangbo.demoforbsk.listeners.OkButtonClickedListener;
|
| | | import com.bsk.zhangbo.demoforbsk.ui.activity.MainActivity;
|
| | | import com.bsk.zhangbo.demoforbsk.widget.BirthdayPickerDialog;
|
| | | import com.bsk.zhangbo.demoforbsk.widget.CountrySelectionPopup;
|
| | | import com.bsk.zhangbo.demoforbsk.widget.SingleSelectionPopup;
|
| | |
| | | import com.lidroid.xutils.view.annotation.ViewInject;
|
| | | import com.lidroid.xutils.view.annotation.event.OnClick;
|
| | |
|
| | | import java.util.Calendar;
|
| | | import org.xutils.http.RequestParams;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.discern.entity.Person;
|
| | |
| | | //@ContentView(value = R.layout.fragment_register)
|
| | | public class RegisterFragment extends BaseFragment implements View.OnClickListener{
|
| | |
|
| | | private static final int PICK_IMAGE_REQUEST = 1;
|
| | | @ViewInject(value = R.id.register_tv_content, parentId = R.id.register_id_class)
|
| | | private TextView mViewIdentityTypeContent;
|
| | | private TextView mViewGenderContent;
|
| | | private TextView mViewCountryContent;
|
| | | private TextView mViewBirthdyContent;
|
| | | private TextView mViewVisitorClassContent;
|
| | | private TextView identityTypeTv;
|
| | | private TextView genderTv;
|
| | | private TextView countryTv;
|
| | | private TextView birthdayTv;
|
| | | private TextView isitorvTypeTv;
|
| | | private TextView mViewVisitorClassTitle;
|
| | |
|
| | | private EditText mViewNameContent,mViewPhoneContent, mViewIdentityContent,mViewCompanyNameContent,mViewRemarkContent;
|
| | | private EditText nameEt, phoneEt, identifyEt, companyEt,mViewRemarkContent;
|
| | | private List mSexList;
|
| | | private List mVisitorTypeList;
|
| | | private List mCredentialsList;
|
| | |
| | | @ViewInject(R.id.register_remark)
|
| | | private View mViewRemark;
|
| | |
|
| | | public static RegisterFragment newInstance() {
|
| | | return new RegisterFragment();
|
| | | private String[] countryWordData;
|
| | | private List<String> countryWordList;
|
| | | private HashMap<String, List<String>> countryData;
|
| | |
|
| | | private static RegisterFragment instance = new RegisterFragment();
|
| | |
|
| | | public static RegisterFragment getInstance() {
|
| | | return instance;
|
| | | }
|
| | | @Override
|
| | | protected int getLayoutId() {
|
| | |
| | | mBaseLayout = (LinearLayout) view.findViewById(R.id.register_base);
|
| | | ViewUtils.inject(this, mBaseLayout);
|
| | |
|
| | | mViewGenderContent = (TextView) mViewSex.findViewById(R.id.register_tv_content);
|
| | | mViewCountryContent = (TextView) mViewNation.findViewById(R.id.register_tv_content);
|
| | | mViewBirthdyContent= (TextView) mViewBirthday.findViewById(R.id.register_tv_content);
|
| | | mViewVisitorClassContent = (TextView) mViewVisitorClass.findViewById(R.id.register_tv_content);
|
| | | genderTv = (TextView) mViewSex.findViewById(R.id.register_tv_content);
|
| | | countryTv = (TextView) mViewNation.findViewById(R.id.register_tv_content);
|
| | | birthdayTv= (TextView) mViewBirthday.findViewById(R.id.register_tv_content);
|
| | | isitorvTypeTv = (TextView) mViewVisitorClass.findViewById(R.id.register_tv_content);
|
| | | // mViewIdentityTypeContent = (TextView) mViewIdClass.findViewById(R.id.register_tv_content);
|
| | | mViewNameContent = (EditText) mViewName.findViewById(R.id.register_et_content);
|
| | | mViewPhoneContent = (EditText) mViewPhone.findViewById(R.id.register_et_content);
|
| | | mViewIdentityContent = (EditText) mViewIdNumber.findViewById(R.id.register_et_content);
|
| | | mViewCompanyNameContent = (EditText) mViewCompayName.findViewById(R.id.register_et_content);
|
| | | nameEt = (EditText) mViewName.findViewById(R.id.register_et_content);
|
| | | phoneEt = (EditText) mViewPhone.findViewById(R.id.register_et_content);
|
| | | identifyEt = (EditText) mViewIdNumber.findViewById(R.id.register_et_content);
|
| | | companyEt = (EditText) mViewCompayName.findViewById(R.id.register_et_content);
|
| | | mViewRemarkContent = (EditText) mViewRemark.findViewById(R.id.register_et_content);
|
| | |
|
| | | ((TextView) mViewName.findViewById(R.id.register_et_title)).setText(R.string.title_name);
|
| | |
| | | ((TextView) mViewIdNumber.findViewById(R.id.register_et_title)).setText(R.string.title_idNumber);
|
| | | ((TextView) mViewCompayName.findViewById(R.id.register_et_title)).setText(R.string.title_companyName);
|
| | | ((TextView) mViewRemark.findViewById(R.id.register_et_title)).setText(R.string.title_remark);
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_save)
|
| | |
| | |
|
| | | @OnClick(R.id.register_add)
|
| | | public void registerAdd(View v) {
|
| | | Person person = new Person();
|
| | | // person.setBirthday(mViewBirthdyContent.getText());
|
| | | person.setName(mViewNameContent.getText().toString());
|
| | | person.setPhone(mViewPhoneContent.getText().toString());
|
| | | person.setGender(DictionaryMng.getInstance().getId(mViewGenderContent.getText().toString()));
|
| | | person.setIdentityType(DictionaryMng.getInstance().getId(mViewIdentityTypeContent.getText().toString()));
|
| | | person.setCountry(DictionaryMng.getInstance().getId(mViewCountryContent.getText().toString()));
|
| | | person.setIdentify(mViewIdentityContent.getText().toString());
|
| | | person.setBirthday(mViewBirthdyContent.getText().toString());
|
| | | //person.setCompanyId();
|
| | | RequestParams params = new RequestParams();
|
| | |
|
| | | VisitPersonType visitPersonType = new VisitPersonType();
|
| | | // visitPersonType.setRegisterCompanyId();
|
| | | visitPersonType.setVisitorTypeId(VisitorTypeMng.getInstance().getId(mViewVisitorClassContent.getText().toString()));
|
| | | VisitorTypeMng.getInstance().add(person, visitPersonType);
|
| | | params.addBodyParameter(Person.FieldNames.name, nameEt.getText().toString());
|
| | | params.addBodyParameter(Person.FieldNames.phone, phoneEt.getText().toString());
|
| | | params.addBodyParameter(Person.FieldNames.gender, DictionaryMng.getInstance().getId(genderTv.getText().toString()));
|
| | | params.addBodyParameter(Person.FieldNames.identityType, DictionaryMng.getInstance().getId(identityTypeTv.getText().toString()));
|
| | | params.addBodyParameter(Person.FieldNames.country, DictionaryMng.getInstance().getId(countryTv.getText().toString()));
|
| | | params.addBodyParameter(Person.FieldNames.identify, identifyEt.getText().toString());
|
| | | params.addBodyParameter(Person.FieldNames.birthday, birthdayTv.getText().toString());
|
| | | params.addBodyParameter("companyName", companyEt.getText().toString());
|
| | |
|
| | | //visitor_type
|
| | | params.addBodyParameter(VisitPersonType.FieldNames.visitorTypeId, VisitorTypeMng.getInstance().getId(isitorvTypeTv.getText().toString()));
|
| | | params.addBodyParameter(VisitPersonType.FieldNames.registerCompanyId, "0");
|
| | |
|
| | | RegisterMng.getInstance().add(params);
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void initData() {
|
| | | mVisitorTypeList = VisitorTypeMng.mVisitorTypeList;
|
| | | mSexList = DictionaryMng.mSexList;
|
| | | mCredentialsList = DictionaryMng.mCredentialsList;
|
| | | // mVisitorTypeList = VisitorTypeMng.mVisitorTypeList;
|
| | | // mSexList = DictionaryMng.mSexList;
|
| | | // mCredentialsList = DictionaryMng.mCredentialsList;
|
| | | }
|
| | |
|
| | | public void setVisitorTypeList(List visitorTypeList) {
|
| | | this.mVisitorTypeList = visitorTypeList;
|
| | | }
|
| | |
|
| | | public void setSexList(List sexList) {
|
| | | this.mSexList = sexList;
|
| | | }
|
| | |
|
| | | public void setCredentialsList(List credentialsList) {
|
| | | this.mCredentialsList = credentialsList;
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_gender)
|
| | |
| | | popup.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewGenderContent.setText(item);
|
| | | genderTv.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void setCountryData(String[] countryWordData, List<String> countryWordList, HashMap<String, List<String>> countryData) {
|
| | | this.countryData = countryData;
|
| | | this.countryWordList = countryWordList;
|
| | | this.countryData = countryData;
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_country)
|
| | | public void selectCountry(View view) {
|
| | | CountrySelectionPopup countrySelectionPopup = new CountrySelectionPopup(getActivity());
|
| | | CountrySelectionPopup countrySelectionPopup = new CountrySelectionPopup(getActivity(),
|
| | | countryWordData,countryWordList,countryData);
|
| | | countrySelectionPopup.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | countrySelectionPopup.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewCountryContent.setText(item);
|
| | | countryTv.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | @Override
|
| | | public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
| | | int month=monthOfYear+1;
|
| | | mViewBirthdyContent.setText(year+"-"+month+"-"+dayOfMonth);
|
| | | birthdayTv.setText(year+"-"+month+"-"+dayOfMonth);
|
| | | }
|
| | | },date);
|
| | | myDatePickerDialog.myShow();
|
| | |
| | | popup1.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewVisitorClassContent.setText(item);
|
| | | isitorvTypeTv.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | popup2.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewIdentityTypeContent.setText(item);
|
| | | identityTypeTv.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | */
|
| | | @OnClick(R.id.register_update__photo)
|
| | | public void clickUploadPhoto(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, "选择图片"), PICK_IMAGE_REQUEST);
|
| | | }
|
| | |
|
| | | @ViewInject(R.id.register_update__photo)
|
| | | private ImageView ploadPhotoIv;
|
| | |
|
| | | @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) {
|
| | |
|
| | | Uri uri = data.getData();
|
| | |
|
| | | try {
|
| | | Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), uri);
|
| | | // Log.d(TAG, String.valueOf(bitmap));u
|
| | | ploadPhotoIv.setImageBitmap(bitmap);
|
| | | // ImageView imageView = (ImageView) findViewById(R.id.imageView);
|
| | | // imageView.setImageBitmap(bitmap);
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | Toast.makeText(getActivity(), "证件快照", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_back)
|
| | | public void back(View view) {
|
| | | MainActivity.selectPage(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onClick(View v) {}
|
| | |
|