File was renamed from VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/com/bsk/zhangbo/demoforbsk/service/DictionaryService.java |
| | |
| | |
|
| | | import com.bsk.zhangbo.demoforbsk.util.AppApi;
|
| | |
|
| | | import net.sourceforge.pinyin4j.PinyinHelper;
|
| | |
|
| | | import org.xutils.http.RequestParams;
|
| | | import org.xutils.x;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | 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;
|
| | |
|
| | | public class DictionaryService {
|
| | | public class DictionaryMng extends BaseMng {
|
| | |
|
| | | public static DictionaryMng instance = new DictionaryMng();
|
| | |
|
| | | public static DictionaryMng getInstance() {
|
| | | return instance;
|
| | | }
|
| | |
|
| | | public static List<String> nationList = new ArrayList<String>();
|
| | | public static List<String> mCredentialsList = new ArrayList<String>();
|
| | | public static List<String> mSexList = new ArrayList<String>();
|
| | | public static Map<String, String> idMap = new HashMap<String, String>();
|
| | | public static List<String> countryWordList = new ArrayList<String>();
|
| | | public static HashMap<String,List<String>> countryData = new HashMap<String,List<String>>();
|
| | | public static String[] countryWordData = new String[]{};
|
| | |
|
| | | public static void loadAllDictionaryData() {
|
| | | loadNation();
|
| | | public void loadAllDictionaryData() {
|
| | | loadCountries();
|
| | | loadCredentialsList();
|
| | | loadSexList();
|
| | | }
|
| | |
|
| | | public static String getPinYinFirstLetter(String str) {
|
| | | StringBuffer sb = new StringBuffer();
|
| | | try {
|
| | | sb.setLength(0);
|
| | | char c = str.charAt(0);
|
| | | String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c);
|
| | | if (pinyinArray != null) {
|
| | | sb.append(pinyinArray[0].charAt(0));
|
| | | } else {
|
| | | sb.append(c);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return sb.toString();
|
| | | }
|
| | |
|
| | | public static void loadNation() {
|
| | | public void loadCountries() {
|
| | | RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.DICTIONARY_TYPE_LIST);
|
| | | params.addParameter(Dictionary.FieldNames.type, CommonVariables.DictionaryType.NATION);
|
| | | params.addParameter(Dictionary.FieldNames.type, CommonVariables.DictionaryType.COUNTRY);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | | public void success() {
|
| | | List<Dictionary> items = getList(Dictionary.class);
|
| | |
| | | for (Dictionary item : items) {
|
| | | idMap.put(item.getName(), item.getId()+"");
|
| | | nationList.add(item.getName());
|
| | | String captialLetter = item.getRemark();//getPinYinFirstLetter(nation.getName()).toUpperCase();
|
| | | List list = countryData.get(captialLetter);
|
| | | String firstLetter = item.getRemark();
|
| | | List list = countryData.get(firstLetter);
|
| | | if (list == null) {
|
| | | list = new ArrayList();
|
| | | countryData.put(captialLetter, list);
|
| | | countryWordList.add(0, captialLetter);
|
| | | countryData.put(firstLetter, list);
|
| | | countryWordList.add(0, firstLetter);
|
| | | }
|
| | | list.add(item.getName());
|
| | | countryWordData[i] = item.getName();
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | public static void loadCredentialsList() {
|
| | | public void loadCredentialsList() {
|
| | | RequestParams params = new RequestParams(AppApi.BASEURL+AppApi.DICTIONARY_TYPE_LIST);
|
| | | params.addParameter(Dictionary.FieldNames.type, CommonVariables.DictionaryType.CREDENTIALS);
|
| | | x.http().get(params, new BaseCommonCallBack() {
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | private static void loadSexList() {
|
| | | 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 static String getId(String name) {
|
| | | return idMap.get(name);
|
| | | }
|
| | |
|
| | | }
|