工具类--PopDialogUtils 窗口提示工具类

public class PopDialogUtils {

    private Context mContext;

    public PopDialogUtils(Context context){
        mContext = context;
    }

    /**
     * 两个按钮的对话框
     *  “确定” “取消样式的对话框
     * @param parent
     * @param contentId 提示内容id
     * @param sureId    确定string id
     * @param cancelId  取消string id
     * @return
     */
    public PopupWindow showTipPop1(final View parent, int contentId, int sureId, int cancelId, View.OnClickListener listener) {

         PopupWindow tPop;

         View dialogView = LayoutInflater.from(mContext).inflate(R.layout.player_tip, null, false);

         tPop = new PopupWindow(dialogView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, true);
         tPop.setFocusable(true);//创建弹出的对话框

         TextView tipTv = (TextView) dialogView.findViewById(R.id.tv_tip);
         tipTv.setText(contentId);//提示内容

         TextView okbtn = (TextView) dialogView.findViewById(R.id.btn_ok);
         okbtn.setText(sureId);//确定按钮
         okbtn.setOnClickListener(listener);

         TextView cancelbtn = (TextView) dialogView.findViewById(R.id.btn_cancel);
         cancelbtn.setText(cancelId);//取消按钮
         cancelbtn.setOnClickListener(listener);

         tPop.showAtLocation(parent, Gravity.TOP | Gravity.CENTER, 0, 0);

         return  tPop;
    }

    /**
     * 一个按钮的对话框
     * “我知道了等样式的对话框
     * @param parent
     * @param contentId
     * @param sureId
     * @param listener
     * @return
     */
    public PopupWindow showTipPop2(final View parent, String color,int contentId, int sureId, View.OnClickListener listener) {

        PopupWindow tPop;

        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.player_tip, null, false);

        tPop = new PopupWindow(dialogView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, true);
        tPop.setFocusable(true);//创建弹出的对话框

        TextView tipTv = (TextView) dialogView.findViewById(R.id.tv_tip);
        tipTv.setText(contentId);//提示内容

        TextView okbtn = (TextView) dialogView.findViewById(R.id.btn_ok);
        okbtn.setText(sureId);//确定按钮
        okbtn.setTextColor(Color.parseColor(color));
        okbtn.setOnClickListener(listener);

        TextView cancelbtn = (TextView) dialogView.findViewById(R.id.btn_cancel);
        cancelbtn.setVisibility(View.GONE);

        LinearLayout layout = (LinearLayout) dialogView.findViewById(R.id.ll_tips_line);
        layout.setVisibility(View.GONE);

        tPop.showAtLocation(parent, Gravity.TOP | Gravity.CENTER, 0, 0);
        return  tPop;
    }


    /**
     * 两行提示文字
     * 搜索样式对话框
     * @param parent
     * @param contentId
     * @param sureId
     * @param listener
     * @return
     */
    public PopupWindow showTipPop3(final View parent, int contentId, int sureId, View.OnClickListener listener) {

        PopupWindow tPop;

        View dialogView = LayoutInflater.from(mContext).inflate(R.layout.common_ppw1, null, false);

        tPop = new PopupWindow(dialogView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, true);
        tPop.setFocusable(true);//创建弹出的对话框

        TextView tipTv = (TextView) dialogView.findViewById(R.id.tv_tip2);
        tipTv.setText(contentId);//提示内容

        TextView okbtn = (TextView) dialogView.findViewById(R.id.btn_ok);
        okbtn.setText(sureId);//确定按钮
        okbtn.setOnClickListener(listener);

        TextView cancelbtn = (TextView) dialogView.findViewById(R.id.btn_cancel);
        cancelbtn.setVisibility(View.GONE);

        tPop.showAtLocation(parent, Gravity.TOP | Gravity.CENTER, 0, 0);
        return  tPop;
    }


}
 public static PopupWindow choiceCardModeWindows(final Context context, final View vFather,
                                                    OnClickListener onClickListener, boolean isCanClose, int modeblue, int modenfc) {
        View view = LayoutInflater.from(context).inflate(
                R.layout.popwindows_cardmode_choice, null);
        final PopupWindow pop = new PopupWindow(view,
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, false);
        pop.setBackgroundDrawable(new BitmapDrawable());
        pop.setOutsideTouchable(true);
        pop.showAtLocation(vFather, Gravity.CENTER, 0, 0);
        pop.setFocusable(true);
        final LinearLayout selectCardChannel = (LinearLayout) view
                .findViewById(R.id.card_mode_ll_channel);
        TranslateAnimation animation = (TranslateAnimation) AnimationUtils
                .loadAnimation(context, R.anim.share_red_envelopes_in);
        animation.setDuration(300);
        animation.setFillAfter(true);
        selectCardChannel.setAnimation(animation);
        pop.showAsDropDown(vFather);
        RelativeLayout re = (RelativeLayout) view.findViewById(R.id.rv_pop_cardmode);
        final RadioButton bluetooth_rb = (RadioButton) view.findViewById(R.id.bluetooth_rb);
        final RadioButton nfcsim_rb = (RadioButton) view.findViewById(R.id.nfcsim_rb);
        final RadioButton card_rb = (RadioButton) view.findViewById(R.id.card_rb);
//        RadioButton card_rb = (RadioButton) view.findViewById(R.id.card_rb);
        final CheckBox saveMyChoice = (CheckBox) view.findViewById(R.id.save_readcard_cb);
        TextView sure_bt = (TextView) view.findViewById(R.id.btn_login_on);
        TextView lin1 = (TextView) view.findViewById(R.id.cadrmode_lin1);


        if (modeblue == 1) {
            bluetooth_rb.setVisibility(View.VISIBLE);
            //判断如果有nfc或者全中断则显示它下面的线
        }
        if (modenfc == 1) {
            card_rb.setVisibility(View.VISIBLE);
            lin1.setVisibility(View.VISIBLE);

        }

        re.setBackgroundColor(Color.parseColor("#A0000000"));

        sure_bt.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                final Intent intent = new Intent();
                 if (saveMyChoice.isChecked()) {
                    ContentManager.getInstance().setShowCardWindow(false);
                    if (card_rb.isChecked()) {
                        ContentManager.getInstance().setReadCardMode("common_card");
                        intent.setClass(context, NfcReadCardActivity.class);
                    } else if (bluetooth_rb.isChecked()) {
                        intent.setClass(context, ChoiceBluetoothActivity.class);
   				    	Bundle bundle = new Bundle();
 						bundle.putString("channel", "readCard");
 						intent.putExtras(bundle);
                        ContentManager.getInstance().setReadCardMode("bluetooth");
                    }
                }else{
                     if (card_rb.isChecked()) {
                          intent.setClass(context, NfcReadCardActivity.class);
                     } else if (bluetooth_rb.isChecked()) {
                         intent.setClass(context, ChoiceBluetoothActivity.class);
                         Bundle bundle = new Bundle();
                         bundle.putString("channel", "readCard");
                         intent.putExtras(bundle);
                      }
                 }
                context.startActivity(intent);
                pop.dismiss();

            }
        });
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值