| | |
| | |
|
| | | import com.lidroid.xutils.ViewUtils;
|
| | | import com.lidroid.xutils.view.annotation.ViewInject;
|
| | | import com.lidroid.xutils.view.annotation.event.OnItemSelected;
|
| | | import com.lidroid.xutils.view.annotation.event.OnClick;
|
| | | import com.wx.wheelview.widget.WheelView;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
|
| | | public class CountrySelectionDialog extends PopupWindow implements View.OnClickListener, WheelView.OnWheelItemSelectedListener {
|
| | | public class CountrySelectionDialog extends PopupWindow implements WheelView.OnWheelItemSelectedListener {
|
| | |
|
| | | @ViewInject(R.id.dialog_country_ok)
|
| | | private TextView dialog_country_ok;
|
| | |
| | | private List<String> countryWordList;
|
| | | private List<String> countryList;
|
| | |
|
| | | @OnItemSelected(R.id.dialog_country_name)
|
| | | public void dialog_country_name_click(View view) {
|
| | | System.out.println("");
|
| | | @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()));
|
| | | }
|
| | | }
|
| | | dismiss();
|
| | | }
|
| | |
|
| | | @OnClick(R.id.dialog_country_cancel)
|
| | | public void dialog_country_cancel_click(View view) {
|
| | | dismiss();
|
| | | }
|
| | |
|
| | | public CountrySelectionDialog(Context context, String[] countryWordData, List<String> countryWordList, HashMap<String, List<String>> countryData) {
|
| | |
| | | view = LayoutInflater.from(context).inflate(R.layout.dialog_country, null);
|
| | | ViewUtils.inject(this, view);
|
| | |
|
| | | dialog_country_cancel = (TextView) view.findViewById(R.id.dialog_country_cancel);
|
| | | dialog_country_ok = (TextView) view.findViewById(R.id.dialog_country_ok);
|
| | | dialog_country_cancel.setOnClickListener(this);
|
| | | dialog_country_ok.setOnClickListener(this);
|
| | | this.countryWordList = countryWordList;
|
| | | this.countryData = countryData;
|
| | | countryList = countryData.get(countryWordList.get(dialog_country_name_first_letter.getSelection()));
|
| | | this.countryList = countryData.get(countryWordList.get(dialog_country_name_first_letter.getSelection()));
|
| | |
|
| | | WheelView.WheelViewStyle wheelViewStyle = new WheelView.WheelViewStyle();
|
| | | wheelViewStyle.selectedTextColor = Color.parseColor("#11c3e3");
|
| | | wheelViewStyle.textColor = Color.parseColor("#bcc6cf");
|
| | | wheelViewStyle.selectedTextSize = 22;
|
| | | wheelViewStyle.textSize = 16;
|
| | | wheelViewStyle.holoBorderColor = Color.parseColor("#11c3e3");
|
| | |
|
| | | dialog_country_name_first_letter.setWheelAdapter(new MyWheelAdapter(context));
|
| | | dialog_country_name_first_letter.setSkin(WheelView.Skin.Holo);
|
| | | dialog_country_name_first_letter.setWheelSize(5);
|
| | | dialog_country_name_first_letter.setBackgroundResource(R.color.colorBackground);
|
| | | dialog_country_name_first_letter.setStyle(wheelViewStyle);
|
| | |
|
| | | dialog_country_name.setWheelAdapter(new MyWheelAdapter(context));
|
| | | dialog_country_name.setSkin(WheelView.Skin.Holo);
|
| | | dialog_country_name.setWheelSize(5);
|
| | | dialog_country_name.setBackgroundResource(R.color.colorBackground);
|
| | | WheelView.WheelViewStyle style = new WheelView.WheelViewStyle();
|
| | | style.selectedTextColor = Color.parseColor("#11c3e3");
|
| | | style.textColor = Color.parseColor("#bcc6cf");
|
| | | style.selectedTextSize = 22;
|
| | | style.textSize = 16;
|
| | | style.holoBorderColor = Color.parseColor("#11c3e3");
|
| | | dialog_country_name_first_letter.setStyle(style);
|
| | | dialog_country_name.setStyle(style);
|
| | | dialog_country_name.setStyle(wheelViewStyle);
|
| | |
|
| | | initData();
|
| | | setOutsideTouchable(true);
|
| | |
|
| | | view.setOnTouchListener(new View.OnTouchListener() {
|
| | | @Override
|
| | | public boolean onTouch(View view, MotionEvent motionEvent) {
|
| | |
| | | }
|
| | | });
|
| | |
|
| | | this.setOutsideTouchable(true);
|
| | | this.setFocusable(true);
|
| | | this.setContentView(this.view);
|
| | | this.setHeight(RelativeLayout.LayoutParams.MATCH_PARENT);
|
| | | this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
|
| | | this.setFocusable(true);
|
| | | ColorDrawable colorDrawable = new ColorDrawable(0x7f000000);
|
| | | this.setBackgroundDrawable(colorDrawable);
|
| | | this.setBackgroundDrawable(new ColorDrawable(0x7f000000));
|
| | | this.setAnimationStyle(R.style.PopupAnimation);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void onClick(View view) {
|
| | | if (view instanceof AppCompatTextView) {
|
| | | if (((AppCompatTextView) view).getText().equals("确认")) {
|
| | | 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()));
|
| | | }
|
| | | }
|
| | | dismiss();
|
| | | }
|
| | | if (((AppCompatTextView) view).getText().equals("取消")) {
|
| | | dismiss();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|