/[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 731 by torben, Tue May 18 14:02:13 2010 UTC revision 1562 by torben, Fri Jul 8 16:26:09 2011 UTC
# Line 8  import android.view.View; Line 8  import android.view.View;
8  import android.view.View.OnClickListener;  import android.view.View.OnClickListener;
9  import android.widget.Button;  import android.widget.Button;
10  import android.widget.TextView;  import android.widget.TextView;
11    import android.widget.Toast;
12    import dk.thoerup.android.traininfo.common.StationEntry;
13  import dk.thoerup.traininfo.WelcomeScreen.ListType;  import dk.thoerup.traininfo.WelcomeScreen.ListType;
14    import dk.thoerup.traininfo.util.StationEntryCsv;
15    
16  public class ShortcutActivity extends Activity {  public class ShortcutActivity extends Activity {
17            
# Line 16  public class ShortcutActivity extends Ac Line 19  public class ShortcutActivity extends Ac
19      final static int SHOW_STATIONS = 2000;      final static int SHOW_STATIONS = 2000;
20            
21            
22      StationBean station;      StationEntry station;
23      Button okBtn;      Button okBtn;
24    
25      @Override      @Override
# Line 63  public class ShortcutActivity extends Ac Line 66  public class ShortcutActivity extends Ac
66          } else {                  } else {        
67                  //launched by the user clicking on the shortcut                  //launched by the user clicking on the shortcut
68                  String stationStr = intent.getStringExtra("station");                  String stationStr = intent.getStringExtra("station");
69                  StationBean station = StationBean.fromCSV(stationStr);                  
70                    if (stationStr != null) { //haven't reproduced it, but got a stacktrace where stationStr apparently was null
71                            StationEntry station = StationEntryCsv.fromCSV(stationStr);
72    
73                  Intent launcher = new Intent( this, DepartureList.class );                          Intent launcher = new Intent( this, DepartureList.class );
74                  launcher.putExtra("stationbean", station);                          launcher.putExtra("stationbean", station);
75                  startActivityForResult(launcher, SHOW_DEPARTURES);                          startActivityForResult(launcher, SHOW_DEPARTURES);
76                    } else {
77                            Toast.makeText(this, "Invalid TrainInfo shortcut - please delete and re-create", Toast.LENGTH_LONG).show();
78                    }
79          }          }
80      }      }
81    
# Line 98  public class ShortcutActivity extends Ac Line 106  public class ShortcutActivity extends Ac
106       * with an appropriate Uri for your content, but any Intent will work here as long as it       * with an appropriate Uri for your content, but any Intent will work here as long as it
107       * triggers the desired action within your Activity.       * triggers the desired action within your Activity.
108       */       */
109      private void setupShortcut(StationBean station) {      private void setupShortcut(StationEntry station) {
110          // First, set up the shortcut intent.            // First, set up the shortcut intent.  
111          Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);          Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
112          shortcutIntent.setClassName(this, this.getClass().getName());          shortcutIntent.setClassName(this, this.getClass().getName());
113          shortcutIntent.putExtra("station", station.toCSV() );          shortcutIntent.putExtra("station", StationEntryCsv.toCSV(station) );
114    
115                    
116          // Then, set up the container intent (the response to the caller)          // Then, set up the container intent (the response to the caller)
# Line 128  public class ShortcutActivity extends Ac Line 136  public class ShortcutActivity extends Ac
136                                                    
137                  case SHOW_STATIONS:                  case SHOW_STATIONS:
138                          if (data != null) {                          if (data != null) {
139                                  station = (StationBean) data.getSerializableExtra("station");                                  station = (StationEntry) data.getSerializableExtra("station");
140                                  if (station != null) {                                  if (station != null) {
141                                          okBtn.setEnabled(true);                                          okBtn.setEnabled(true);
142                                                                                    

Legend:
Removed from v.731  
changed lines
  Added in v.1562

  ViewVC Help
Powered by ViewVC 1.1.20