package com.duben.microtribe.ui.widgets;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;

import com.duben.microtribe.R;


public class PayAgreementDialog extends Dialog {
    private Context context;
    private LayoutParams lp;
    private DialogListener listener;

    private ImageView iv_agreement_quit;
    private TextView tv_agreement_next;

    public PayAgreementDialog(Context context, DialogListener listener) {
        super(context, R.style.dialog);
        this.context = context;
        this.listener = listener;
        setContentView(R.layout.dialog_agreement);
        // 设置window属性
        lp = getWindow().getAttributes();
        lp.gravity = Gravity.BOTTOM;
        lp.width = LayoutParams.MATCH_PARENT;
        lp.windowAnimations = R.style.DialogAnimBottom;
        getWindow().setAttributes(lp);

        // 设置外部不可关闭
        setCancelable(false);
        setCanceledOnTouchOutside(false);
        setOnKeyListener(new OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                if (i == keyEvent.KEYCODE_BACK) {
                    return true;
                }
                return false;
            }
        });

        // 查找View
        tv_agreement_next = (TextView) findViewById(R.id.tv_agreement_next);
        iv_agreement_quit = (ImageView) findViewById(R.id.iv_agreement_quit);
        iv_agreement_quit.setOnClickListener(listener);
        tv_agreement_next.setOnClickListener(listener);

//        new Handler().postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                YoYo.with(Techniques.Pulse).duration(500).repeat(-1).playOn(tv_agreement_next);
//            }
//        }, 300);
    }
}
