package com.android.chmo.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.android.chmo.R;
import com.android.chmo.app.ChmoApplication;
import com.android.chmo.utils.PixelUtils;

/**
 * Created by Administrator on 2018/8/6.
 */

public class CallRewardDialog extends Dialog {

    private RewardSelectListener listener;

    public CallRewardDialog(Context context) {
        super(context, R.style.TransDialog);
    }

    public CallRewardDialog setSelectListener(RewardSelectListener listener) {
        this.listener = listener;
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_call);
        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = PixelUtils.getWindowWidth();
        lp.gravity = Gravity.BOTTOM;
        window.setAttributes(lp);

        findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        TextView balanceView = (TextView) findViewById(R.id.balance);
        balanceView.setText("余额：" + ChmoApplication.getApp().getLoginUser().coin_a + "元");

        findViewById(R.id.send_50).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != listener) {
                    listener.onSelect(50,CallRewardDialog.this);
                }
            }
        });
        findViewById(R.id.send_100).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != listener) {
                    listener.onSelect(100,CallRewardDialog.this);
                }
            }
        });
        findViewById(R.id.send_200).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != listener) {
                    listener.onSelect(200, CallRewardDialog.this);
                }
            }
        });
    }

    public interface RewardSelectListener {
        void onSelect(int value, Dialog dialog);
    }
}
