xuxiuxi
2017-03-28 a9a69e67c9f78fcf0d8c00930a15db5289f799d5
VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/CountrySelectionPopup.java
@@ -1,31 +1,25 @@
package com.bsk.zhangbo.demoforbsk.widget;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.AppCompatTextView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bsk.zhangbo.demoforbsk.R;
import com.bsk.zhangbo.demoforbsk.adapter.MyWheelAdapter;
import com.bsk.zhangbo.demoforbsk.service.DictionaryMng;
import com.bsk.zhangbo.demoforbsk.listeners.OkButtonClickedListener;
import com.bsk.zhangbo.demoforbsk.util.CountryPresenter;
import com.wx.wheelview.widget.WheelView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -43,7 +37,8 @@
    private List<String> countryList;
    private CountryPresenter countryPresenter;
    public CountrySelectionPopup(Context context) {
    public CountrySelectionPopup(Context context, String[] countryWordData, List<String> countryWordList, HashMap<String, List<String>> countryData) {
        this.mContext = context;
        countryPresenter = new CountryPresenter(context);
        view = LayoutInflater.from(context).inflate(R.layout.pop_country, null);
@@ -56,9 +51,10 @@
        mTvCancel.setOnClickListener(this);
        mTvConfirm.setOnClickListener(this);
        String[] countryWordData = countryPresenter.getCountryWordData();
        countryWordList = Arrays.asList(countryWordData);
        countryData = countryPresenter.getCountryData();
        //String[] countryWordData = DictionaryMng.countryWordData;
        this.countryWordList = countryWordList;//DictionaryMng.countryWordList;
        this.countryData = countryData;//DictionaryMng.countryData;
        countryList = countryData.get(countryWordList.get(mWheelViewTitle.getSelection()));
        mWheelViewTitle.setWheelAdapter(new MyWheelAdapter(context));
@@ -125,9 +121,14 @@
        if (view instanceof AppCompatTextView) {
            if (((AppCompatTextView) view).getText().equals("确认")) {
                for (OkButtonClickedListener okButtonClickedListener : okButtonClickedListeners) {
                    countryList = countryData.get(countryWordList.get(mWheelViewTitle.getCurrentPosition()));
                    okButtonClickedListener.onItemSelected(0, null, countryList.get(mWheelViewName.getCurrentPosition()));
                    if (mWheelViewTitle.getCurrentPosition() >= 0) {
                        countryList = countryData.get(countryWordList.get(mWheelViewTitle.getCurrentPosition()));
                        okButtonClickedListener.onItemSelected(0, null, countryList.get(mWheelViewName.getCurrentPosition()));
                    }
                }
                dismiss();
            }
            if (((AppCompatTextView) view).getText().equals("取消")) {
                dismiss();
            }
        }
@@ -144,7 +145,6 @@
        mWheelViewTitle.joinDatas(countryData);
        mWheelViewName.setWheelData(countryList);
    }
    private List<OkButtonClickedListener> okButtonClickedListeners = new ArrayList<OkButtonClickedListener>();