1 |
package dk.thoerup.traininfo;
|
2 |
|
3 |
import android.app.Activity;
|
4 |
import android.content.Intent;
|
5 |
import android.net.Uri;
|
6 |
import android.os.Bundle;
|
7 |
import android.os.Handler;
|
8 |
import android.util.Log;
|
9 |
import android.view.View;
|
10 |
import android.view.Window;
|
11 |
import android.view.View.OnClickListener;
|
12 |
import android.widget.Button;
|
13 |
|
14 |
import com.nullwire.trace.ExceptionHandler;
|
15 |
|
16 |
import dk.thoerup.androidutils.CheckUpdates;
|
17 |
import dk.thoerup.traininfo.provider.ProviderFactory;
|
18 |
|
19 |
public class WelcomeScreen extends Activity{
|
20 |
public enum ListType {
|
21 |
ListNearest,
|
22 |
ListSearch,
|
23 |
ListFavorites
|
24 |
}
|
25 |
|
26 |
Handler handler = new Handler();
|
27 |
|
28 |
@Override
|
29 |
public void onCreate(Bundle savedInstanceState) {
|
30 |
|
31 |
super.onCreate(savedInstanceState);
|
32 |
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
33 |
setContentView(R.layout.welcome);
|
34 |
|
35 |
Button nearestButton = (Button) findViewById(R.id.nearest);
|
36 |
nearestButton.setOnClickListener( new StationListListener(ListType.ListNearest));
|
37 |
|
38 |
Button searchButton = (Button) findViewById(R.id.search);
|
39 |
searchButton.setOnClickListener( new StationListListener(ListType.ListSearch));
|
40 |
|
41 |
Button favoritesButton = (Button) findViewById(R.id.favorites);
|
42 |
favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites));
|
43 |
|
44 |
Button aboutButton = (Button) findViewById(R.id.about);
|
45 |
aboutButton.setOnClickListener( new AboutListener() );
|
46 |
|
47 |
ExceptionHandler.register(this, "http://t-hoerup.dk/android/trace.php");
|
48 |
|
49 |
CheckUpdates update = new CheckUpdates();
|
50 |
update.checkForUpdates(this, "http://t-hoerup.dk/android/traininfo/version.txt", "TrainInfo DK", null);
|
51 |
/*
|
52 |
Runnable r = new Runnable() {
|
53 |
@Override
|
54 |
public void run() {
|
55 |
View splash = findViewById(R.id.splash);
|
56 |
splash.setVisibility(View.GONE);
|
57 |
}
|
58 |
};
|
59 |
handler.postDelayed(r, 1500);
|
60 |
*/
|
61 |
}
|
62 |
|
63 |
|
64 |
|
65 |
@Override
|
66 |
protected void onDestroy() {
|
67 |
super.onDestroy();
|
68 |
ProviderFactory.purgeOldEntries(); //exiting application, do some cleanup
|
69 |
}
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
class AboutListener implements OnClickListener {
|
75 |
|
76 |
@Override
|
77 |
public void onClick(View v) {
|
78 |
/*
|
79 |
String appName = WelcomeScreen.this.getResources().getString(R.string.app_name);
|
80 |
String ver = WelcomeScreen.this.getResources().getString(R.string.app_version);
|
81 |
|
82 |
StringBuffer message = new StringBuffer();
|
83 |
message.append(appName);
|
84 |
message.append(" v").append(ver).append("\n");
|
85 |
message.append("By Torben H. Nielsen\n");
|
86 |
|
87 |
MessageBox.showMessage(WelcomeScreen.this, message.toString());*/
|
88 |
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.t-hoerup.dk/android/traininfo/"));
|
89 |
startActivity(browserIntent);
|
90 |
}
|
91 |
|
92 |
}
|
93 |
|
94 |
class StationListListener implements OnClickListener{
|
95 |
ListType launchType;
|
96 |
StationListListener(ListType type) {
|
97 |
launchType = type;
|
98 |
}
|
99 |
|
100 |
@Override
|
101 |
public void onClick(View v) {
|
102 |
Intent intent = new Intent(WelcomeScreen.this, StationList.class);
|
103 |
intent.putExtra("type", launchType);
|
104 |
WelcomeScreen.this.startActivity(intent);
|
105 |
}
|
106 |
|
107 |
}
|
108 |
}
|