Search in sources :

Example 1 with CafeteriaRemoteRepository

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

the class DownloadService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    Utils.log("DownloadService service has started");
    broadcastManager = LocalBroadcastManager.getInstance(this);
    new SyncManager(this);
    CafeteriaRemoteRepository remoteRepository = CafeteriaRemoteRepository.INSTANCE;
    remoteRepository.setTumCabeClient(TUMCabeClient.getInstance(this));
    CafeteriaLocalRepository localRepository = CafeteriaLocalRepository.INSTANCE;
    localRepository.setDb(TcaDb.getInstance(this));
    cafeteriaViewModel = new CafeteriaViewModel(localRepository, remoteRepository, mDisposable);
    // Init sync table
    KinoLocalRepository.INSTANCE.setDb(TcaDb.getInstance(this));
    KinoRemoteRepository.INSTANCE.setTumCabeClient(TUMCabeClient.getInstance(this));
    kinoViewModel = new KinoViewModel(KinoLocalRepository.INSTANCE, KinoRemoteRepository.INSTANCE, mDisposable);
}
Also used : CafeteriaViewModel(de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel) SyncManager(de.tum.in.tumcampusapp.utils.sync.SyncManager) KinoViewModel(de.tum.in.tumcampusapp.component.ui.news.KinoViewModel) CafeteriaRemoteRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository) CafeteriaLocalRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)

Example 2 with CafeteriaRemoteRepository

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

the class CafeteriaDetailsSectionFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CafeteriaRemoteRepository remoteRepository = CafeteriaRemoteRepository.INSTANCE;
    remoteRepository.setTumCabeClient(TUMCabeClient.getInstance(getContext()));
    CafeteriaLocalRepository localRepository = CafeteriaLocalRepository.INSTANCE;
    localRepository.setDb(TcaDb.getInstance(getContext()));
    cafeteriaViewModel = new CafeteriaViewModel(localRepository, remoteRepository, mDisposable);
    JodaTimeAndroid.init(getContext());
}
Also used : CafeteriaRemoteRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository) CafeteriaLocalRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)

Example 3 with CafeteriaRemoteRepository

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

the class CafeteriaDetailsSectionsPagerAdapter method setCafeteriaId.

public void setCafeteriaId(Context context, int cafeteriaId) {
    mCafeteriaId = cafeteriaId;
    CafeteriaRemoteRepository remoteRepository = CafeteriaRemoteRepository.INSTANCE;
    remoteRepository.setTumCabeClient(TUMCabeClient.getInstance(context));
    CafeteriaLocalRepository localRepository = CafeteriaLocalRepository.INSTANCE;
    localRepository.setDb(TcaDb.getInstance(context));
    CafeteriaViewModel cafeteriaViewModel = new CafeteriaViewModel(localRepository, remoteRepository, mDisposable);
    cafeteriaViewModel.getAllMenuDates().subscribe(dates -> {
        this.dates = dates;
        this.notifyDataSetChanged();
    });
// Tell we just update the data
}
Also used : CafeteriaRemoteRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository) CafeteriaLocalRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)

Example 4 with CafeteriaRemoteRepository

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

the class CafeteriaActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get id from intent if specified
    final Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null && intent.getExtras().containsKey(Const.CAFETERIA_ID)) {
        mCafeteriaId = intent.getExtras().getInt(Const.CAFETERIA_ID);
    }
    mViewPager = findViewById(R.id.pager);
    /*
         *set pagelimit to avoid losing toggle button state.
         *by default it's 1.
         */
    mViewPager.setOffscreenPageLimit(50);
    CafeteriaRemoteRepository remoteRepository = CafeteriaRemoteRepository.INSTANCE;
    remoteRepository.setTumCabeClient(TUMCabeClient.getInstance(this));
    CafeteriaLocalRepository localRepository = CafeteriaLocalRepository.INSTANCE;
    localRepository.setDb(TcaDb.getInstance(this));
    cafeteriaViewModel = new CafeteriaViewModel(localRepository, remoteRepository, mDisposable);
}
Also used : CafeteriaViewModel(de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel) Intent(android.content.Intent) CafeteriaRemoteRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository) CafeteriaLocalRepository(de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)

Aggregations

CafeteriaLocalRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)4 CafeteriaRemoteRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository)4 CafeteriaViewModel (de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel)2 Intent (android.content.Intent)1 KinoViewModel (de.tum.in.tumcampusapp.component.ui.news.KinoViewModel)1 SyncManager (de.tum.in.tumcampusapp.utils.sync.SyncManager)1