53 |
import android.widget.Toast; |
import android.widget.Toast; |
54 |
import dk.thoerup.android.traininfo.common.StationBean; |
import dk.thoerup.android.traininfo.common.StationBean; |
55 |
import dk.thoerup.android.traininfo.common.StationEntry; |
import dk.thoerup.android.traininfo.common.StationEntry; |
56 |
|
import dk.thoerup.traininfo.WelcomeScreen.ListType; |
57 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
58 |
import dk.thoerup.traininfo.provider.StationProvider; |
import dk.thoerup.traininfo.provider.StationProvider; |
59 |
import dk.thoerup.traininfo.stationmap.GeoPair; |
import dk.thoerup.traininfo.stationmap.GeoPair; |
112 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
113 |
setContentView(R.layout.stationlist); |
setContentView(R.layout.stationlist); |
114 |
|
|
115 |
|
listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type"); |
116 |
|
|
117 |
adapter = new StationListAdapter(this); |
adapter = new StationListAdapter(this, (listType == ListType.ListNearest) ); |
118 |
setListAdapter(adapter); |
setListAdapter(adapter); |
119 |
|
|
120 |
ListView lv = getListView(); |
ListView lv = getListView(); |
129 |
favorites.fromString(favoriteString); |
favorites.fromString(favoriteString); |
130 |
} |
} |
131 |
|
|
|
listType = (WelcomeScreen.ListType) getIntent().getSerializableExtra("type"); |
|
132 |
setTitle(); |
setTitle(); |
133 |
|
|
134 |
isLaunchedforShortcut = getIntent().getBooleanExtra("shortcut", false); |
isLaunchedforShortcut = getIntent().getBooleanExtra("shortcut", false); |
135 |
|
|
136 |
ProviderFactory.purgeOldEntries(); //cleanup before fetching more data |
ProviderFactory.purgeOldEntries(); //cleanup before fetching more data |
137 |
|
|
138 |
|
if (listType == ListType.ListSearch) { |
139 |
|
enableNamesearchField(); |
140 |
|
} |
141 |
|
|
142 |
if (savedInstanceState == null) { |
if (savedInstanceState == null) { |
143 |
|
|
|
|
|
144 |
switch (listType) { |
switch (listType) { |
145 |
case ListNearest: |
case ListNearest: |
146 |
startNearestLookup(); |
startNearestLookup(); |
147 |
break; |
break; |
148 |
case ListSearch: |
case ListSearch: |
149 |
enableNamesearchField(); |
// do nothing here |
150 |
break; |
break; |
151 |
case ListFavorites: |
case ListFavorites: |
152 |
startFavoriteLookup(); |
startFavoriteLookup(); |
156 |
} |
} |
157 |
|
|
158 |
} else { |
} else { |
159 |
|
((TextView)findViewById(R.id.stationsearch)).setText( savedInstanceState.getString( "search") ); |
160 |
|
|
161 |
stations = (StationBean) savedInstanceState.getSerializable("stations"); |
stations = (StationBean) savedInstanceState.getSerializable("stations"); |
162 |
adapter.setStations(stations); |
adapter.setStations(stations); |
163 |
} |
} |
240 |
if (dialog != null && dialog.isShowing()) |
if (dialog != null && dialog.isShowing()) |
241 |
dialog.dismiss(); |
dialog.dismiss(); |
242 |
outState.putSerializable("stations", (StationBean) stations); |
outState.putSerializable("stations", (StationBean) stations); |
243 |
|
outState.putString("search", ((TextView)findViewById(R.id.stationsearch)).getText().toString() ); |
244 |
|
|
245 |
} |
} |
246 |
|
|