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

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

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

revision 1053 by torben, Tue Sep 14 16:00:57 2010 UTC revision 1798 by torben, Wed Apr 18 17:38:54 2012 UTC
# Line 11  import android.app.AlertDialog; Line 11  import android.app.AlertDialog;
11  import android.app.Dialog;  import android.app.Dialog;
12  import android.app.ListActivity;  import android.app.ListActivity;
13  import android.app.ProgressDialog;  import android.app.ProgressDialog;
14    import android.content.ActivityNotFoundException;
15  import android.content.DialogInterface;  import android.content.DialogInterface;
16  import android.content.Intent;  import android.content.Intent;
17    import android.content.SharedPreferences;
18  import android.graphics.Typeface;  import android.graphics.Typeface;
19  import android.net.Uri;  import android.net.Uri;
20  import android.os.AsyncTask;  import android.os.AsyncTask;
21  import android.os.Bundle;  import android.os.Bundle;
22    import android.preference.PreferenceManager;
23  import android.util.Log;  import android.util.Log;
24  import android.view.Menu;  import android.view.Menu;
25  import android.view.MenuItem;  import android.view.MenuItem;
# Line 27  import android.widget.ListView; Line 30  import android.widget.ListView;
30  import android.widget.TableLayout;  import android.widget.TableLayout;
31  import android.widget.TableRow;  import android.widget.TableRow;
32  import android.widget.TextView;  import android.widget.TextView;
33    import android.widget.Toast;
34    import dk.thoerup.android.traininfo.common.DepartureBean;
35    import dk.thoerup.android.traininfo.common.DepartureEntry;
36    import dk.thoerup.android.traininfo.common.MetroBean;
37    import dk.thoerup.android.traininfo.common.MetroBean.MetroEntry;
38    import dk.thoerup.android.traininfo.common.StationEntry;
39  import dk.thoerup.traininfo.provider.DepartureProvider;  import dk.thoerup.traininfo.provider.DepartureProvider;
40  import dk.thoerup.traininfo.provider.MetroProvider;  import dk.thoerup.traininfo.provider.MetroProvider;
41  import dk.thoerup.traininfo.provider.ProviderFactory;  import dk.thoerup.traininfo.provider.ProviderFactory;
42  import dk.thoerup.traininfo.provider.MetroProvider.MetroBean;  
43  import dk.thoerup.traininfo.provider.MetroProvider.MetroEntry;  import dk.thoerup.traininfo.util.FavoritesHelper;
44  import dk.thoerup.traininfo.util.MessageBox;  import dk.thoerup.traininfo.util.MessageBox;
45    import dk.thoerup.traininfo.util.StationEntryCsv;
46    
47  public class DepartureList extends ListActivity {  public class DepartureList extends ListActivity {
48    
49          public static final int DLG_PROGRESS = 1;          public static final int DLG_PROGRESS = 1;
50          static final int MENU_MAP = 100;          static final int MENU_MAP = 100;
51          static final int MENU_NOTIFICATIONS = 101;          static final int MENU_NOTIFICATIONS = 101;
52            static final int MENU_METROMAP = 102;
53            static final int MENU_TOGGLEDETAILS= 103;
54    
55            static final int MENU_FAVORITES_ADD = 104;
56            static final int MENU_FAVORITES_REMOVE = 105;
57                    
58                    
59          DepartureListAdapter adapter;          DepartureListAdapter adapter;
# Line 49  public class DepartureList extends ListA Line 64  public class DepartureList extends ListA
64          MetroProvider metro;          MetroProvider metro;
65                    
66          int selectedItemId;          int selectedItemId;
67    
68            FavoritesHelper favorites;
69    
70          //DepartureBean currentDeparture;          //DepartureBean currentDeparture;
71                    
72          ProgressDialog pgDialog;          ProgressDialog pgDialog;
# Line 56  public class DepartureList extends ListA Line 74  public class DepartureList extends ListA
74          DepartureFetcher fetcher;          DepartureFetcher fetcher;
75          MetroFetcher metroFetcher;          MetroFetcher metroFetcher;
76    
77          StationBean station;          StationEntry station;
78                    
79          boolean arrival = false;          String trainType = "REGIONAL";
80            
81            boolean arrival = false;        
82    
83          int commFailCounter = 0;          int commFailCounter = 0;
84    
# Line 66  public class DepartureList extends ListA Line 86  public class DepartureList extends ListA
86          protected void onCreate(Bundle savedInstanceState) {          protected void onCreate(Bundle savedInstanceState) {
87                  super.onCreate(savedInstanceState);                  super.onCreate(savedInstanceState);
88                  setContentView(R.layout.departurelist);                  setContentView(R.layout.departurelist);
89                            
90                    favorites = new FavoritesHelper(this);
91            
92                  adapter = new DepartureListAdapter(this);                  adapter = new DepartureListAdapter(this);
93                  setListAdapter(adapter);                  setListAdapter(adapter);
94                                                    
95                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
96                    
97                  station = (StationBean) launchedBy.getSerializableExtra("stationbean");                  station = (StationEntry) launchedBy.getSerializableExtra("stationbean");
98                                    
99                  ((TextView) findViewById(R.id.stationName)).setText( station.getName() );                  ((TextView) findViewById(R.id.stationName)).setText( station.getName() );
100    
# Line 82  public class DepartureList extends ListA Line 104  public class DepartureList extends ListA
104                  final Button departureBtn = (Button) findViewById(R.id.departurebtn);                  final Button departureBtn = (Button) findViewById(R.id.departurebtn);
105                  final Button arrivalBtn = (Button) findViewById(R.id.arrivalbtn);                  final Button arrivalBtn = (Button) findViewById(R.id.arrivalbtn);
106                  final Button metroBtn = (Button) findViewById(R.id.metrobtn);                  final Button metroBtn = (Button) findViewById(R.id.metrobtn);
107                    final Button regionalBtn = (Button) findViewById(R.id.regionalbtn);
108                    final Button stogBtn = (Button) findViewById(R.id.stogbtn);
109                                    
110                  final View metroView = findViewById(R.id.metroonly);                  final View metroView = findViewById(R.id.metroonly);
111                                    
# Line 112  public class DepartureList extends ListA Line 136  public class DepartureList extends ListA
136                          }                          }
137                  });                  });
138                                    
139                    regionalBtn.setOnClickListener( new OnClickListener() {
140                            @Override
141                            public void onClick(View arg0) {        
142                                    regionalBtn.setBackgroundResource(R.drawable.custom_button_hilight);
143                                    stogBtn.setBackgroundResource(R.drawable.custom_button);                                
144                                    metroBtn.setBackgroundResource(R.drawable.custom_button);
145                                    
146                                    departureBtn.setVisibility( View.VISIBLE );
147                                    arrivalBtn.setVisibility( View.VISIBLE );
148                                    
149                                    getListView().setVisibility( View.VISIBLE );            
150                                    metroView.setVisibility( View.GONE );
151                                    trainType = "REGIONAL";
152                                    startDepartureFetcher();
153                            }
154                    });
155                    stogBtn.setOnClickListener( new OnClickListener() {
156                            @Override
157                            public void onClick(View arg0) {        
158                                    regionalBtn.setBackgroundResource(R.drawable.custom_button);
159                                    stogBtn.setBackgroundResource(R.drawable.custom_button_hilight);                                
160                                    metroBtn.setBackgroundResource(R.drawable.custom_button);
161    
162    
163                                    departureBtn.setVisibility( View.VISIBLE );
164                                    arrivalBtn.setVisibility( View.VISIBLE );
165                                    
166                                    getListView().setVisibility( View.VISIBLE );            
167                                    metroView.setVisibility( View.GONE );
168                                    trainType = "STOG";                    
169                                    startDepartureFetcher();
170                            }
171                    });
172    
173                    
174                    
175                  metroBtn.setOnClickListener( new OnClickListener() {                                      metroBtn.setOnClickListener( new OnClickListener() {                    
176                          @Override                          @Override
177                          public void onClick(View v) {                          public void onClick(View v) {
178                                  arrivalBtn.setBackgroundResource(R.drawable.custom_button);                                  regionalBtn.setBackgroundResource(R.drawable.custom_button);
179                                  departureBtn.setBackgroundResource(R.drawable.custom_button);                                  stogBtn.setBackgroundResource(R.drawable.custom_button);                                
180                                  metroBtn.setBackgroundResource(R.drawable.custom_button_hilight);                                  metroBtn.setBackgroundResource(R.drawable.custom_button_hilight);
181                                                                    
182                                    departureBtn.setVisibility( View.GONE );
183                                    arrivalBtn.setVisibility( View.GONE );
184                                    
185                                  getListView().setVisibility( View.GONE );                                                getListView().setVisibility( View.GONE );              
186                                  metroView.setVisibility( View.VISIBLE );                                  metroView.setVisibility( View.VISIBLE );
187                                  startMetroFetcher();                                  startMetroFetcher();
# Line 130  public class DepartureList extends ListA Line 193  public class DepartureList extends ListA
193                                    
194                  // findViewById(R.id.header).setOnClickListener( mapLauncher );                  // findViewById(R.id.header).setOnClickListener( mapLauncher );
195                                    
196                  int distance = station.getDistance();                  int distance = station.getCalcdist();
197                  if (distance != 0) {                  if (distance != 0) {
198                          NumberFormat format = NumberFormat.getNumberInstance();                          NumberFormat format = NumberFormat.getNumberInstance();
199                          format.setMaximumFractionDigits(1);                          format.setMaximumFractionDigits(1);
# Line 143  public class DepartureList extends ListA Line 206  public class DepartureList extends ListA
206                    
207                  ProviderFactory.purgeOldEntries(); //cleanup before fetching more data                  ProviderFactory.purgeOldEntries(); //cleanup before fetching more data
208                                    
209                  Log.e("Station", station.toCSV() );                  Log.e("Station", StationEntryCsv.toCSV(station) );
210                    
211                    
212                                    
213                  if (station.isMetro() == false) {                  if (station.isMetro() == false) {
214                          metroBtn.setVisibility( View.GONE );                          metroBtn.setVisibility( View.GONE );
# Line 151  public class DepartureList extends ListA Line 216  public class DepartureList extends ListA
216                    
217                  metro = ProviderFactory.getMetroProvider();                  metro = ProviderFactory.getMetroProvider();
218                                    
219                  if (station.isRegional() == false && station.isSTrain() == false) {                  if (station.isRegional() == false ) {
220                            regionalBtn.setVisibility(View.GONE);
221                    }
222                    
223                    if (station.isStrain() == false ) {
224                            stogBtn.setVisibility(View.GONE);
225                    }
226                    
227                    if (station.isRegional() == true && station.isStrain() == false ) {
228                            if ( station.isMetro() == false )
229                                    regionalBtn.setVisibility(View.GONE);
230                            trainType = "REGIONAL";                
231                    }              
232    
233                    if (station.isRegional() == false  && station.isStrain() == true) {
234                            if (station.isMetro() == false)
235                                    stogBtn.setVisibility(View.GONE);
236    
237                            stogBtn.setBackgroundResource(R.drawable.custom_button_hilight);
238                            trainType = "STOG";
239                            
240                    }
241                    //Both enabled - use preferred from preferences
242                    if (station.isRegional() == true && station.isStrain() == true ) {
243                            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
244                            trainType = prefs.getString("traintype", "REGIONAL"); //default value is gps    
245                            
246                            if (trainType.equals("STOG") ) {
247                                    stogBtn.setBackgroundResource(R.drawable.custom_button_hilight);
248                                    regionalBtn.setBackgroundResource(R.drawable.custom_button);
249                            }
250                    }
251                                    
252                    
253                    if (station.isRegional() == false && station.isStrain() == false) {
254                          getListView().setVisibility( View.GONE );                                        getListView().setVisibility( View.GONE );              
255                          metroView.setVisibility( View.VISIBLE );                          metroView.setVisibility( View.VISIBLE );
256                                                    
257                          departureBtn.setVisibility( View.GONE );                          departureBtn.setVisibility( View.GONE );
258                          arrivalBtn.setVisibility(View.GONE);                          arrivalBtn.setVisibility(View.GONE);
259                          metroBtn.setVisibility( View.GONE );                          metroBtn.setVisibility( View.GONE );            
260                            
261                            
262                                                    
263                          if (savedInstanceState == null) {                          if (savedInstanceState == null) {
264                                  startMetroFetcher();                                  startMetroFetcher();
265                          } else {                          } else {
266                                  metroBean = (MetroBean) savedInstanceState.getSerializable("metro");                                  metroBean = (MetroBean) savedInstanceState.getSerializable("metro");
267                                  loadMetroData();                                  if (metroBean != null) { // Avoid reported NPE
268                                            loadMetroData();
269                                    } else {
270                                            startMetroFetcher();    
271                                    }
272                          }                          }
273                                                    
274                  } else {                  } else {
# Line 187  public class DepartureList extends ListA Line 292  public class DepartureList extends ListA
292                  }                  }
293          }          }
294                    
295            
296            
297          boolean hasNotifications() {          boolean hasNotifications() {
298                  return (departures != null && departures.notifications.size() > 0);                  return (departures != null && departures.notifications.size() > 0);
299          }          }
# Line 222  public class DepartureList extends ListA Line 329  public class DepartureList extends ListA
329          protected void onListItemClick(ListView l, View v, int position, long id) {          protected void onListItemClick(ListView l, View v, int position, long id) {
330                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
331                                    
332                    //how can this happen ??
333                    if (departures == null || departures.entries == null || departures.entries.size() == 0) {
334                            Toast.makeText(this, "No departures in list ?!?", Toast.LENGTH_LONG).show(); //TODO: translate
335                            return;
336                    }
337                    
338                  selectedItemId = position;                  selectedItemId = position;
339                                    
340                  DepartureEntry dep = departures.entries.get(selectedItemId);                  DepartureEntry dep = departures.entries.get(selectedItemId);
# Line 262  public class DepartureList extends ListA Line 375  public class DepartureList extends ListA
375                    
376                    
377    
378            @Override
379            public boolean onPrepareOptionsMenu(Menu menu) {                
380                    super.onPrepareOptionsMenu(menu);
381    
382                    ///////////////////////
383                    
384                    MenuItem item = menu.findItem( MENU_NOTIFICATIONS );
385                    boolean notifEnabled = hasNotifications();
386                    item.setEnabled(notifEnabled);
387    
388                    //////////////////////////
389    
390    
391                    
392                    
393                    return true;
394            }
395    
396          @Override          @Override
397          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
398                  MenuItem item;                  MenuItem item;
399                                    
400                    
401                    item = menu.add(0, MENU_TOGGLEDETAILS, 0, getString(R.string.departurelist_toggledetails));
402                    item.setIcon(android.R.drawable.ic_menu_view);
403                    
404                  item = menu.add(0, MENU_MAP, 0, getString(R.string.departurelist_showonmap) );                  item = menu.add(0, MENU_MAP, 0, getString(R.string.departurelist_showonmap) );
405                  item.setIcon(android.R.drawable.ic_menu_mapmode);                  item.setIcon(android.R.drawable.ic_menu_mapmode);
406                                    
407                  item = menu.add(0, MENU_NOTIFICATIONS, 0, getString(R.string.departurelist_notifications) );                  item = menu.add(0, MENU_NOTIFICATIONS, 0, getString(R.string.departurelist_notifications) );
408                  item.setIcon(android.R.drawable.ic_menu_info_details);                  item.setIcon(android.R.drawable.ic_menu_info_details);                  
                   
409                                    
410                  boolean notifEnabled = hasNotifications();                  boolean notifEnabled = hasNotifications();
411                  item.setEnabled(notifEnabled);                  item.setEnabled(notifEnabled);
412    
413                    ///////////////////////////////////////
414                    if ( ! favorites.hasFavorite( this.station.getId() ) ) {
415                            item = menu.add(0, MENU_FAVORITES_ADD, 0, getString(dk.thoerup.traininfo.R.string.stationlist_addfavorite) );
416                    } else {
417                            item = menu.add(0, MENU_FAVORITES_REMOVE, 0, getString(dk.thoerup.traininfo.R.string.stationlist_removefavorite) );
418                    }
419                    item.setIcon(android.R.drawable.ic_menu_save);                  
420                    /////////////////////////////
421                                    
422                    if (station.isMetro()) {
423                            item = menu.add(0, MENU_METROMAP, 0, "Metro" ); //TODO:translate!?!
424                            item.setIcon(android.R.drawable.ic_menu_mapmode);                      
425                    }                                              
426    
427                  return true;                  return true;
428          }          }
429    
430          @Override          @Override
431          public boolean onOptionsItemSelected(MenuItem item) {                    public boolean onOptionsItemSelected(MenuItem item) {          
432                  boolean res;                  boolean res = true;
433                  switch(item.getItemId()) {                  switch(item.getItemId()) {
434                  case MENU_MAP:                  case MENU_MAP:
435                          Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude());                          Uri uri = Uri.parse("geo:" + station.getLatitude() + "," + station.getLongitude() + "?z=16");
436                          startActivity( new Intent(Intent.ACTION_VIEW, uri));                          
437                          res = true;                          try {                          
438                                    startActivity( new Intent(Intent.ACTION_VIEW, uri));
439                            } catch (ActivityNotFoundException anfe) {
440                                     Toast.makeText(this, "Could not launch google maps", Toast.LENGTH_LONG).show();
441                            }
442                            
443                          break;                          break;
444                  case MENU_NOTIFICATIONS:                  case MENU_NOTIFICATIONS:
445                          Intent i = new Intent(this,dk.thoerup.traininfo.NotificationList.class);                          Intent i = new Intent(this,dk.thoerup.traininfo.NotificationList.class);
446                          i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications);                          i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications);
447                          startActivity(i);                          startActivity(i);                      
448                          res = true;                          break;
449                    case MENU_METROMAP:
450                            Intent metroMap = new Intent(this,dk.thoerup.traininfo.MetroMap.class);
451                            startActivity(metroMap);                        
452                            break;                  
453                    case MENU_TOGGLEDETAILS:
454                            adapter.toggleShowDetails();                                            
455                            break;
456                    case MENU_FAVORITES_ADD:
457                            favorites.addFavorite( this.station.getId() );
458                            Toast.makeText(this, getString(dk.thoerup.traininfo.R.string.stationlist_stationadded), Toast.LENGTH_SHORT).show();
459                            break;
460                    case MENU_FAVORITES_REMOVE:
461                            favorites.removeFavorite( station.getId() );
462                            Toast.makeText(this, getString(dk.thoerup.traininfo.R.string.stationlist_stationremoved), Toast.LENGTH_SHORT).show();
463                          break;                          break;
464                  default:                  default:
465                          res = super.onOptionsItemSelected(item);                          res = super.onOptionsItemSelected(item);
# Line 347  public class DepartureList extends ListA Line 511  public class DepartureList extends ListA
511                                                    
512                                                    
513                          pgDialog.dismiss();                          pgDialog.dismiss();
514                            
515                          if (departures != null) {                          if (departures != null && departures.errorCode == null) {
516                                  commFailCounter = 0;                                  commFailCounter = 0;
517                                  DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html                                  DepartureList.this.getListView().setVisibility(View.GONE); //Experimental, inspired by http://osdir.com/ml/Android-Developers/2010-04/msg01198.html
518                                  adapter.setDepartures(departures.entries);                                  adapter.setDepartures(departures.entries);
519                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);
520                                                                    
521                                                                    
522                                  if ( hasNotifications() ) {                                  // handle notification icon.
523                                          findViewById(R.id.notifIcon).setVisibility(View.VISIBLE);                                  View notifIcon = findViewById(R.id.notifIcon);
524                                    if ( hasNotifications() ) {                                    
525                                            notifIcon.setVisibility(View.VISIBLE);
526                                            notifIcon.setClickable(true);
527                                            notifIcon.setOnClickListener( new View.OnClickListener() {                                              
528                                                    @Override
529                                                    public void onClick(View v) {
530                                                            Intent i = new Intent(DepartureList.this, dk.thoerup.traininfo.NotificationList.class);
531                                                            i.putExtra(NotificationList.EXTRA_NOTIFICATIONS, departures.notifications);
532                                                            startActivity(i);                                                      
533                                                    }
534                                            });
535                                    } else {
536                                            notifIcon.setVisibility(View.INVISIBLE);
537                                  }                                  }
538                                                                    
539                                  if (departures.entries.size() == 0) {                                  if (departures.entries.size() == 0) {
540                                          MessageBox.showMessage(DepartureList.this, "No departures found", true);                                          int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals;
541                                            MessageBox.showMessage(DepartureList.this, getString(msgId), false);
542                                  }                                  }
543                          } else { // communication or parse error                          } else { // communication or parse error
544                                  commFailCounter++;                                  commFailCounter++;
545                                  AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);                                                                                AlertDialog.Builder builder = new AlertDialog.Builder(DepartureList.this);
546                                  builder.setMessage("Error finding departures");                                  
547                                    if (departures != null && departures.errorCode != null ) { //got an error xml back
548                                            commFailCounter = 10;
549                                            builder.setMessage( getString(R.string.no_backend) );
550                                    } else {                                        
551                                            builder.setMessage( getString(R.string.departurelist_fetcherror) );            
552                                    }
553                                  builder.setCancelable(true);                                  builder.setCancelable(true);
554                                    
555                                  if (commFailCounter < 3) {                                  if (commFailCounter < 3) {
556                                          builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {                                          builder.setPositiveButton(getString(generic_retry), new DialogInterface.OnClickListener() {
557                                                  public void onClick(DialogInterface dialog, int id) {                                                  public void onClick(DialogInterface dialog, int id) {
# Line 383  public class DepartureList extends ListA Line 568  public class DepartureList extends ListA
568                                          }                                                                                                }                                                      
569                                  });                                  });
570                                                                    
571                                  try {                                  try { //TODO: is this still necessary after the 0.9.4.1 fix ?
572                                          builder.show();                                          builder.show();
573                                  } catch (android.view.WindowManager.BadTokenException e) {                                                                        } catch (android.view.WindowManager.BadTokenException e) {                                      
574                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running
# Line 393  public class DepartureList extends ListA Line 578  public class DepartureList extends ListA
578    
579                  @Override                  @Override
580                  protected Void doInBackground(Integer... params) {                  protected Void doInBackground(Integer... params) {
581                          departures = provider.lookupDepartures(params[0], DepartureList.this.arrival);                          departures = provider.lookupDepartures(params[0], DepartureList.this.arrival, trainType);
582                          return null;                          return null;
583                  }                  }
584                                    
# Line 411  public class DepartureList extends ListA Line 596  public class DepartureList extends ListA
596                                    
597                  TextView h1 = new TextView(this);                  TextView h1 = new TextView(this);
598                  h1.setText("Metro");                  h1.setText("Metro");
599                    h1.setTextSize(16);
600                  h1.setTypeface( Typeface.defaultFromStyle(Typeface.BOLD));                  h1.setTypeface( Typeface.defaultFromStyle(Typeface.BOLD));
601                                    
602                                    
# Line 418  public class DepartureList extends ListA Line 604  public class DepartureList extends ListA
604                  params.span = 2;                  params.span = 2;
605                  head.addView(h1, params);                  head.addView(h1, params);
606                                    
607                    
608                    
609                  TextView h2 = new TextView(this);                  TextView h2 = new TextView(this);
610                  h2.setText("Om minutte");                  h2.setTextSize(16);
611                  h2.setTypeface( Typeface.defaultFromStyle(Typeface.BOLD));                  h2.setTypeface( Typeface.defaultFromStyle(Typeface.BOLD));
612                  head.addView(h2);                  h2.setText("Om minutter");
613                    
614                    params = new TableRow.LayoutParams();
615                    params.weight = 2;
616                    head.addView(h2,params);
617    
618                                    
619                                    
# Line 433  public class DepartureList extends ListA Line 625  public class DepartureList extends ListA
625                          Log.e("Test", "" + entry.destination);                          Log.e("Test", "" + entry.destination);
626                                                    
627                          TextView v1 = new TextView(this);                          TextView v1 = new TextView(this);
628                          v1.setText( entry.metro );                          v1.setTextSize(16);
629                            v1.setText( entry.metro );                      
630                          row.addView(v1);                          row.addView(v1);
631                                                    
632                          TextView v2 = new TextView(this);                          TextView v2 = new TextView(this);
633                            v2.setTextSize(16);
634                          v2.setText( entry.destination );                          v2.setText( entry.destination );
635                          row.addView(v2);                          row.addView(v2);
636                                            
637                          TextView v3 = new TextView(this);                          TextView v3 = new TextView(this);
638                            v3.setTextSize(16);
639                          v3.setText( entry.minutes );                          v3.setText( entry.minutes );
640                          row.addView(v3);                          row.addView(v3);
641                                                    
# Line 479  public class DepartureList extends ListA Line 674  public class DepartureList extends ListA
674                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
675                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
676                                                  dialog.dismiss();                                                  dialog.dismiss();
677                                                  DepartureList.this.finish();                                                  DepartureList.this.finish(); //TODO: should we really close the activity ??
678                                          }                                                                                                }                                                      
679                                  });                                  });
680                                                                    
681                                  try {                                  try { //TODO: is this still necessary after the 0.9.4.1 fix ?
682                                          builder.show();                                          builder.show();
683                                  } catch (android.view.WindowManager.BadTokenException e) {                                                                        } catch (android.view.WindowManager.BadTokenException e) {                                      
684                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running                                          Log.i("DepartureList", "BadTokenException"); // this can happen if the user switched away from this activity, while doInBackground was running

Legend:
Removed from v.1053  
changed lines
  Added in v.1798

  ViewVC Help
Powered by ViewVC 1.1.20