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

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

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

revision 699 by torben, Mon May 3 11:19:18 2010 UTC revision 917 by torben, Sat Jun 26 10:50:34 2010 UTC
# Line 10  import static dk.thoerup.traininfo.R.str Line 10  import static dk.thoerup.traininfo.R.str
10  import java.util.ArrayList;  import java.util.ArrayList;
11  import java.util.List;  import java.util.List;
12    
 import android.app.Activity;  
13  import android.app.AlertDialog;  import android.app.AlertDialog;
14  import android.app.Dialog;  import android.app.Dialog;
15    import android.app.ListActivity;
16  import android.app.ProgressDialog;  import android.app.ProgressDialog;
17  import android.content.DialogInterface;  import android.content.DialogInterface;
18  import android.content.Intent;  import android.content.Intent;
19  import android.os.AsyncTask;  import android.os.AsyncTask;
20  import android.os.Bundle;  import android.os.Bundle;
21  import android.util.Log;  import android.util.Log;
22    import android.view.View;
23  import android.widget.ListView;  import android.widget.ListView;
24  import android.widget.TextView;  import android.widget.TextView;
25    import android.widget.Toast;
26  import dk.thoerup.traininfo.provider.ProviderFactory;  import dk.thoerup.traininfo.provider.ProviderFactory;
27  import dk.thoerup.traininfo.provider.TimetableProvider;  import dk.thoerup.traininfo.provider.TimetableProvider;
28  import dk.thoerup.traininfo.util.MessageBox;  import dk.thoerup.traininfo.util.MessageBox;
29    
30  public class TimetableList extends Activity {  public class TimetableList extends ListActivity {
31                    
32          private static final int DLG_PROGRESS = 8000;          private static final int DLG_PROGRESS = 8000;
33          DepartureBean departure;          DepartureBean departure;
# Line 43  public class TimetableList extends Activ Line 45  public class TimetableList extends Activ
45                                    
46                  provider = ProviderFactory.getTimetableProvider();                  provider = ProviderFactory.getTimetableProvider();
47                                    
48                  adapter = new TimetableListAdapter(this);                  adapter = new TimetableListAdapter(this);              
49                                    setListAdapter(adapter);
50                  ListView lv = (ListView) findViewById(R.id.List);  
                 lv.setAdapter(adapter);  
51    
52                                    
53                  Intent launchedBy = getIntent();                  Intent launchedBy = getIntent();
# Line 67  public class TimetableList extends Activ Line 68  public class TimetableList extends Activ
68                  }                  }
69          }          }
70                    
71      @Override          
72        @Override
73            protected void onListItemClick(ListView l, View v, int position, long id) {
74                    super.onListItemClick(l, v, position, id);
75    
76                    TimetableBean tt = timetables.get(position);
77                    
78                    StationBean station = new StationBean();
79                    station.setName( tt.getStation() );
80                    station.setId( tt.getStationId() );
81                    station.setRegional(true);
82                    
83                    Intent intent = new Intent(this, DepartureList.class);
84                    intent.putExtra("stationbean", station);
85                    startActivity(intent);
86                    
87            }
88        
89    
90    
91            @Override
92      public void onSaveInstanceState(Bundle outState)      public void onSaveInstanceState(Bundle outState)
93      {                {          
94          dismissDialog(DLG_PROGRESS);          dismissDialog(DLG_PROGRESS);
# Line 116  public class TimetableList extends Activ Line 137  public class TimetableList extends Activ
137                    
138                                                    
139                          if (success) {                          if (success) {
140                                    TimetableList.this.getListView().invalidateViews();
141                                  adapter.setTimetable(timetables);                                  adapter.setTimetable(timetables);
142                                  if (timetables.size() == 0) {                                  if (timetables.size() == 0) {
143                                          MessageBox.showMessage(TimetableList.this, getString(timetablelist_nodata));                                          MessageBox.showMessage(TimetableList.this, getString(timetablelist_nodata), true);
144                                  }                                  }
145                          } else { // communication or parse error                          } else { // communication or parse error
146                                  AlertDialog.Builder builder = new AlertDialog.Builder(TimetableList.this);                                                                                AlertDialog.Builder builder = new AlertDialog.Builder(TimetableList.this);                                              
# Line 134  public class TimetableList extends Activ Line 156  public class TimetableList extends Activ
156                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {                                  builder.setNegativeButton(getString(generic_cancel), new DialogInterface.OnClickListener() {
157                                          public void onClick(DialogInterface dialog, int id) {                                          public void onClick(DialogInterface dialog, int id) {
158                                                  dialog.dismiss();                                                  dialog.dismiss();
159                                                    TimetableList.this.finish();
160                                          }                                                                                                }                                                      
161                                  });                                  });
162                                                                    

Legend:
Removed from v.699  
changed lines
  Added in v.917

  ViewVC Help
Powered by ViewVC 1.1.20