package com.example.writeepc.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.writeepc.R;


/**
 * Created by wangh on 2020/10/10-14:57。
 */
public class TipsDialog extends Dialog implements View.OnClickListener {
    public String tip;
    public TextView textView,button;
    private ImageView imageView;
    private boolean imageState=true;
    public TipsDialog(@NonNull Context context) {
        super(context, R.style.MyMiddleDialogStyle);
    }

    public void setTip(String tip) {
        this.tip = tip;
    }

    public void setTip(boolean imageState , String tip) {
        this.imageState = imageState;
        this.tip = tip;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_tip);
//        imageState=false;
        imageView=findViewById(R.id.tip_image);
        textView=findViewById(R.id.tip_tip);
        button=findViewById(R.id.dialog_no);
        button.setOnClickListener(this);
    }

    @Override
    public void show() {
        super.show();
        textView.setText(tip);
        if (imageState){
            imageView.setImageResource(R.mipmap.chenggong);
        }else {
            imageView.setImageResource(R.mipmap.icon_jinggao);
        }
        imageState=false;
    }

    @Override
    public void onClick(View view) {
        dismiss();
    }
}
