/[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 1562 by torben, Fri Jul 8 16:26:09 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 38  import dk.thoerup.traininfo.provider.Dep Line 40  import dk.thoerup.traininfo.provider.Dep
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.util.MessageBox;  import dk.thoerup.traininfo.util.MessageBox;
43    import dk.thoerup.traininfo.util.StationEntryCsv;
44    
45  public class DepartureList extends ListActivity {  public class DepartureList extends ListActivity {
46    
# Line 77  public class DepartureList extends ListA Line 80  public class DepartureList extends ListA
80                  setContentView(R.layout.departurelist);                  setContentView(R.layout.departurelist);
81                                    
82                  adapter = new DepartureListAdapter(this);                  adapter = new DepartureListAdapter(this);
83                  setListAdapter(adapter);                                                  setListAdapter(adapter);
84                                                    
85                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
86                    
87                  station = (StationEntry) launchedBy.getSerializableExtra("stationbean");                  station = (StationEntry) launchedBy.getSerializableExtra("stationbean");
# Line 193  public class DepartureList extends ListA Line 196  public class DepartureList extends ListA
196                    
197                  ProviderFactory.purgeOldEntries(); //cleanup before fetching more data                  ProviderFactory.purgeOldEntries(); //cleanup before fetching more data
198                                    
199                  Log.e("Station", station.toCSV() );                  Log.e("Station", StationEntryCsv.toCSV(station) );
200                    
201                    
202                                    
203                  if (station.isMetro() == false) {                  if (station.isMetro() == false) {
204                          metroBtn.setVisibility( View.GONE );                          metroBtn.setVisibility( View.GONE );
# Line 223  public class DepartureList extends ListA Line 228  public class DepartureList extends ListA
228                          trainType = "STOG";                          trainType = "STOG";
229                                                    
230                  }                  }
231                    //Both enabled - use preferred from preferences
232                    if (station.isRegional() == true && station.isStrain() == true ) {
233                            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
234                            trainType = prefs.getString("traintype", "REGIONAL"); //default value is gps    
235                            
236                            if (trainType.equals("STOG") ) {
237                                    stogBtn.setBackgroundResource(R.drawable.custom_button_hilight);
238                                    regionalBtn.setBackgroundResource(R.drawable.custom_button);
239                            }
240                    }
241                                                                    
242                                    
243                  if (station.isRegional() == false && station.isStrain() == false) {                  if (station.isRegional() == false && station.isStrain() == false) {
# Line 263  public class DepartureList extends ListA Line 278  public class DepartureList extends ListA
278                  }                  }
279          }          }
280                    
281            
282            
283          boolean hasNotifications() {          boolean hasNotifications() {
284                  return (departures != null && departures.notifications.size() > 0);                  return (departures != null && departures.notifications.size() > 0);
285          }          }
# Line 298  public class DepartureList extends ListA Line 315  public class DepartureList extends ListA
315          protected void onListItemClick(ListView l, View v, int position, long id) {          protected void onListItemClick(ListView l, View v, int position, long id) {
316                  super.onListItemClick(l, v, position, id);                  super.onListItemClick(l, v, position, id);
317                                    
318                    //how can this happen ??
319                    if (departures == null || departures.entries == null || departures.entries.size() == 0) {
320                            Toast.makeText(this, "No departures in list ?!?", Toast.LENGTH_LONG).show(); //TODO: translate
321                            return;
322                    }
323                    
324                  selectedItemId = position;                  selectedItemId = position;
325                                    
326                  DepartureEntry dep = departures.entries.get(selectedItemId);                  DepartureEntry dep = departures.entries.get(selectedItemId);
# Line 339  public class DepartureList extends ListA Line 362  public class DepartureList extends ListA
362                    
363    
364          @Override          @Override
365            public boolean onPrepareOptionsMenu(Menu menu) {                
366                    super.onPrepareOptionsMenu(menu);
367                    
368                    MenuItem item = menu.findItem( MENU_NOTIFICATIONS );
369                    boolean notifEnabled = hasNotifications();
370                    item.setEnabled(notifEnabled);
371                    
372                    return true;
373            }
374    
375            @Override
376          public boolean onCreateOptionsMenu(Menu menu) {          public boolean onCreateOptionsMenu(Menu menu) {
377                  MenuItem item;                  MenuItem item;
378                                    
# Line 447  public class DepartureList extends ListA Line 481  public class DepartureList extends ListA
481                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);                                  DepartureList.this.getListView().setVisibility(View.VISIBLE);
482                                                                    
483                                                                    
484                                  // handle notification icon.                                                                                              // handle notification icon.
485                                  if ( hasNotifications() ) {                                  View notifIcon = findViewById(R.id.notifIcon);
486                                          View notifIcon = findViewById(R.id.notifIcon);                                  if ( hasNotifications() ) {                                    
487                                          notifIcon.setVisibility(View.VISIBLE);                                          notifIcon.setVisibility(View.VISIBLE);
488                                          notifIcon.setClickable(true);                                          notifIcon.setClickable(true);
489                                          notifIcon.setOnClickListener( new View.OnClickListener() {                                                                                        notifIcon.setOnClickListener( new View.OnClickListener() {                                              
# Line 460  public class DepartureList extends ListA Line 494  public class DepartureList extends ListA
494                                                          startActivity(i);                                                                                                                startActivity(i);                                                      
495                                                  }                                                  }
496                                          });                                          });
497                                  }                                                                } else {
498                                            notifIcon.setVisibility(View.INVISIBLE);
499                                    }
500                                                                    
501                                  if (departures.entries.size() == 0) {                                  if (departures.entries.size() == 0) {
502                                          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.1562

  ViewVC Help
Powered by ViewVC 1.1.20