/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/ShortcutActivity.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/ShortcutActivity.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1151 by torben, Fri Oct 1 17:47:49 2010 UTC revision 1735 by torben, Thu Mar 15 19:46:10 2012 UTC
# Line 1  Line 1 
1  package dk.thoerup.traininfo;  package dk.thoerup.traininfo;
2    
3    import java.io.InvalidClassException;
4    
5  import android.app.Activity;  import android.app.Activity;
6  import android.content.Intent;  import android.content.Intent;
7  import android.os.Bundle;  import android.os.Bundle;
8  import android.os.Parcelable;  import android.os.Parcelable;
9    import android.util.Log;
10  import android.view.View;  import android.view.View;
11  import android.view.View.OnClickListener;  import android.view.View.OnClickListener;
12  import android.widget.Button;  import android.widget.Button;
13  import android.widget.TextView;  import android.widget.TextView;
14  import android.widget.Toast;  import android.widget.Toast;
15  import dk.thoerup.android.traininfo.common.StationBean.StationEntry;  import dk.thoerup.android.traininfo.common.StationEntry;
16  import dk.thoerup.traininfo.WelcomeScreen.ListType;  import dk.thoerup.traininfo.WelcomeScreen.ListType;
17    import dk.thoerup.traininfo.provider.OfflineStationProvider;
18    import dk.thoerup.traininfo.provider.ProviderFactory;
19    import dk.thoerup.traininfo.util.StationEntryCsv;
20    
21  public class ShortcutActivity extends Activity {  public class ShortcutActivity extends Activity {
22            
# Line 35  public class ShortcutActivity extends Ac Line 41  public class ShortcutActivity extends Ac
41          if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {          if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
42                  setContentView(R.layout.shortcut);                  setContentView(R.layout.shortcut);
43                                    
44                    OfflineStationProvider osp = (OfflineStationProvider) ProviderFactory.getStationProvider();
45                    
46                    try {
47                                    osp.loadStations(this);
48                            }                                                                                              
49                            catch (InvalidClassException e) {
50                                    Log.i("TrainInfo", "invalid class - do a new download of stationlist");
51                            }
52                            catch (Exception e) {
53                                    Toast.makeText(this, "" + e.getMessage(), Toast.LENGTH_SHORT).show();
54                                    Log.e("TrainInfo", "load error", e);
55                            }
56    
57                    
58                  Button cancelBtn = (Button) findViewById(R.id.shortcut_cancel);                  Button cancelBtn = (Button) findViewById(R.id.shortcut_cancel);
59                  cancelBtn.setOnClickListener( new OnClickListener() {                  cancelBtn.setOnClickListener( new OnClickListener() {
60    
# Line 67  public class ShortcutActivity extends Ac Line 87  public class ShortcutActivity extends Ac
87                  String stationStr = intent.getStringExtra("station");                  String stationStr = intent.getStringExtra("station");
88                                    
89                  if (stationStr != null) { //haven't reproduced it, but got a stacktrace where stationStr apparently was null                  if (stationStr != null) { //haven't reproduced it, but got a stacktrace where stationStr apparently was null
90                          StationEntry station = StationEntry.fromCSV(stationStr);                          StationEntry station = StationEntryCsv.fromCSV(stationStr);
91    
92                          Intent launcher = new Intent( this, DepartureList.class );                          Intent launcher = new Intent( this, DepartureList.class );
93                          launcher.putExtra("stationbean", station);                          launcher.putExtra("stationbean", station);
# Line 109  public class ShortcutActivity extends Ac Line 129  public class ShortcutActivity extends Ac
129          // First, set up the shortcut intent.            // First, set up the shortcut intent.  
130          Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);          Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
131          shortcutIntent.setClassName(this, this.getClass().getName());          shortcutIntent.setClassName(this, this.getClass().getName());
132          shortcutIntent.putExtra("station", station.toCSV() );          shortcutIntent.putExtra("station", StationEntryCsv.toCSV(station) );
133    
134                    
135          // Then, set up the container intent (the response to the caller)          // Then, set up the container intent (the response to the caller)

Legend:
Removed from v.1151  
changed lines
  Added in v.1735

  ViewVC Help
Powered by ViewVC 1.1.20