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.TextView;


import com.yyrh.utils.ResourceUtil;


public class SingleButtonDialog extends Dialog {

	private	static TextView bt_exit_game,content;


	private static SingleButtonDialog dialog;

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

	}
	public  static class  Builder{
		private Context context;
		private OnClickListener positiveButtonClickListener;

		public Builder(Context context){ this.context = context;}
		public Builder setPositiveButton(OnClickListener listener){
			this.positiveButtonClickListener = listener;
			return this;
		}

		public void  dialogDismiss(){dialog.dismiss();}
		public SingleButtonDialog Create(String msg){
			{
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				dialog = new SingleButtonDialog(context,ResourceUtil.getStyleId(context,"hnyy_base_dialog"));
				View layout;

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



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

				bt_exit_game =(TextView) dialog.findViewById(ResourceUtil.getId(context,
						"confirm"));
				content =(TextView) dialog.findViewById(ResourceUtil.getId(context,
						"content"));
				content.setText(msg);

				if (bt_exit_game!=null){
					bt_exit_game.setOnClickListener(new View.OnClickListener() {
						@Override
						public void onClick(View view) {
							positiveButtonClickListener.onClick(dialog,DialogInterface.BUTTON_POSITIVE);
						}
					});
				}

				}
				return dialog;
			}
		}




}
