use of de.tum.in.tumcampusapp.component.ui.transportation.model.efa.StationResult in project TumCampusApp by TCA-Team.
the class TransportController method onRequestCard.
/**
* Inserts a MVV card for the nearest public transport station
*
* @param context Context
*/
@Override
public void onRequestCard(Context context) {
if (!NetUtils.isConnected(context)) {
return;
}
// Get station for current campus
LocationManager locMan = new LocationManager(context);
StationResult station = locMan.getStation();
if (station == null) {
return;
}
List<Departure> cur = getDeparturesFromExternal(context, station.getId());
MVVCard card = new MVVCard(context);
card.setStation(station);
card.setDepartures(cur);
card.apply();
}
use of de.tum.in.tumcampusapp.component.ui.transportation.model.efa.StationResult in project TumCampusApp by TCA-Team.
the class TransportationDetailsActivity method onLoadInBackground.
/**
* Load departure times
*
* @param arg Station name
* @return List of departures
*/
@Override
protected List<Departure> onLoadInBackground(String... arg) {
final String location = arg[0];
final String locationID = arg[1];
// Quality is always 100% hit
final StationResult stationResult = new StationResult(location, locationID, Integer.MAX_VALUE);
final String jsonStationResult = gson.toJson(stationResult);
// save clicked station into db
recentsDao.insert(new Recent(jsonStationResult, RecentsDao.STATIONS));
// Check for internet connectivity
if (!NetUtils.isConnected(this)) {
showNoInternetLayout();
return null;
}
// get departures from website
List<Departure> departures = TransportController.getDeparturesFromExternal(this, locationID);
if (departures.isEmpty()) {
showError(R.string.no_departures_found);
}
return departures;
}
Aggregations