FloatingInputPopWindow.java
7.36 KB
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
package com.cnlive.goldenline.ui.widget;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.IdRes;
import android.text.InputFilter;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioGroup;
import android.widget.TextView;
import com.cnlive.goldenline.R;
import com.cnlive.goldenline.model.EventType;
import com.cnlive.goldenline.ui.base.SingleChoiceAdapter;
import com.cnlive.goldenline.util.LogUtils;
import com.cnlive.goldenline.util.StringUtils;
import org.greenrobot.eventbus.EventBus;
/**
* Description:直播-选座弹框
* Created on 2017/3/14
* Author : 萧
*/
public class FloatingInputPopWindow extends PopupWindow {
private static final String TAG = "ChooseSeatPopWindow";
public FloatingInputPopWindow(Context mContext, int height, int textLimit, boolean isShowSettings) {
if (mContext != null) {
View view = LayoutInflater.from(mContext).inflate(R.layout.layout_floating_input, null);
view.setAnimation(AnimationUtils.loadAnimation(mContext, R.anim.seat_selection_bottom_bar_in));
this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
ColorDrawable cd = new ColorDrawable(Color.WHITE);
this.setBackgroundDrawable(cd);
this.setHeight(height > 0 ? height : ViewGroup.LayoutParams.WRAP_CONTENT);
this.setFocusable(true);
this.setContentView(view);
this.setOutsideTouchable(false);
this.setAnimationStyle(R.style.popup_anim_slow);
final EditText et = (EditText) view.findViewById(R.id.floating_input_et);
if (textLimit > 0)
et.setFilters(new InputFilter[]{new InputFilter.LengthFilter(textLimit)});
et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
LogUtils.LOGE(TAG + " v = " + v);
if (v != null) {
String s = v.getText().toString();
if (!StringUtils.isEmpty(s)) {
EventType type = new EventType();
type.setType(EventType.EVENT_CHAT_ZHIBO);
type.setMsg(s);
EventBus.getDefault().post(type);
et.setText("");
}
}
}
return false;
}
});
ImageView img_setting = (ImageView) view.findViewById(R.id.floating_input_img_settings);
if (!isShowSettings) {
img_setting.setVisibility(View.GONE);
} else {
final LinearLayout layout_settings = (LinearLayout) view.findViewById(R.id.floating_input_layout_settings);
img_setting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (layout_settings != null) {
if (layout_settings.getVisibility() != View.GONE) {
layout_settings.setVisibility(View.GONE);
} else if (layout_settings.getVisibility() != View.VISIBLE) {
layout_settings.setVisibility(View.VISIBLE);
}
}
}
});
RadioGroup rg_loc = (RadioGroup) view.findViewById(R.id.floating_input_rg_location);
rg_loc.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.rg_loc_rb_top:
break;
case R.id.rg_loc_rb_center:
break;
case R.id.rg_loc_rb_bottom:
break;
}
}
});
MultiRowRadioGroup rg_color = (MultiRowRadioGroup) view.findViewById(R.id.floating_input_rg_color);
rg_color.setOnCheckedChangeListener(new MultiRowRadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(MultiRowRadioGroup group, @IdRes int checkedId) {
Log.e(TAG, "rg_color.onCheckedChanged: checkId = " + checkedId);
}
});
// GridView grid = (GridView) view.findViewById(R.id.floating_input_gridview);
// List<Drawable> dataList = new ArrayList<>();
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_white));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_orange));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_lightyellow));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_yellow));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_green));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_skyblue));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_blue));
// dataList.add(ResLoader.Drawable(mContext, R.drawable.danmu_color_bg_purple));
// ColorAdapter adapter = new ColorAdapter(mContext);
// grid.setAdapter(adapter);
// adapter.setData(dataList, 0);
// grid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
// @Override
// public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//
// }
// });
}
}
}
class ColorAdapter extends SingleChoiceAdapter<Drawable> {
public ColorAdapter(Context context) {
super(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.layout_single_checkbox, parent, false);
holder = new ViewHolder();
holder.cb = (CheckBox) convertView.findViewById(R.id.single_cb);
holder.cb.setButtonDrawable(dataList.get(position));
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.cb.setChecked(isSelected.get(position));
return convertView;
}
class ViewHolder {
CheckBox cb;
}
}
}