package com.sabirjan.android;




import com.sabirjan.Dialog.Custom_WaitDialog;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class Qita_Activity extends Activity{

	
	WebView web;
	Custom_WaitDialog dilg;
	String url="";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.qita);
		Intent in=this.getIntent();
		 url=in.getStringExtra("Url");
		 
		web=(WebView)findViewById(R.id.webview_qita);
		dilg=new Custom_WaitDialog(this);
		dilg.show();
		
	    new Thread(new myThread()).start();
	}
		
	class myThread extends Thread
	{
		public void run()
		{
			 web.getSettings().setJavaScriptEnabled(true);
			    web.getSettings().setLoadsImagesAutomatically(true);
			    web.getSettings().setSupportZoom(true);
			    web.getSettings().setBuiltInZoomControls(true);
			//    
			   
			    web.getSettings().setPluginsEnabled(true);
			    web.getSettings().setBlockNetworkImage(false);
			    web.getSettings().setUserAgentString("Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10");
			    web.isClickable();
			    web.getSettings().setSupportMultipleWindows(false);
			    web.setWebViewClient(new MyWebClinet());
			    web.setWebChromeClient(new MyWebChromeClient());
			    web.loadUrl("file:///android_asset/qita/"+url+".htm");
		}
	}
	
	
	  class MyWebChromeClient extends WebChromeClient
	    {
	    	@Override
			public void onProgressChanged(WebView view,	int newProgress)
	    	{
				
				super.onProgressChanged(view, newProgress);
			}
	    }
	  class MyWebClinet extends WebViewClient
	    {
	    	  	@Override
				public void onPageFinished(WebView view, String url) 
	    	  	{
	    	  		dilg.dismiss();
	    	  		super.onPageFinished(view, url);
				}

				@Override
				public void onPageStarted(WebView view, String url,
						Bitmap favicon) {
					super.onPageStarted(view, url, favicon);
				}

				
				@Override
				public void onReceivedError(WebView view,int errorCode, String description,String failingUrl) 
				{
					
					super.onReceivedError(view, errorCode, description, failingUrl);
				} 
				
	    }//End WebViewClinet Class
}

