/[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 1151 by torben, Fri Oct 1 17:47:49 2010 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.StationBean.StationEntry;
13  import dk.thoerup.traininfo.WelcomeScreen.ListType;  import dk.thoerup.traininfo.WelcomeScreen.ListType;
14    
15  public class ShortcutActivity extends Activity {  public class ShortcutActivity extends Activity {
# Line 16  public class ShortcutActivity extends Ac Line 18  public class ShortcutActivity extends Ac
18      final static int SHOW_STATIONS = 2000;      final static int SHOW_STATIONS = 2000;
19            
20            
21      StationBean station;      StationEntry station;
22      Button okBtn;      Button okBtn;
23    
24      @Override      @Override
# Line 63  public class ShortcutActivity extends Ac Line 65  public class ShortcutActivity extends Ac
65          } else {                  } else {        
66                  //launched by the user clicking on the shortcut                  //launched by the user clicking on the shortcut
67                  String stationStr = intent.getStringExtra("station");                  String stationStr = intent.getStringExtra("station");
68                  StationBean station = StationBean.fromCSV(stationStr);                  
69                    if (stationStr != null) { //haven't reproduced it, but got a stacktrace where stationStr apparently was null
70                            StationEntry station = StationEntry.fromCSV(stationStr);
71    
72                  Intent launcher = new Intent( this, DepartureList.class );                          Intent launcher = new Intent( this, DepartureList.class );
73                  launcher.putExtra("stationbean", station);                          launcher.putExtra("stationbean", station);
74                  startActivityForResult(launcher, SHOW_DEPARTURES);                          startActivityForResult(launcher, SHOW_DEPARTURES);
75                    } else {
76                            Toast.makeText(this, "Invalid TrainInfo shortcut - please delete and re-create", Toast.LENGTH_LONG).show();
77                    }
78          }          }
79      }      }
80    
# Line 98  public class ShortcutActivity extends Ac Line 105  public class ShortcutActivity extends Ac
105       * 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
106       * triggers the desired action within your Activity.       * triggers the desired action within your Activity.
107       */       */
108      private void setupShortcut(StationBean station) {      private void setupShortcut(StationEntry station) {
109          // First, set up the shortcut intent.            // First, set up the shortcut intent.  
110          Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);          Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
111          shortcutIntent.setClassName(this, this.getClass().getName());          shortcutIntent.setClassName(this, this.getClass().getName());
# Line 128  public class ShortcutActivity extends Ac Line 135  public class ShortcutActivity extends Ac
135                                                    
136                  case SHOW_STATIONS:                  case SHOW_STATIONS:
137                          if (data != null) {                          if (data != null) {
138                                  station = (StationBean) data.getSerializableExtra("station");                                  station = (StationEntry) data.getSerializableExtra("station");
139                                  if (station != null) {                                  if (station != null) {
140                                          okBtn.setEnabled(true);                                          okBtn.setEnabled(true);
141                                                                                    

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

  ViewVC Help
Powered by ViewVC 1.1.20