package com.sabirjan.liulanqi.Dialog;

import com.sabirjan.android.R;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AutoCompleteTextView;
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 Dialog_InputURL extends Dialog implements OnClickListener {

	Button btnYes;
	Button btnno;
	Activity main;
	AutoCompleteTextView text;
	MyListener myListener;
	public Dialog_InputURL(Context context,MyListener mListener) {
		super(context);
		myListener=mListener;
		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.dialog_inputurl);
		TextView txt_msgtitle=(TextView)this.findViewById(R.id.topview);
		//TextView txt_msgmsg=(TextView)this.findViewById(R.id.txtdilalogmsg);
		text=(AutoCompleteTextView)this.findViewById(R.id.txt_url);
		
	    btnYes=(Button)this.findViewById(R.id.GoButton);
		btnno=(Button)this.findViewById(R.id.CancelButton);
		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==btnYes)
		{

			if(text.getText().length()>0)
			{
				this.dismiss();
				myListener.refreshActivity(String.valueOf(text.getText()));
			}
			
		}
		else if(v==btnno)
		{	
		//	Activity_B.SelectMain();
			this.dismiss();
			myListener.refreshActivity("");
		}
	}

	

}

