package com.sabirjan.liulanqi.Dialog;

import com.sabirjan.android.R;
import com.sabirjan.android.TSNews_Activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

/** Class Must extends with Dialog */
/** Implement onClickListener to dismiss dialog when OK Button is pressed */
public class CustomizeDialog extends Dialog implements OnClickListener {

	Button btnYes;
	Button btnno;
	Activity main;
	Context con;
	public CustomizeDialog(Context context) {
		super(context);
		con=context;
		Typeface typeface=Typeface.createFromAsset(context.getAssets(),"fonts/UKIJTuT.ttf");
		main=(Activity) context;
		/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		/** Design the dialog in main.xml file */
		setContentView(R.layout.dialogexit);
		TextView txt_msgtitle=(TextView)this.findViewById(R.id.txtdilalogtitle);
		TextView txt_msgmsg=(TextView)this.findViewById(R.id.txtdilalogmsg);
		
		btnYes=(Button)this.findViewById(R.id.yesButton);
		btnno=(Button)this.findViewById(R.id.noButton);
		btnYes.setTypeface(typeface);
		btnno.setTypeface(typeface);
		txt_msgtitle.setTypeface(typeface);
		txt_msgmsg.setTypeface(typeface);
		btnYes.setOnClickListener(this);
		btnno.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		/** When OK Button is clicked, dismiss the dialog */
		if(v==btnno)
		{
			this.dismiss();
		}
		else if(v==btnYes)
		{try
		{
			TSNews_Activity cls=(TSNews_Activity)con;
			cls.finish();
			// android.os.Process.killProcess(android.os.Process.myPid());  
		//	  System.exit(0);
		}
		catch(Exception ex)
		{
			
		}
		}
	}

}

