Search in sources :

Example 6 with Recent

use of de.tum.in.tumcampusapp.component.other.general.model.Recent 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)

Example 7 with Recent

use of de.tum.in.tumcampusapp.component.other.general.model.Recent in project TumCampusApp by TCA-Team.

the class RoomFinderActivity method getRecents.

/**
 * Reconstruct recents from String
 */
private List<RoomFinderRoom> getRecents() {
    List<Recent> recentList = recentsDao.getAll(RecentsDao.ROOMS);
    List<RoomFinderRoom> roomList = new ArrayList<>(recentList.size());
    for (Recent r : recentList) {
        try {
            roomList.add(RoomFinderRoom.Companion.fromRecent(r));
        } catch (IllegalArgumentException ignore) {
        }
    }
    return roomList;
}
Also used : Recent(de.tum.in.tumcampusapp.component.other.general.model.Recent) RoomFinderRoom(de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom) ArrayList(java.util.ArrayList)

Aggregations

Recent (de.tum.in.tumcampusapp.component.other.general.model.Recent)7 Intent (android.content.Intent)4 Bundle (android.os.Bundle)2 Person (de.tum.in.tumcampusapp.component.tumui.person.model.Person)2 RoomFinderRoom (de.tum.in.tumcampusapp.component.tumui.roomfinder.model.RoomFinderRoom)2 ArrayList (java.util.ArrayList)2 Switch (android.widget.Switch)1 TransportController (de.tum.in.tumcampusapp.component.ui.transportation.TransportController)1 Departure (de.tum.in.tumcampusapp.component.ui.transportation.model.efa.Departure)1 StationResult (de.tum.in.tumcampusapp.component.ui.transportation.model.efa.StationResult)1