From f1920dd17d0e8b535204e9038d493ee8b571d6e7 Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 23 三月 2017 15:45:40 +0800
Subject: [PATCH] 

---
 VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/CountrySelectionPopup.java |   40 ++++++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/CountrySelectionPopup.java b/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/CountrySelectionPopup.java
index 5412998..08bed90 100644
--- a/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/CountrySelectionPopup.java
+++ b/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/CountrySelectionPopup.java
@@ -1,13 +1,9 @@
 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.util.Log;
+import android.support.v7.widget.AppCompatTextView;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
@@ -17,10 +13,13 @@
 
 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.Arrays;
+
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
@@ -39,6 +38,7 @@
     private CountryPresenter countryPresenter;
 
     public CountrySelectionPopup(Context context) {
+
         this.mContext = context;
         countryPresenter = new CountryPresenter(context);
         view = LayoutInflater.from(context).inflate(R.layout.pop_country, null);
@@ -51,9 +51,10 @@
         mTvCancel.setOnClickListener(this);
         mTvConfirm.setOnClickListener(this);
 
-        String[] countryWordData = countryPresenter.getCountryWordData();
-        countryWordList = Arrays.asList(countryWordData);
-        countryData = countryPresenter.getCountryData();
+        String[] countryWordData = DictionaryMng.countryWordData;
+        countryWordList = DictionaryMng.countryWordList;
+        countryData = DictionaryMng.countryData;
+
         countryList = countryData.get(countryWordList.get(mWheelViewTitle.getSelection()));
 
         mWheelViewTitle.setWheelAdapter(new MyWheelAdapter(context));
@@ -117,7 +118,20 @@
 
     @Override
     public void onClick(View view) {
-
+        if (view instanceof AppCompatTextView) {
+            if (((AppCompatTextView) view).getText().equals("纭")) {
+                for (OkButtonClickedListener okButtonClickedListener : okButtonClickedListeners) {
+                    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();
+            }
+        }
     }
 
     @Override
@@ -132,4 +146,10 @@
         mWheelViewName.setWheelData(countryList);
     }
 
+    private List<OkButtonClickedListener> okButtonClickedListeners = new ArrayList<OkButtonClickedListener>();
+
+    public void addOkButtonClickedListener(OkButtonClickedListener okButtonClickedListener) {
+        this.okButtonClickedListeners.add(okButtonClickedListener);
+    }
+
 }

--
Gitblit v1.8.0