/[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 1434 by torben, Tue May 3 16:28:56 2011 UTC revision 1487 by torben, Sat May 28 17:47:01 2011 UTC
# Line 14  import android.app.ProgressDialog; Line 14  import android.app.ProgressDialog;
14  import android.content.ActivityNotFoundException;  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 77  public class DepartureList extends ListA Line 79  public class DepartureList extends ListA
79                  setContentView(R.layout.departurelist);                  setContentView(R.layout.departurelist);
80                                    
81                  adapter = new DepartureListAdapter(this);                  adapter = new DepartureListAdapter(this);
82                  setListAdapter(adapter);                                                  setListAdapter(adapter);
83                                                    
84                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
85                    
86                  station = (StationEntry) launchedBy.getSerializableExtra("stationbean");                  station = (StationEntry) launchedBy.getSerializableExtra("stationbean");
# Line 195  public class DepartureList extends ListA Line 197  public class DepartureList extends ListA
197                                    
198                  Log.e("Station", station.toCSV() );                  Log.e("Station", station.toCSV() );
199                                    
200                    
201                    
202                  if (station.isMetro() == false) {                  if (station.isMetro() == false) {
203                          metroBtn.setVisibility( View.GONE );                          metroBtn.setVisibility( View.GONE );
204                  }                  }
# Line 223  public class DepartureList extends ListA Line 227  public class DepartureList extends ListA
227                          trainType = "STOG";                          trainType = "STOG";
228                                                    
229                  }                  }
230                    //Both enabled - use preferred from preferences
231                    if (station.isRegional() == true && station.isStrain() == true ) {
232                            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
233                            trainType = prefs.getString("traintype", "REGIONAL"); //default value is gps    
234                            
235                            if (trainType.equals("STOG") ) {
236                                    stogBtn.setBackgroundResource(R.drawable.custom_button_hilight);
237                                    regionalBtn.setBackgroundResource(R.drawable.custom_button);
238                            }
239                    }
240                                                                    
241                                    
242                  if (station.isRegional() == false && station.isStrain() == false) {                  if (station.isRegional() == false && station.isStrain() == false) {
# Line 263  public class DepartureList extends ListA Line 277  public class DepartureList extends ListA
277                  }                  }
278          }          }
279                    
280            
281            
282          boolean hasNotifications() {          boolean hasNotifications() {
283                  return (departures != null && departures.notifications.size() > 0);                  return (departures != null && departures.notifications.size() > 0);
284          }          }
# Line 298  public class DepartureList extends ListA Line 314  public class DepartureList extends ListA
314          protected void onListItemClick(ListView l, View v, int position, long id) {          protected void onListItemClick(ListView l, View v, int position, long id) {
315                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
316                                    
317                    //how can this happen ??
318                    if (departures == null || departures.entries == null || departures.entries.size() == 0) {
319                            Toast.makeText(this, "No departures in list ?!?", Toast.LENGTH_LONG).show(); //TODO: translate
320                            return;
321                    }
322                    
323                  selectedItemId = position;                  selectedItemId = position;
324                                    
325                  DepartureEntry dep = departures.entries.get(selectedItemId);                  DepartureEntry dep = departures.entries.get(selectedItemId);
# Line 339  public class DepartureList extends ListA Line 361  public class DepartureList extends ListA
361                    
362    
363          @Override          @Override
364            public boolean onPrepareOptionsMenu(Menu menu) {                
365                    super.onPrepareOptionsMenu(menu);
366                    
367                    MenuItem item = menu.findItem( MENU_NOTIFICATIONS );
368                    boolean notifEnabled = hasNotifications();
369                    item.setEnabled(notifEnabled);
370                    
371                    return true;
372            }
373    
374            @Override
375          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
376                  MenuItem item;                  MenuItem item;
377                                    
# Line 447  public class DepartureList extends ListA Line 480  public class DepartureList extends ListA
480                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);
481                                                                    
482                                                                    
483                                  // handle notification icon.                                                                                              // handle notification icon.
484                                  if ( hasNotifications() ) {                                  View notifIcon = findViewById(R.id.notifIcon);
485                                          View notifIcon = findViewById(R.id.notifIcon);                                  if ( hasNotifications() ) {                                    
486                                          notifIcon.setVisibility(View.VISIBLE);                                          notifIcon.setVisibility(View.VISIBLE);
487                                          notifIcon.setClickable(true);                                          notifIcon.setClickable(true);
488                                          notifIcon.setOnClickListener( new View.OnClickListener() {                                                                                        notifIcon.setOnClickListener( new View.OnClickListener() {                                              
# Line 460  public class DepartureList extends ListA Line 493  public class DepartureList extends ListA
493                                                          startActivity(i);                                                                                                                startActivity(i);                                                      
494                                                  }                                                  }
495                                          });                                          });
496                                  }                                                                } else {
497                                            notifIcon.setVisibility(View.INVISIBLE);
498                                    }
499                                                                    
500                                  if (departures.entries.size() == 0) {                                  if (departures.entries.size() == 0) {
501                                          int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals;                                          int msgId = (arrival==false) ? R.string.departurelist_nodepartures : R.string.departurelist_noarrivals;

Legend:
Removed from v.1434  
changed lines
  Added in v.1487

  ViewVC Help
Powered by ViewVC 1.1.20