www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

Main.java (1241B)


      1 package org.pticlic;
      2 
      3 import org.pticlic.js.JavaScriptInterface;
      4 import org.pticlic.model.Constant;
      5 
      6 import android.app.Activity;
      7 import android.os.Bundle;
      8 import android.webkit.WebChromeClient;
      9 import android.webkit.WebView;
     10 
     11 public class Main extends Activity {
     12 	
     13 	private WebView webView;
     14 	private JavaScriptInterface js = null;
     15 	
     16 	/** Called when the activity is first created. */
     17 	@Override
     18 	public void onCreate(Bundle savedInstanceState) {
     19 		super.onCreate(savedInstanceState);
     20 		setContentView(R.layout.frontpage);
     21 
     22 		webView = (WebView) findViewById(R.id.webview);
     23 		webView.getSettings().setJavaScriptEnabled(true);
     24 		webView.setWebChromeClient(new WebChromeClient());
     25 		webView.setVerticalScrollBarEnabled(false);
     26 		webView.setHorizontalScrollBarEnabled(false);
     27 
     28 		js = new JavaScriptInterface(this, webView);
     29 		webView.addJavascriptInterface(js, "PtiClicAndroid");
     30 	}
     31 	
     32 	@Override
     33 	protected void onStart() {
     34 		super.onStart();
     35 		webView.loadUrl(Constant.SERVER + Constant.SERVER_URL);
     36 	}
     37 	
     38 	@Override
     39 	public void onBackPressed() {
     40 		if (js.getScreen().equals("splash") || js.getScreen().equals("frontpage"))
     41 			finish();
     42 		else
     43 			webView.goBack();
     44 	}
     45 	
     46 	@Override
     47 	protected void onStop() {
     48 		super.onStop();
     49 
     50 		finish();
     51 	}
     52 }