| | |
| | | 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;
|
| | |
| | | @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();
|
| | |
| | | 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");
|
| | |
| | |
|
| | | @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>();
|