package com.bono88.CplTT;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.webkit.WebView;
import android.widget.ImageButton;
import android.webkit.WebChromeClient;
public class CplTimeTableActivity extends Activity {
private ImageButton bt_input;
private ImageButton bt_setting;
private WebView wv_table;
private ProgressDialog pb;
private InputDialog input;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bt_input = (ImageButton) findViewById(R.id.bt_input);
bt_setting = (ImageButton) findViewById(R.id.bt_setting);
wv_table = (WebView) findViewById(R.id.wv_show_table);
input = new InputDialog(CplTimeTableActivity.this, this);
bt_input.setOnTouchListener(new ChangeBg());
bt_setting.setOnTouchListener(new ChangeBg());
bt_input.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
new AlertDialog.Builder(this).setMessage(e.toString()).show();
public void setTable(String classe, int data) {
String link = "http://time.spailocarno.ch/SpaiOrario/OrarioStudenti/";
link = link + "0" + data + "/c/c";
link = link + data + "/c/c";
if (Integer.parseInt(classe) < 10) {
link = link + "0000" + classe + ".htm";
} else if (Integer.parseInt(classe) < 100) {
link = link + "000" + classe + ".htm";
link = link + "00" + classe + ".htm";
wv_table = (WebView) findViewById(R.id.wv_show_table);
wv_table.setInitialScale(100);
wv_table.getSettings().setBuiltInZoomControls(true);
pb = new ProgressDialog(CplTimeTableActivity.this);
pb.setMessage("Sto scaricando l'orario");
wv_table.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (newProgress == 100) {
public class ChangeBg implements OnTouchListener {
public boolean onTouch(View arg0, MotionEvent arg1) {
switch (arg1.getAction()) {
case MotionEvent.ACTION_DOWN: {
((ImageButton) arg0).setBackgroundColor(Color.DKGRAY);
case MotionEvent.ACTION_UP: {
((ImageButton) arg0).setBackgroundColor(Color.TRANSPARENT);