Search in sources :

Example 1 with CafeteriaMenuCard

use of de.tum.in.tumcampusapp.component.ui.cafeteria.CafeteriaMenuCard in project TumCampusApp by TCA-Team.

the class CafeteriaManager method onRequestCard.

/**
 * Shows card for the best matching cafeteria.
 *
 * @param context Context
 * @see LocationManager#getCafeteria()
 */
@Override
public void onRequestCard(Context context) {
    // Choose which mensa should be shown
    int cafeteriaId = new LocationManager(context).getCafeteria();
    if (cafeteriaId == -1) {
        return;
    }
    CafeteriaMenuCard card = new CafeteriaMenuCard(context);
    compositeDisposable.add(createCafeteriaObservable(cafeteriaId).take(1).subscribe(cafeteria -> {
        card.setCardMenus(cafeteria.id, cafeteria.name, cafeteria.dateStr, de.tum.in.tumcampusapp.utils.DateUtils.getDate(cafeteria.dateStr), cafeteria.menus);
        card.apply();
    }, throwable -> Utils.log(throwable.getMessage())));
}
Also used : LocationManager(de.tum.in.tumcampusapp.component.other.locations.LocationManager) Context(android.content.Context) CafeteriaMenu(de.tum.in.tumcampusapp.component.ui.cafeteria.model.CafeteriaMenu) DateUtils(android.text.format.DateUtils) Date(java.util.Date) Card(de.tum.in.tumcampusapp.component.ui.overview.card.Card) HashMap(java.util.HashMap) TUMCabeClient(de.tum.in.tumcampusapp.api.app.TUMCabeClient) CafeteriaLocalRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository) CafeteriaMenuCard(de.tum.in.tumcampusapp.component.ui.cafeteria.CafeteriaMenuCard) CafeteriaViewModel(de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Calendar(java.util.Calendar) Flowable(io.reactivex.Flowable) Map(java.util.Map) Utils(de.tum.in.tumcampusapp.utils.Utils) TcaDb(de.tum.in.tumcampusapp.database.TcaDb) CafeteriaRemoteRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository) Collections(java.util.Collections) LocationManager(de.tum.in.tumcampusapp.component.other.locations.LocationManager) CafeteriaMenuCard(de.tum.in.tumcampusapp.component.ui.cafeteria.CafeteriaMenuCard)

Aggregations

Context (android.content.Context)1 DateUtils (android.text.format.DateUtils)1 TUMCabeClient (de.tum.in.tumcampusapp.api.app.TUMCabeClient)1 LocationManager (de.tum.in.tumcampusapp.component.other.locations.LocationManager)1 CafeteriaMenuCard (de.tum.in.tumcampusapp.component.ui.cafeteria.CafeteriaMenuCard)1 CafeteriaViewModel (de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel)1 CafeteriaMenu (de.tum.in.tumcampusapp.component.ui.cafeteria.model.CafeteriaMenu)1 CafeteriaLocalRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)1 CafeteriaRemoteRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository)1 Card (de.tum.in.tumcampusapp.component.ui.overview.card.Card)1 TcaDb (de.tum.in.tumcampusapp.database.TcaDb)1 Utils (de.tum.in.tumcampusapp.utils.Utils)1 Flowable (io.reactivex.Flowable)1 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1