xuxiuxi
2017-05-12 e1bcafb39828e18a3605d94aad20376484b56b26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package cn.com.basic.face.dialog;
 
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
 
import com.bsk.zhangbo.demoforbsk.R;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
 
import java.util.ArrayList;
import java.util.List;
 
import cn.com.basic.face.base.MainActivity;
import cn.com.basic.face.dialog.wheelview.adapter.BaseWheelAdapter;
import cn.com.basic.face.dialog.wheelview.widget.WheelView;
import cn.com.basic.face.discern.common.CommonVariables;
import cn.com.basic.face.discern.query.item.SurveillancePhotoQueryItem;
import cn.com.basic.face.discern.query.item.SurveillanceQueryItem;
import cn.com.basic.face.fragment.SurveillanceFragment;
import cn.com.basic.face.service.SurveillanceMng;
import cn.com.basic.face.util.Constant;
import cn.com.basic.face.util.OkClickedListener;
import cn.com.basic.face.widget.surveilance.SurveillancePhotoSelectListView;
 
public class SurveillancePhotoDialog extends PopupWindow {
    private final View parentView;
 
    @ViewInject(R.id.dialog_surveillance_photo_select_list_view)
    private SurveillancePhotoSelectListView dialog_surveillance_photo_select_list_view;
 
    private List list = new ArrayList();
 
    public static List visitorTypeList = new ArrayList();
    public static List genderList = new ArrayList();
    public static List idTypeList = new ArrayList();
    public static List visitReasonList = new ArrayList();
 
    public static void setVisitorTypeList(List visitorTypeList) {
        AddDialog.visitorTypeList = visitorTypeList;
    }
 
    public static void setGenderList(List genderList) {
        AddDialog.genderList = genderList;
    }
 
    public static void setIdTypeList(List idTypeList) {
        AddDialog.idTypeList = idTypeList;
    }
 
    public SurveillancePhotoDialog(View parentView, int type, OkClickedListener okButtonClickedListener, long selectedId) {
        this.parentView = parentView;
        View view = LayoutInflater.from(MainActivity.getInstance()).inflate(R.layout.dialog_surveillance_photo_select,null);
        ViewUtils.inject(this, view);
 
        dialog_surveillance_photo_select_list_view.show(SurveillanceMng.getInstance().getSurveillancePhotoList(selectedId));
 
        setTitleAndList(type);
        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");
 
        view.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                View popLayout = view.findViewById(R.id.dialog_add_linear_layout);
                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;
            }
        });
 
        setOutsideTouchable(true);
        this.setContentView(view);
        this.setHeight(RelativeLayout.LayoutParams.MATCH_PARENT);
        this.setWidth(RelativeLayout.LayoutParams.MATCH_PARENT);
        this.setFocusable(true);
        //this.setBackgroundDrawable(new ColorDrawable(0x7f000000));
        this.setAnimationStyle(R.style.PopupSlideAnimation);
        okButtonClickedListeners.add(okButtonClickedListener);
        this.showAtLocation(parentView, Gravity.BOTTOM,0,330);
    }
 
 
    @OnClick(R.id.dialog_add_ok)
    public void dialog_add_ok_click(View view) {
        for (OkClickedListener okButtonClickedListener : okButtonClickedListeners) {
            // okButtonClickedListener.onSelected(dialog_add_content.getText().toString());
        }
        dismiss();
    }
 
    @OnClick(R.id.dialog_add_cancel)
    public void dialog_add_cancel_click(View view) {
        dismiss();
    }
 
    private List<OkClickedListener> okButtonClickedListeners = new ArrayList<OkClickedListener>();
 
    public void addOkButtonClickedListener(OkClickedListener okButtonClickedListener) {
        this.okButtonClickedListeners.add(okButtonClickedListener);
    }
 
    private void setTitleAndList(int type) {
        String tile = "";
        switch (type) {
            case Constant.DialogSelectType.VISIT_REASON_ADD:
                tile = "添加访问事由";
                break;
        }
        // dialog_add_title.setText(tile);
    }
 
    public static void setVisitReasonList(List visitReasonList) {
        AddDialog.visitReasonList = visitReasonList;
    }
 
 
    public static class WheelAdapter extends BaseWheelAdapter<String> {
        private Context mContext;
 
        public WheelAdapter(Context context) {
            mContext = context;
        }
 
        @Override
        protected View bindView(int position, View convertView, ViewGroup parent) {
            AddDialog.WheelAdapter.ViewHolder viewHolder;
            if (convertView == null) {
                viewHolder = new AddDialog.WheelAdapter.ViewHolder();
                convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_row, null);
                viewHolder.textView = (TextView) convertView.findViewById(R.id.item_wheel_name);
                convertView.setTag(viewHolder);
            } else {
                viewHolder = (AddDialog.WheelAdapter.ViewHolder) convertView.getTag();
            }
            viewHolder.textView.setText(mList.get(position)+"");
            return convertView;
        }
 
        static class ViewHolder {
            TextView textView;
        }
 
    }
}