Search in sources :

Example 6 with LocationManager

use of de.tum.in.tumcampusapp.component.other.locations.LocationManager 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 LocationManager

use of de.tum.in.tumcampusapp.component.other.locations.LocationManager in project TumCampusApp by TCA-Team.

the class FeedbackActivity method getBackupLocation.

private void getBackupLocation() {
    Location backup = new LocationManager(this).getLastLocation();
    if (backup != null) {
        location = backup;
    }
    if (location == null) {
        // we don't know anything about the location
        includeLocation.setChecked(false);
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setIcon(R.drawable.ic_location);
        dialog.setTitle(R.string.location_services_off_title);
        dialog.setMessage(R.string.location_services_off_message);
        dialog.setPositiveButton(R.string.ok, null);
        dialog.show();
    }
}
Also used : LocationManager(de.tum.in.tumcampusapp.component.other.locations.LocationManager) AlertDialog(android.app.AlertDialog) Location(android.location.Location)

Aggregations

LocationManager (de.tum.in.tumcampusapp.component.other.locations.LocationManager)7 Location (android.location.Location)3 List (java.util.List)3 AlertDialog (android.app.AlertDialog)2 Bundle (android.os.Bundle)2 Spinner (android.widget.Spinner)2 TUMCabeClient (de.tum.in.tumcampusapp.api.app.TUMCabeClient)2 CafeteriaViewModel (de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel)2 CafeteriaLocalRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)2 CafeteriaRemoteRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository)2 TcaDb (de.tum.in.tumcampusapp.database.TcaDb)2 Utils (de.tum.in.tumcampusapp.utils.Utils)2 Flowable (io.reactivex.Flowable)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 HashMap (java.util.HashMap)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 Intent (android.content.Intent)1 LocationListener (android.location.LocationListener)1 NonNull (android.support.annotation.NonNull)1