| | |
| | | import cn.com.basic.face.dialog.CountryDialog;
|
| | | import cn.com.basic.face.dialog.SelectDialog;
|
| | | import cn.com.basic.face.discern.query.condition.DictionaryQueryCondition;
|
| | | import cn.com.basic.face.service.sqlite.DictionaryDao;
|
| | | import cn.com.basic.face.service.sqlite.TestDao;
|
| | | import cn.com.basic.face.util.AppApi;
|
| | |
|
| | |
| | | loadCameraBrandList();
|
| | | DepartmentMng.getInstance().loadDepartmentDictionary();
|
| | | PostMng.getInstance().loadPostDictionary();
|
| | | loadAttenderTypeList();
|
| | | }
|
| | |
|
| | | public void loadCountries() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.COUNTRY);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<Dictionary> items = getList(Dictionary.class);
|
| | | int i=0;
|
| | | List<String> uniqueFirstLetterList = new ArrayList<String>();
|
| | | HashMap<String,List<String>> countriesGroupByFirstLetter = new HashMap<String,List<String>>();
|
| | | sortCountries(items);
|
| | | for (Dictionary item : items) {
|
| | | idMap.put(item.getName(), item.getDictId()+"");
|
| | |
|
| | | String firstLetter = item.getName();
|
| | | if (item.getName().length() > 0) {
|
| | | firstLetter = CharacterParser.getInstance().getSelling(item.getName()).substring(0, 1).toUpperCase();
|
| | | }
|
| | | List list = countriesGroupByFirstLetter.get(firstLetter);
|
| | | if (list == null) {
|
| | | list = new ArrayList();
|
| | | countriesGroupByFirstLetter.put(firstLetter, list);
|
| | | uniqueFirstLetterList.add(0, firstLetter);
|
| | | }
|
| | | list.add(item.getName());
|
| | | i++;
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.COUNTRY);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | loadCountriesAfterReturn(getList(Dictionary.class));
|
| | | }
|
| | | CountryDialog.setCountries(uniqueFirstLetterList, countriesGroupByFirstLetter);
|
| | | }
|
| | | });
|
| | | });
|
| | | } else {
|
| | | loadCountriesAfterReturn(DictionaryDao.getInstance().loadCountries());
|
| | | }
|
| | | }
|
| | |
|
| | | private void loadCountriesAfterReturn(List<Dictionary> items) {
|
| | | int i=0;
|
| | | List<String> uniqueFirstLetterList = new ArrayList<String>();
|
| | | HashMap<String,List<String>> countriesGroupByFirstLetter = new HashMap<String,List<String>>();
|
| | | sortCountries(items);
|
| | | for (Dictionary item : items) {
|
| | | idMap.put(item.getName(), item.getDictId()+"");
|
| | |
|
| | | String firstLetter = item.getName();
|
| | | if (item.getName().length() > 0) {
|
| | | firstLetter = CharacterParser.getInstance().getSelling(item.getName()).substring(0, 1).toUpperCase();
|
| | | }
|
| | | List list = countriesGroupByFirstLetter.get(firstLetter);
|
| | | if (list == null) {
|
| | | list = new ArrayList();
|
| | | countriesGroupByFirstLetter.put(firstLetter, list);
|
| | | uniqueFirstLetterList.add(0, firstLetter);
|
| | | }
|
| | | list.add(item.getName());
|
| | | i++;
|
| | | }
|
| | | CountryDialog.setCountries(uniqueFirstLetterList, countriesGroupByFirstLetter);
|
| | | }
|
| | |
|
| | |
|
| | | private void sortCountries(List<Dictionary> countries) {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | |
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.ID_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setIdTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.ID_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setIdTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setIdTypeList(getDictionaryNameList(DictionaryDao.getInstance().loadIdTypeList()));
|
| | | }
|
| | | }
|
| | |
|
| | | private void loadGenderList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.GENDER);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setGenderList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.GENDER);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setGenderList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setGenderList(getDictionaryNameList(DictionaryDao.getInstance().loadGenderList()));
|
| | | }
|
| | | }
|
| | |
|
| | | public void loadVisitReasonList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISIT_REASON);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setVisitReasonList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISIT_REASON);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setVisitReasonList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setVisitReasonList(getDictionaryNameList(DictionaryDao.getInstance().loadVisitReasonList()));
|
| | | }
|
| | | }
|
| | |
|
| | | public void loadResolutionList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.RESOLUTION);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.RESOLUTION);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(DictionaryDao.getInstance().loadResolutionList()));
|
| | | }
|
| | | }
|
| | |
|
| | | public void loadProtocolList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.PROTOCOL);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.PROTOCOL);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(DictionaryDao.getInstance().loadProtocolList()));
|
| | | }
|
| | | }
|
| | |
|
| | | public void loadCameraBrandList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.CAMERA_BRAND);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.CAMERA_BRAND);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(DictionaryDao.getInstance().loadCameraBrandList()));
|
| | | }
|
| | | }
|
| | |
|
| | | private void loadVisitorTypeList() {
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISITOR_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setVisitorTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.VISITOR_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setVisitorTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setVisitorTypeList(getDictionaryNameList(DictionaryDao.getInstance().loadVisitorTypeList()));
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.ATTENDER_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setAttenderTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.Query.DICTIONARY_QUERY);
|
| | | params.addParameter(DictionaryQueryCondition.FieldNames.type, CommonVariables.DictionaryType.ATTENDER_TYPE);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | SelectDialog.setAttenderTypeList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | }
|
| | | });
|
| | | } else {
|
| | | SelectDialog.setAttenderTypeList(getDictionaryNameList(DictionaryDao.getInstance().loadAttenderTypeList()));
|
| | | }
|
| | | }
|
| | |
|
| | | public void addDictionary(final int type, String type1, String name) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.DICTIONARY_ADD);
|
| | | params.addBodyParameter(Dictionary.FieldNames.type, type1);
|
| | | params.addBodyParameter(Dictionary.FieldNames.name, name);
|
| | | params.addBodyParameter(Dictionary.FieldNames.orderBy, "10");
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<Dictionary> items = getList(Dictionary.class);
|
| | | switch (type) {
|
| | | case Constant.DialogSelectType.VISIT_REASON:
|
| | | break;
|
| | | case Constant.DialogSelectType.RESOLUTION:
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | break;
|
| | | case Constant.DialogSelectType.PROTOCOL:
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | break;
|
| | | case Constant.DialogSelectType.CAMERA_BRAND:
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(getList(Dictionary.class)));
|
| | | break;
|
| | | if (!BaseApplication.deviceAvailable) {
|
| | | return;
|
| | | }
|
| | | if (BaseApplication.getInstance().networkAvailable()) {
|
| | | RequestParams params = new RequestParams(AppApi.BASE_URL +AppApi.DICTIONARY_ADD);
|
| | | params.addBodyParameter(Dictionary.FieldNames.type, type1);
|
| | | params.addBodyParameter(Dictionary.FieldNames.name, name);
|
| | | params.addBodyParameter(Dictionary.FieldNames.orderBy, "10");
|
| | | x.http().post(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | addDictionaryAfterReturn(getList(Dictionary.class), type);
|
| | | }
|
| | | Toast.makeText(MainActivity.getInstance(), "添加成功", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | | });
|
| | | });
|
| | | } else {
|
| | | addDictionaryAfterReturn(DictionaryDao.getInstance().addDictionary(type1, name), type);
|
| | | }
|
| | | }
|
| | |
|
| | | public void addDictionaryAfterReturn(List<Dictionary> list, int type) {
|
| | | switch (type) {
|
| | | case Constant.DialogSelectType.VISIT_REASON:
|
| | | break;
|
| | | case Constant.DialogSelectType.RESOLUTION:
|
| | | SelectDialog.setResolutionList(getDictionaryNameList(list));
|
| | | break;
|
| | | case Constant.DialogSelectType.PROTOCOL:
|
| | | SelectDialog.setProtocolList(getDictionaryNameList(list));
|
| | | break;
|
| | | case Constant.DialogSelectType.CAMERA_BRAND:
|
| | | SelectDialog.setCameraBrandList(getDictionaryNameList(list));
|
| | | break;
|
| | | }
|
| | | Toast.makeText(MainActivity.getInstance(), "添加成功", Toast.LENGTH_SHORT).show();
|
| | | }
|
| | |
|
| | | }
|