package com.yyrh.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yyrh.utils.ResourceUtil;

import static com.yyrh.constant.SDKSettings.isLandscape;


public class CustomExitGameDialog extends Dialog {

	private	static Button bt_exit_game;
	private static Button bt_goon_game;
	private static TextView hnyy_issure_exit;
	private static CustomExitGameDialog dialog;

	public CustomExitGameDialog(Context context, int theme) {
		super(context, theme);

	}
	public  static class  Builder{
		private Context context;
		private OnClickListener positiveButtonClickListener;
		private OnClickListener negativeButtonClickListener;
		public Builder(Context context){ this.context = context;}
		public Builder setPositiveButton(OnClickListener listener){
			this.positiveButtonClickListener = listener;
			return this;
		}
		public Builder setnegativeButton(OnClickListener listener){
			this.negativeButtonClickListener = listener;
			return this;
		}
		public void setTitle(String title){
			hnyy_issure_exit.setText(title);
		}
		public void  dialogDismiss(){dialog.dismiss();}
		public CustomExitGameDialog Create(){
			{
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				dialog = new CustomExitGameDialog(context,ResourceUtil.getStyleId(context,"hnyy_base_dialog"));


				View layout =  inflater.inflate(ResourceUtil.getLayoutId(context, "hnyy_exit_game_dialog"),null);


				if (!isLandscape){
					LinearLayout ll_exit_game = layout.findViewById(ResourceUtil.getId(context, "ll_exit_game"));
					ll_exit_game.setScaleX(0.9f);
					ll_exit_game.setScaleY(0.9f);
				}

				dialog.addContentView(layout,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

				bt_exit_game =(Button) dialog.findViewById(ResourceUtil.getId(context,
						"find_pwd_confirm_btn"));
				bt_goon_game = (Button) dialog.findViewById(ResourceUtil.getId(context,
						"find_pwd_cancel_btn"));
				if (bt_exit_game!=null){
					bt_exit_game.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View view) {
							positiveButtonClickListener.onClick(dialog,DialogInterface.BUTTON_POSITIVE);
						}
					});
				}
				if (bt_goon_game!=null){
					bt_goon_game.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View view) {
							negativeButtonClickListener.onClick(dialog,DialogInterface.BUTTON_NEGATIVE);
						}
					});
				}
				hnyy_issure_exit = dialog.findViewById(ResourceUtil.getId(context,
						"hnyy_issure_exit"));
				return dialog;
			}
		}


	}


}
