| | |
| | | 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.BaseApplication;
|
| | | import com.bsk.zhangbo.demoforbsk.base.BaseFragment;
|
| | | import com.bsk.zhangbo.demoforbsk.service.DictionaryMng;
|
| | | import com.bsk.zhangbo.demoforbsk.service.VisitorTypeMng;
|
| | | import com.bsk.zhangbo.demoforbsk.listeners.OkButtonClickedListener;
|
| | | import com.bsk.zhangbo.demoforbsk.util.AppApi;
|
| | | 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.ViewUtils;
|
| | | import com.lidroid.xutils.view.annotation.ViewInject;
|
| | | import com.lidroid.xutils.view.annotation.event.OnClick;
|
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | | import org.xutils.view.annotation.ContentView;
|
| | | import org.xutils.x;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import cn.com.basic.face.discern.common.BaseCommonCallBack;
|
| | | import cn.com.basic.face.discern.common.CommonVariables;
|
| | | import cn.com.basic.face.discern.entity.Dictionary;
|
| | | import cn.com.basic.face.discern.query.item.VistorTypeQueryItem;
|
| | | import cn.com.basic.face.discern.entity.Person;
|
| | | import cn.com.basic.face.discern.entity.VisitPersonType;
|
| | |
|
| | | /**
|
| | | * Created by Administrator on 2017/2/20 0020.
|
| | | */
|
| | |
|
| | | //@ContentView(value = R.layout.fragment_register)
|
| | | public class RegisterFragment extends BaseFragment implements View.OnClickListener{
|
| | |
|
| | | private View mViewName,mViewSex,mViewNation,mViewBirthday,mViewVisitorClass,mViewPhone,mViewIdClass,mViewIdNumber,mViewCompayName,mViewRemark;
|
| | | private TextView mViewNameTitle,mViewSexTitle,mViewNationTitle,mViewBirthdyTitle,mViewIdClassContent,mViewSexContent,mViewNationContent,mViewBirthdyContent,mViewVisitorClassContent,mViewVisitorClassTitle,mViewPhoneTitle,mViewIdClassTitle,mViewIdNumberTitle,mViewCompanyNameTitle,mViewRemarkTitle;
|
| | | private EditText mViewNameContent,mViewPhoneContent,mViewIdNumberContent,mViewCompanyNameContent,mViewRemarkContent;
|
| | | @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 mViewVisitorClassTitle;
|
| | |
|
| | | private EditText mViewNameContent,mViewPhoneContent, mViewIdentityContent,mViewCompanyNameContent,mViewRemarkContent;
|
| | | private List mSexList;
|
| | | private List mVisitorTypeList;
|
| | | private List mCredentialsList;
|
| | | private LinearLayout mBaseLayout;
|
| | | private int mNowYear;
|
| | | private int mNowMonth;
|
| | | private int mNowDay;
|
| | |
|
| | | @ViewInject(R.id.register_name)
|
| | | private View mViewName;
|
| | | @ViewInject(R.id.register_sex)
|
| | | private View mViewSex;
|
| | | @ViewInject(R.id.register_nation)
|
| | | private View mViewNation;
|
| | | @ViewInject(R.id.register_birthday)
|
| | | private View mViewBirthday;
|
| | | @ViewInject(R.id.register_visitor_class)
|
| | | private View mViewVisitorClass;
|
| | | @ViewInject(R.id.register_phone)
|
| | | private View mViewPhone;
|
| | | @ViewInject(R.id.register_id_class)
|
| | | private View mViewIdClass;
|
| | | @ViewInject(R.id.register_id_num)
|
| | | private View mViewIdNumber;
|
| | | @ViewInject(R.id.register_company)
|
| | | private View mViewCompayName;
|
| | | @ViewInject(R.id.register_remark)
|
| | | private View mViewRemark;
|
| | |
|
| | | public static RegisterFragment newInstance() {
|
| | | return new RegisterFragment();
|
| | |
| | | @Override
|
| | | protected void initViews(View view, Bundle savedInstanceState) {
|
| | | mBaseLayout = (LinearLayout) view.findViewById(R.id.register_base);
|
| | | mViewName = view.findViewById(R.id.register_name);
|
| | | mViewSex = view.findViewById(R.id.register_sex);
|
| | | mViewNation = view.findViewById(R.id.register_nation);
|
| | | mViewBirthday = view.findViewById(R.id.register_birthday);
|
| | | mViewVisitorClass = view.findViewById(R.id.register_visitor_class);
|
| | | mViewPhone = view.findViewById(R.id.register_phone);
|
| | | mViewIdClass = view.findViewById(R.id.register_id_class);
|
| | | mViewIdNumber = view.findViewById(R.id.register_id_num);
|
| | | mViewCompayName = view.findViewById(R.id.register_company);
|
| | | mViewRemark = view.findViewById(R.id.register_remark);
|
| | | ViewUtils.inject(this, mBaseLayout);
|
| | |
|
| | | mViewNameTitle = (TextView) mViewName.findViewById(R.id.register_et_title);
|
| | | mViewSexTitle = (TextView) mViewSex.findViewById(R.id.register_tv_title);
|
| | | mViewNationTitle = (TextView) mViewNation.findViewById(R.id.register_tv_title);
|
| | | mViewBirthdyTitle = (TextView) mViewBirthday.findViewById(R.id.register_tv_title);
|
| | | mViewVisitorClassTitle = (TextView) mViewVisitorClass.findViewById(R.id.register_tv_title);
|
| | | mViewPhoneTitle = (TextView) mViewPhone.findViewById(R.id.register_et_title);
|
| | | mViewIdClassTitle = (TextView) mViewIdClass.findViewById(R.id.register_tv_title);
|
| | | mViewIdNumberTitle = (TextView) mViewIdNumber.findViewById(R.id.register_et_title);
|
| | | mViewCompanyNameTitle = (TextView) mViewCompayName.findViewById(R.id.register_et_title);
|
| | | mViewRemarkTitle = (TextView) mViewRemark.findViewById(R.id.register_et_title);
|
| | | mViewSexContent = (TextView) mViewSex.findViewById(R.id.register_tv_content);
|
| | | mViewNationContent = (TextView) mViewNation.findViewById(R.id.register_tv_content);
|
| | | 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);
|
| | | mViewIdClassContent= (TextView) mViewIdClass.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);
|
| | | mViewIdNumberContent = (EditText) mViewIdNumber.findViewById(R.id.register_et_content);
|
| | | mViewIdentityContent = (EditText) mViewIdNumber.findViewById(R.id.register_et_content);
|
| | | mViewCompanyNameContent = (EditText) mViewCompayName.findViewById(R.id.register_et_content);
|
| | | mViewRemarkContent = (EditText) mViewRemark.findViewById(R.id.register_et_content);
|
| | |
|
| | |
|
| | | mViewNameTitle.setText(R.string.title_name);
|
| | | mViewSexTitle.setText(R.string.title_sex);
|
| | | mViewNationTitle.setText(R.string.title_nation);
|
| | | mViewBirthdyTitle.setText(R.string.title_birthday);
|
| | | mViewVisitorClassTitle.setText(R.string.title_visitorClass);
|
| | | mViewPhoneTitle.setText(R.string.title_phone);
|
| | | mViewIdClassTitle.setText(R.string.title_idClass);
|
| | | mViewIdNumberTitle.setText(R.string.title_idNumber);
|
| | | mViewCompanyNameTitle.setText(R.string.title_companyName);
|
| | | mViewRemarkTitle.setText(R.string.title_remark);
|
| | | ((TextView) mViewName.findViewById(R.id.register_et_title)).setText(R.string.title_name);
|
| | | ((TextView) mViewSex.findViewById(R.id.register_tv_title)).setText(R.string.title_sex);
|
| | | ((TextView) mViewNation.findViewById(R.id.register_tv_title)).setText(R.string.title_nation);
|
| | | ((TextView) mViewBirthday.findViewById(R.id.register_tv_title)).setText(R.string.title_birthday);
|
| | | ((TextView) mViewVisitorClass.findViewById(R.id.register_tv_title)).setText(R.string.title_visitorClass);
|
| | | ((TextView) mViewPhone.findViewById(R.id.register_et_title)).setText(R.string.title_phone);
|
| | | ((TextView) mViewIdClass.findViewById(R.id.register_tv_title)).setText(R.string.title_idClass);
|
| | | ((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();
|
| | | mNowYear = calendar.get(Calendar.YEAR);
|
| | | mNowMonth = calendar.get(Calendar.MONTH);
|
| | | mNowDay = calendar.get(Calendar.DAY_OF_MONTH);
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void initToolbar(Bundle savedInstanceState) {
|
| | | @OnClick(R.id.register_save)
|
| | | public void registerEdit() {
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void initListeners() {
|
| | | mViewSex.setOnClickListener(this);
|
| | | mViewNation.setOnClickListener(this);
|
| | | mViewBirthday.setOnClickListener(this);
|
| | | mViewVisitorClass.setOnClickListener(this);
|
| | | mViewIdClass.setOnClickListener(this);
|
| | | @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();
|
| | |
|
| | | VisitPersonType visitPersonType = new VisitPersonType();
|
| | | // visitPersonType.setRegisterCompanyId();
|
| | | visitPersonType.setVisitorTypeId(VisitorTypeMng.getInstance().getId(mViewVisitorClassTitle.getText().toString()));
|
| | | VisitorTypeMng.getInstance().add(person, visitPersonType);
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | protected void initData() {
|
| | | loadVisitorTypeList();
|
| | |
|
| | | loadSexList();
|
| | |
|
| | | loadCredentialsList();
|
| | |
|
| | | mVisitorTypeList = VisitorTypeMng.mVisitorTypeList;
|
| | | mSexList = DictionaryMng.mSexList;
|
| | | mCredentialsList = DictionaryMng.mCredentialsList;
|
| | | }
|
| | |
|
| | | private void loadCredentialsList() {
|
| | | mCredentialsList = new ArrayList<>();
|
| | | mCredentialsList.add("名片");
|
| | | mCredentialsList.add("身份证");
|
| | |
|
| | | mViewIdClassContent.setText(""+mCredentialsList.get(0));
|
| | | }
|
| | |
|
| | | private void loadSexList() {
|
| | | RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.DICTIONARY_TYPE_LIST);
|
| | | params.addParameter(Dictionary.FieldNames.type, CommonVariables.DictionaryType.SEX);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | mSexList = getList(Dictionary.class);
|
| | | mViewVisitorClassContent.setText(((Dictionary)mSexList.get(0)).getName()+"");
|
| | | @OnClick(R.id.register_sex)
|
| | | public void selectGender(View view) {
|
| | | SingleSelectionPopup popup = new SingleSelectionPopup(getActivity(),mSexList,"性别");
|
| | | popup.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | popup.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewGenderContent.setText(item);
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | private void loadVisitorTypeList() {
|
| | | RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.VISITOR_TYPE_LIST);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<VistorTypeQueryItem> items = getList(VistorTypeQueryItem.class);
|
| | | mVisitorTypeList = new ArrayList<String>();
|
| | | mViewVisitorClassContent.setText(items.get(0).getLabel());
|
| | | for (VistorTypeQueryItem item : items) {
|
| | | mVisitorTypeList.add(item.getLabel());
|
| | | }
|
| | | @OnClick(R.id.register_nation)
|
| | | public void selectCountry(View view) {
|
| | | CountrySelectionPopup countrySelectionPopup = new CountrySelectionPopup(getActivity());
|
| | | countrySelectionPopup.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | countrySelectionPopup.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewCountryContent.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_birthday)
|
| | | public void selectBirthday(View view) {
|
| | | showDatePicker();
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_visitor_class)
|
| | | public void selectVisitorType(View view) {
|
| | | SingleSelectionPopup popup1 = new SingleSelectionPopup(getActivity(),mVisitorTypeList,"访客类型");
|
| | | popup1.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | popup1.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewVisitorClassContent.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @OnClick(R.id.register_id_class)
|
| | | public void selectIdentityType(View view) {
|
| | | SingleSelectionPopup popup2 = new SingleSelectionPopup(getActivity(),mCredentialsList,"证件类型");
|
| | | popup2.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | popup2.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewIdentityTypeContent.setText(item);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onClick(View v) {
|
| | | switch (v.getId()){
|
| | | case R.id.register_sex:
|
| | | SingleSelectionPopup popup = new SingleSelectionPopup(getActivity(),mSexList,"性别");
|
| | | popup.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | popup.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewSexContent.setText(item);
|
| | | }
|
| | | });
|
| | | break;
|
| | | case R.id.register_nation:
|
| | | CountrySelectionPopup countrySelectionPopup = new CountrySelectionPopup(getActivity());
|
| | | countrySelectionPopup.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | countrySelectionPopup.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewNationContent.setText(item);
|
| | | }
|
| | | });
|
| | | break;
|
| | | case R.id.register_birthday:
|
| | | showDatePicker();
|
| | | break;
|
| | | case R.id.register_visitor_class:
|
| | | SingleSelectionPopup popup1 = new SingleSelectionPopup(getActivity(),mVisitorTypeList,"访客类型");
|
| | | popup1.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | popup1.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewVisitorClassContent.setText(item);
|
| | | }
|
| | | });
|
| | | break;
|
| | | case R.id.register_id_class:
|
| | | SingleSelectionPopup popup2 = new SingleSelectionPopup(getActivity(),mCredentialsList,"证件类型");
|
| | | popup2.showAtLocation(mBaseLayout, Gravity.CENTER,0,0);
|
| | | popup2.addOkButtonClickedListener(new OkButtonClickedListener() {
|
| | | @Override
|
| | | public void onItemSelected(int position, Object o, String item) {
|
| | | mViewIdClassContent.setText(item);
|
| | | }
|
| | | });
|
| | | break;
|
| | | }
|
| | | }
|
| | | public void onClick(View v) {}
|
| | |
|
| | | public void showDatePicker(){
|
| | | Date date = new Date();
|