VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/dialog/CountrySelectionDialog.java
@@ -3,7 +3,6 @@ import android.content.Context; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.support.v7.widget.AppCompatTextView; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -36,18 +35,17 @@ @ViewInject(R.id.dialog_country_name) private WheelView dialog_country_name; private Context mContext; private View view; private HashMap<String, List<String>> countryData; private List<String> countryWordList; private List<String> countryList; private HashMap<String, List<String>> countriesGroupByFirstLetter; private List<String> uniqueFirstLetterList; private List<String> countriesWithSameFirstLetter; @OnClick(R.id.dialog_country_ok) public void dialog_country_ok_click(View view) { for (OkButtonClickedListener okButtonClickedListener : okButtonClickedListeners) { if (dialog_country_name_first_letter.getCurrentPosition() >= 0) { countryList = countryData.get(countryWordList.get(dialog_country_name_first_letter.getCurrentPosition())); okButtonClickedListener.onItemSelected(0, null, countryList.get(dialog_country_name.getCurrentPosition())); countriesWithSameFirstLetter = countriesGroupByFirstLetter.get(uniqueFirstLetterList.get(dialog_country_name_first_letter.getCurrentPosition())); okButtonClickedListener.onItemSelected(0, null, countriesWithSameFirstLetter.get(dialog_country_name.getCurrentPosition())); } } dismiss(); @@ -58,14 +56,13 @@ dismiss(); } public CountrySelectionDialog(Context context, String[] countryWordData, List<String> countryWordList, HashMap<String, List<String>> countryData) { this.mContext = context; public CountrySelectionDialog(Context context, List<String> uniqueFirstLetterList, HashMap<String, List<String>> countriesGroupByFirstLetter) { view = LayoutInflater.from(context).inflate(R.layout.dialog_country, null); ViewUtils.inject(this, view); this.countryWordList = countryWordList; this.countryData = countryData; this.countryList = countryData.get(countryWordList.get(dialog_country_name_first_letter.getSelection())); this.uniqueFirstLetterList = uniqueFirstLetterList; this.countriesGroupByFirstLetter = countriesGroupByFirstLetter; this.countriesWithSameFirstLetter = countriesGroupByFirstLetter.get(uniqueFirstLetterList.get(dialog_country_name_first_letter.getSelection())); WheelView.WheelViewStyle wheelViewStyle = new WheelView.WheelViewStyle(); wheelViewStyle.selectedTextColor = Color.parseColor("#11c3e3"); @@ -122,14 +119,14 @@ @Override public void onItemSelected(int position, Object o) { countryList = countryData.get(countryWordList.get(dialog_country_name_first_letter.getCurrentPosition())); countriesWithSameFirstLetter = countriesGroupByFirstLetter.get(uniqueFirstLetterList.get(dialog_country_name_first_letter.getCurrentPosition())); } private void initData() { dialog_country_name_first_letter.setWheelData(countryWordList); dialog_country_name_first_letter.setWheelData(uniqueFirstLetterList); dialog_country_name_first_letter.join(dialog_country_name); dialog_country_name_first_letter.joinDatas(countryData); dialog_country_name.setWheelData(countryList); dialog_country_name_first_letter.joinDatas(countriesGroupByFirstLetter); dialog_country_name.setWheelData(countriesWithSameFirstLetter); } private List<OkButtonClickedListener> okButtonClickedListeners = new ArrayList<OkButtonClickedListener>(); VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/RegisterFragment.java
@@ -76,9 +76,8 @@ private List mCredentialsList; private LinearLayout mBaseLayout; private String[] countryWordData; private List<String> countryWordList; private HashMap<String, List<String>> countryData; private List<String> uniqueFirstLetterList; private HashMap<String, List<String>> countriesGroupByFirstLetter; private static RegisterFragment instance = new RegisterFragment(); @@ -133,8 +132,7 @@ @OnClick(R.id.register_country) public void register_country_click(View view) { CountrySelectionDialog countrySelectionPopup = new CountrySelectionDialog(getActivity(), countryWordData,countryWordList,countryData); CountrySelectionDialog countrySelectionPopup = new CountrySelectionDialog(getActivity(),uniqueFirstLetterList,countriesGroupByFirstLetter); countrySelectionPopup.showAtLocation(mBaseLayout, Gravity.CENTER,0,0); countrySelectionPopup.addOkButtonClickedListener(new OkButtonClickedListener() { @Override @@ -218,10 +216,9 @@ this.mCredentialsList = credentialsList; } public void setCountryData(String[] countryWordData, List<String> countryWordList, HashMap<String, List<String>> countryData) { this.countryData = countryData; this.countryWordList = countryWordList; this.countryData = countryData; public void setCountryData(List<String> uniqueFirstLetterList, HashMap<String, List<String>> countriesGroupByFirstLetter) { this.uniqueFirstLetterList = uniqueFirstLetterList; this.countriesGroupByFirstLetter = countriesGroupByFirstLetter; } @Override VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/service/DictionaryMng.java
@@ -26,8 +26,8 @@ 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 List<String> countryWordList = new ArrayList<String>(); public static HashMap<String,List<String>> countryData = new HashMap<String,List<String>>(); public static List<String> uniqueFirstLetterList = new ArrayList<String>(); public static HashMap<String,List<String>> countriesGroupByFirstLetter = new HashMap<String,List<String>>(); public static String[] countryWordData = new String[]{}; public static List<String> visitPurposeList = new ArrayList<String>(); @@ -50,17 +50,17 @@ idMap.put(item.getName(), item.getId()+""); nationList.add(item.getName()); String firstLetter = item.getRemark(); List list = countryData.get(firstLetter); List list = countriesGroupByFirstLetter.get(firstLetter); if (list == null) { list = new ArrayList(); countryData.put(firstLetter, list); countryWordList.add(0, firstLetter); countriesGroupByFirstLetter.put(firstLetter, list); uniqueFirstLetterList.add(0, firstLetter); } list.add(item.getName()); countryWordData[i] = item.getName(); i++; } RegisterFragment.getInstance().setCountryData(countryWordData, countryWordList, countryData); RegisterFragment.getInstance().setCountryData(uniqueFirstLetterList, countriesGroupByFirstLetter); } });