From 0588949cb2006680be01ab4cb5599b985b082edc Mon Sep 17 00:00:00 2001
From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期二, 28 三月 2017 14:14:57 +0800
Subject: [PATCH] 

---
 VisitFace/DemoForBsk/app/src/main/res/values/strings.xml                                        |    1 
 VisitFace/DemoForBsk/app/src/main/res/layout/visit_purpose_popup.xml                            |   69 +++++++++++++++++
 VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/VisitPurposePopup.java |  144 ++++++++++++++++++++++++++++++++++++
 3 files changed, 214 insertions(+), 0 deletions(-)

diff --git a/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/VisitPurposePopup.java b/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/VisitPurposePopup.java
new file mode 100644
index 0000000..cf181ef
--- /dev/null
+++ b/VisitFace/DemoForBsk/app/src/main/java/com/bsk/zhangbo/demoforbsk/widget/VisitPurposePopup.java
@@ -0,0 +1,144 @@
+package com.bsk.zhangbo.demoforbsk.widget;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+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 com.bsk.zhangbo.demoforbsk.R;
+import com.bsk.zhangbo.demoforbsk.adapter.MyWheelAdapter;
+import com.bsk.zhangbo.demoforbsk.listeners.OkButtonClickedListener;
+import com.wx.wheelview.widget.WheelView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.com.basic.face.discern.entity.Dictionary;
+
+/**
+ * Created by Sinoe on 2017/2/27.
+ */
+
+public class VisitPurposePopup extends PopupWindow implements View.OnClickListener,WheelView.OnWheelItemSelectedListener{
+    private View view;
+    private TextView mTvConfirm,mTvCancel,mTvTitle;
+    private List mList;
+    private WheelView mWheelView;
+    private Context mContext;
+    public VisitPurposePopup(Context context, List mList, String mTitle) {
+        this.mContext = context;
+        view = LayoutInflater.from(context).inflate(R.layout.visit_purpose_popup,null);
+        this.mList = mList;
+        mTvTitle = (TextView) view.findViewById(R.id.pop_single_title);
+        if (mTitle !=null && mTitle.length() > 0){
+            mTvTitle.setText(mTitle);
+        }else {
+            mTvTitle.setText("鏍囬");
+        }
+        mWheelView = (WheelView) view.findViewById(R.id. pop_single_wheel);
+        mWheelView.setOnWheelItemSelectedListener(this);
+        mTvCancel = (TextView) view.findViewById(R.id.pop_single_cancel);
+        mTvConfirm = (TextView) view.findViewById(R.id.pop_single_confirm);
+        mTvCancel.setOnClickListener(this);
+        mTvConfirm.setOnClickListener(this);
+        mWheelView.setWheelAdapter(new MyWheelAdapter(context));
+        mWheelView.setSkin(WheelView.Skin.Holo);
+        if (mList != null && mList.size() > 0) {
+            mWheelView.setWheelData(mList);
+        }
+        mWheelView.setWheelSize(5);
+        mWheelView.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");
+        mWheelView.setStyle(style);
+
+        //澶栭儴鍙偣鍑�
+        setOutsideTouchable(true);
+
+        view.setOnTouchListener(new View.OnTouchListener() {
+            @Override
+            public boolean onTouch(View view, MotionEvent motionEvent) {
+            View popLayout = view.findViewById(R.id.pop_single_ll);
+            int top = popLayout.getTop();
+            int bottom = popLayout.getBottom();
+            int left = popLayout.getLeft();
+            int right = popLayout.getRight();
+            int y = (int) motionEvent.getY();
+            int x = (int) motionEvent.getX();
+            if (motionEvent.getAction() == MotionEvent.ACTION_UP){
+                if (y<top || y> bottom){
+                    dismiss();
+                }
+                if (x < left || x > right){
+                    dismiss();
+                }
+
+            }
+            return true;
+            }
+        });
+
+        /*
+             璁剧疆绐楀彛鐗瑰緛
+         */
+        //璁剧疆瑙嗗浘
+        this.setContentView(this.view);
+        //璁剧疆绐楀彛瀹介珮
+        this.setHeight(RelativeLayout.LayoutParams.MATCH_PARENT);
+        this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
+        //璁剧疆寮瑰嚭绐楀彛鍙偣鍑�
+        this.setFocusable(true);
+        //瀹炰緥鍖朇olor
+        ColorDrawable colorDrawable = new ColorDrawable(0x7f000000);
+        this.setBackgroundDrawable(colorDrawable);
+        this.setAnimationStyle(R.style.PopupAnimation);
+    }
+
+    @Override
+    public void onClick(View view) {
+        switch (view.getId()){
+            case R.id.pop_single_cancel:
+                dismiss();
+                break;
+            case R.id.pop_single_add:
+                dismiss();
+                break;
+            case R.id.pop_single_confirm:
+                for (OkButtonClickedListener okButtonClickedListener : okButtonClickedListeners) {
+                    if (mWheelView.getCurrentPosition() >= 0) {
+                        Object o = mList.get(mWheelView.getCurrentPosition());
+                        String item = "";
+                        if (o instanceof Dictionary) {
+                            item = ((Dictionary) o).getName();
+                        } else {
+                            item = o+"";
+                        }
+                        okButtonClickedListener.onItemSelected(mWheelView.getCurrentPosition(), o, item);
+                    }
+                }
+                dismiss();
+                break;
+        }
+    }
+
+    @Override
+    public void onItemSelected(int position, Object o) {
+        //Toast.makeText(mContext,mList.get(position),Toast.LENGTH_SHORT).show();
+    }
+
+    private List<OkButtonClickedListener> okButtonClickedListeners = new ArrayList<OkButtonClickedListener>();
+
+    public void addOkButtonClickedListener(OkButtonClickedListener okButtonClickedListener) {
+        this.okButtonClickedListeners.add(okButtonClickedListener);
+    }
+
+}
diff --git a/VisitFace/DemoForBsk/app/src/main/res/layout/visit_purpose_popup.xml b/VisitFace/DemoForBsk/app/src/main/res/layout/visit_purpose_popup.xml
new file mode 100644
index 0000000..2fdc543
--- /dev/null
+++ b/VisitFace/DemoForBsk/app/src/main/res/layout/visit_purpose_popup.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:gravity="center"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <LinearLayout
+        android:id="@+id/pop_single_ll"
+        android:layout_width="350dp"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:background="@android:color/white"
+        android:orientation="vertical">
+        <TextView
+            android:id="@+id/pop_single_title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:padding="20dp"
+            android:gravity="center"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/text_size_big"
+            android:background="@color/colorPrimary"/>
+        <com.wx.wheelview.widget.WheelView
+            android:id="@+id/pop_single_wheel"
+            android:layout_width="200dp"
+            android:layout_height="wrap_content"></com.wx.wheelview.widget.WheelView>
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="0.5dp"
+            android:background="@color/colorText_5"/>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="50dp"
+            android:orientation="horizontal">
+            <TextView
+            android:id="@+id/pop_single_confirm"
+            android:layout_weight="1"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:gravity="center"
+            android:text="@string/confirm"
+            android:textSize="@dimen/text_size_big"/>
+            <View
+                android:layout_width="0.5dp"
+                android:layout_height="match_parent"
+                android:background="@color/colorText_5"/>
+            <TextView
+                android:id="@+id/pop_single_add"
+                android:layout_weight="1"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:text="@string/add"
+                android:textSize="@dimen/text_size_big"/>
+            <View
+                android:layout_width="0.5dp"
+                android:layout_height="match_parent"
+                android:background="@color/colorText_5"/>
+            <TextView
+                android:id="@+id/pop_single_cancel"
+                android:layout_weight="1"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:text="@string/cancel"
+                android:textSize="@dimen/text_size_big"/>
+        </LinearLayout>
+    </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/VisitFace/DemoForBsk/app/src/main/res/values/strings.xml b/VisitFace/DemoForBsk/app/src/main/res/values/strings.xml
index 0ce634b..82d70a7 100644
--- a/VisitFace/DemoForBsk/app/src/main/res/values/strings.xml
+++ b/VisitFace/DemoForBsk/app/src/main/res/values/strings.xml
@@ -23,6 +23,7 @@
 
 
     <string name="confirm">纭</string>
+    <string name="add">娣诲姞</string>
     <string name="cancel">鍙栨秷</string>
 
 

--
Gitblit v1.8.0