|
|
@@ -33,155 +33,155 @@ import com.uas.appworks.R;
|
|
|
|
|
|
public class SelectPlayPop {
|
|
|
|
|
|
- public static void showPlay(final Activity ct, CharitModel model, OnSureListener onSureListener) {
|
|
|
- if (model == null) return;
|
|
|
- final PopupWindow window = new PopupWindow(ct);
|
|
|
+ public static void showPlay(final Activity ct, CharitModel model, OnSureListener onSureListener) {
|
|
|
+ if (model == null) return;
|
|
|
+ final PopupWindow window = new PopupWindow(ct);
|
|
|
// window.setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
|
|
|
- window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
|
- View view = LayoutInflater.from(ct).inflate(R.layout.pop_play_select, null);
|
|
|
- window.setContentView(view);
|
|
|
- window.getContentView().measure(0, 0);
|
|
|
- int height = DisplayUtil.dip2px(ct, 270);
|
|
|
- window.setHeight(height);
|
|
|
- window.setWidth(DisplayUtil.getSreechWidth(ct));
|
|
|
- initView(ct, window, view, model, onSureListener);
|
|
|
- window.setBackgroundDrawable(ct.getResources().getDrawable(R.color.background));
|
|
|
- DisplayUtil.backgroundAlpha(ct, 0.4f);
|
|
|
- window.setTouchable(true);
|
|
|
- window.setOutsideTouchable(false);
|
|
|
- window.setFocusable(true);
|
|
|
- window.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
- @Override
|
|
|
- public void onDismiss() {
|
|
|
- DisplayUtil.backgroundAlpha(ct, 1f);
|
|
|
- }
|
|
|
- });
|
|
|
- window.showAtLocation(view, Gravity.CENTER, 0, height);
|
|
|
- }
|
|
|
+ window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
|
+ View view = LayoutInflater.from(ct).inflate(R.layout.pop_play_select, null);
|
|
|
+ window.setContentView(view);
|
|
|
+ window.getContentView().measure(0, 0);
|
|
|
+ int height = DisplayUtil.dip2px(ct, 270);
|
|
|
+ window.setHeight(height);
|
|
|
+ window.setWidth(DisplayUtil.getSreechWidth(ct));
|
|
|
+ initView(ct, window, view, model, onSureListener);
|
|
|
+ window.setBackgroundDrawable(ct.getResources().getDrawable(R.color.background));
|
|
|
+ DisplayUtil.backgroundAlpha(ct, 0.4f);
|
|
|
+ window.setTouchable(true);
|
|
|
+ window.setOutsideTouchable(false);
|
|
|
+ window.setFocusable(true);
|
|
|
+ window.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ DisplayUtil.backgroundAlpha(ct, 1f);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ window.showAtLocation(view, Gravity.CENTER, 0, height);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- private static void initView(final Context ct, final PopupWindow window, View view, final CharitModel model, final OnSureListener onSureListener) {
|
|
|
- TextView nameTv = (TextView) view.findViewById(R.id.nameTv);
|
|
|
- nameTv.setText(model.getName());
|
|
|
- final EditText autoNumEd = (EditText) view.findViewById(R.id.autoNumEd);
|
|
|
- final TextView agreeNoteTv = (TextView) view.findViewById(R.id.agreeNoteTv);
|
|
|
- final TextView payNumTv = (TextView) view.findViewById(R.id.payNumTv);
|
|
|
- final CheckBox agreeCb = (CheckBox) view.findViewById(R.id.agreeCb);
|
|
|
- final RadioGroup selectRg = (RadioGroup) view.findViewById(R.id.selectRg);
|
|
|
- final RadioGroup typeRg = (RadioGroup) view.findViewById(R.id.typeRg);
|
|
|
- final RadioButton wxRb = (RadioButton) view.findViewById(R.id.wxRb);
|
|
|
- final RadioButton aliPlayRb = (RadioButton) view.findViewById(R.id.aliPlayRb);
|
|
|
- payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + 1 + "元");
|
|
|
- autoNumEd.addTextChangedListener(new EditChangeListener() {
|
|
|
- @Override
|
|
|
- public void afterTextChanged(Editable editable) {
|
|
|
- try {
|
|
|
- double num = Double.valueOf(editable.toString());
|
|
|
- payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num);
|
|
|
- } catch (Exception e) {
|
|
|
+ private static void initView(final Context ct, final PopupWindow window, View view, final CharitModel model, final OnSureListener onSureListener) {
|
|
|
+ TextView nameTv = (TextView) view.findViewById(R.id.nameTv);
|
|
|
+ nameTv.setText(model.getName());
|
|
|
+ final EditText autoNumEd = (EditText) view.findViewById(R.id.autoNumEd);
|
|
|
+ final TextView agreeNoteTv = (TextView) view.findViewById(R.id.agreeNoteTv);
|
|
|
+ final TextView payNumTv = (TextView) view.findViewById(R.id.payNumTv);
|
|
|
+ final CheckBox agreeCb = (CheckBox) view.findViewById(R.id.agreeCb);
|
|
|
+ final RadioGroup selectRg = (RadioGroup) view.findViewById(R.id.selectRg);
|
|
|
+ final RadioGroup typeRg = (RadioGroup) view.findViewById(R.id.typeRg);
|
|
|
+ final RadioButton wxRb = (RadioButton) view.findViewById(R.id.wxRb);
|
|
|
+ final RadioButton aliPlayRb = (RadioButton) view.findViewById(R.id.aliPlayRb);
|
|
|
+ payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + 1 + "元");
|
|
|
+ autoNumEd.addTextChangedListener(new EditChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable editable) {
|
|
|
+ try {
|
|
|
+ double num = Double.valueOf(editable.toString());
|
|
|
+ payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num);
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- selectRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
|
|
- hideKeyboard(ct, autoNumEd);
|
|
|
- autoNumEd.setText("");
|
|
|
- int num = 1;
|
|
|
- if (i == R.id.oneRb) {
|
|
|
- num = 1;
|
|
|
- } else if (i == R.id.twoRb) {
|
|
|
- num = 2;
|
|
|
- } else if (i == R.id.fiveRb) {
|
|
|
- num = 5;
|
|
|
- } else if (i == R.id.tenRb) {
|
|
|
- num = 10;
|
|
|
- }
|
|
|
- payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num + "元");
|
|
|
- }
|
|
|
- });
|
|
|
- typeRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
|
|
- hideKeyboard(ct, autoNumEd);
|
|
|
- if (i == R.id.wxRb) {
|
|
|
- ToastUtil.showToast(ct, "暂不支持微信支付");
|
|
|
- aliPlayRb.setChecked(true);
|
|
|
- wxRb.setChecked(false);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- agreeCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
|
|
- if (b) {
|
|
|
- agreeNoteTv.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- view.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- hideKeyboard(ct, autoNumEd);
|
|
|
- }
|
|
|
- });
|
|
|
- view.findViewById(R.id.giftBtn).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- hideKeyboard(ct, autoNumEd);
|
|
|
- if (agreeCb.isChecked()) {
|
|
|
- giftBtn(window, autoNumEd, selectRg, typeRg, model, onSureListener);
|
|
|
- } else {
|
|
|
- agreeNoteTv.setVisibility(View.VISIBLE);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ selectRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
|
|
+ hideKeyboard(ct, autoNumEd);
|
|
|
+ autoNumEd.setText("");
|
|
|
+ int num = 1;
|
|
|
+ if (i == R.id.oneRb) {
|
|
|
+ num = 1;
|
|
|
+ } else if (i == R.id.twoRb) {
|
|
|
+ num = 2;
|
|
|
+ } else if (i == R.id.fiveRb) {
|
|
|
+ num = 5;
|
|
|
+ } else if (i == R.id.tenRb) {
|
|
|
+ num = 10;
|
|
|
+ }
|
|
|
+ payNumTv.setText(StringUtil.getMessage(R.string.new_select_pay) + " " + num + "元");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ typeRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
|
|
+ hideKeyboard(ct, autoNumEd);
|
|
|
+ if (i == R.id.wxRb) {
|
|
|
+ ToastUtil.showToast(ct, "暂不支持微信支付");
|
|
|
+ aliPlayRb.setChecked(true);
|
|
|
+ wxRb.setChecked(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ agreeCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
|
|
+ if (b) {
|
|
|
+ agreeNoteTv.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ view.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ hideKeyboard(ct, autoNumEd);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ view.findViewById(R.id.giftBtn).setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ hideKeyboard(ct, autoNumEd);
|
|
|
+ if (agreeCb.isChecked()) {
|
|
|
+ giftBtn(window, autoNumEd, selectRg, typeRg, model, onSureListener);
|
|
|
+ } else {
|
|
|
+ agreeNoteTv.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- /*隐藏软键盘并显示头布局*/
|
|
|
- private static void hideKeyboard(Context context, EditText chatEd) {
|
|
|
- InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
- imm.hideSoftInputFromWindow(chatEd.getWindowToken(), 0);
|
|
|
- }
|
|
|
+ /*隐藏软键盘并显示头布局*/
|
|
|
+ private static void hideKeyboard(Context context, EditText chatEd) {
|
|
|
+ InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
+ imm.hideSoftInputFromWindow(chatEd.getWindowToken(), 0);
|
|
|
+ }
|
|
|
|
|
|
- private static synchronized void giftBtn(PopupWindow window, EditText autoNumEd, RadioGroup selectRg, RadioGroup typeRg, CharitModel model, OnSureListener onSureListener) {
|
|
|
- double num = 1;
|
|
|
- if (TextUtils.isEmpty(autoNumEd.getText())) {
|
|
|
- int selectId = selectRg.getCheckedRadioButtonId();
|
|
|
- if (selectId == R.id.twoRb) {
|
|
|
- num = 2;
|
|
|
- } else if (selectId == R.id.fiveRb) {
|
|
|
- num = 5;
|
|
|
- } else if (selectId == R.id.tenRb) {
|
|
|
- num = 10;
|
|
|
- }
|
|
|
- } else {
|
|
|
- String message = autoNumEd.getText().toString();
|
|
|
- LogUtil.i("message=" + message);
|
|
|
- try {
|
|
|
- num = Double.valueOf(message);
|
|
|
- } catch (Exception e) {
|
|
|
- if (e != null) {
|
|
|
- LogUtil.i("giftBtn Exception =" + e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- int typeId = typeRg.getCheckedRadioButtonId();
|
|
|
- int type = 2;
|
|
|
- if (typeId == R.id.wxRb) {
|
|
|
- type = 1;
|
|
|
- }
|
|
|
- if (onSureListener != null) {
|
|
|
- onSureListener.sure(num, type, model);
|
|
|
- }
|
|
|
- if (window != null && window.isShowing()) {
|
|
|
- window.dismiss();
|
|
|
- }
|
|
|
- }
|
|
|
+ private static synchronized void giftBtn(PopupWindow window, EditText autoNumEd, RadioGroup selectRg, RadioGroup typeRg, CharitModel model, OnSureListener onSureListener) {
|
|
|
+ double num = 1;
|
|
|
+ if (TextUtils.isEmpty(autoNumEd.getText())) {
|
|
|
+ int selectId = selectRg.getCheckedRadioButtonId();
|
|
|
+ if (selectId == R.id.twoRb) {
|
|
|
+ num = 2;
|
|
|
+ } else if (selectId == R.id.fiveRb) {
|
|
|
+ num = 5;
|
|
|
+ } else if (selectId == R.id.tenRb) {
|
|
|
+ num = 10;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String message = autoNumEd.getText().toString();
|
|
|
+ LogUtil.i("message=" + message);
|
|
|
+ try {
|
|
|
+ num = Double.valueOf(message);
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (e != null) {
|
|
|
+ LogUtil.i("giftBtn Exception =" + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ int typeId = typeRg.getCheckedRadioButtonId();
|
|
|
+ int type = 2;
|
|
|
+ if (typeId == R.id.wxRb) {
|
|
|
+ type = 1;
|
|
|
+ }
|
|
|
+ if (onSureListener != null) {
|
|
|
+ onSureListener.sure(num, type, model);
|
|
|
+ }
|
|
|
+ if (window != null && window.isShowing()) {
|
|
|
+ window.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- public interface OnSureListener {
|
|
|
- void sure(double num, int type, CharitModel model);
|
|
|
- }
|
|
|
+ public interface OnSureListener {
|
|
|
+ void sure(double num, int type, CharitModel model);
|
|
|
+ }
|
|
|
}
|