Search in sources :

Example 6 with StationResult

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();
}
Also used : LocationManager(de.tum.in.tumcampusapp.component.other.locations.LocationManager) Departure(de.tum.in.tumcampusapp.component.ui.transportation.model.efa.Departure) StationResult(de.tum.in.tumcampusapp.component.ui.transportation.model.efa.StationResult)

Example 7 with StationResult

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;
}
Also used : Recent(de.tum.in.tumcampusapp.component.other.general.model.Recent) Departure(de.tum.in.tumcampusapp.component.ui.transportation.model.efa.Departure) StationResult(de.tum.in.tumcampusapp.component.ui.transportation.model.efa.StationResult)

Aggregations

StationResult (de.tum.in.tumcampusapp.component.ui.transportation.model.efa.StationResult)7 Departure (de.tum.in.tumcampusapp.component.ui.transportation.model.efa.Departure)2 Recent (de.tum.in.tumcampusapp.component.other.general.model.Recent)1 NoResultsAdapter (de.tum.in.tumcampusapp.component.other.generic.adapter.NoResultsAdapter)1 LocationManager (de.tum.in.tumcampusapp.component.other.locations.LocationManager)1 NetUtils (de.tum.in.tumcampusapp.utils.NetUtils)1 ArrayList (java.util.ArrayList)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1