Search in sources :

Example 1 with Kino

use of de.tum.in.tumcampusapp.component.ui.tufilm.model.Kino in project TumCampusApp by TCA-Team.

the class CacheManager method fillCache.

/**
 * Download usual tumOnline requests
 */
public void fillCache() {
    NetUtils net = new NetUtils(mContext);
    // Cache news source images
    NewsController newsController = new NewsController(mContext);
    List<NewsSources> newsSources = newsController.getNewsSources();
    for (NewsSources newsSource : newsSources) {
        String imgUrl = newsSource.getIcon();
        if (!imgUrl.isEmpty() && !"null".equals(imgUrl)) {
            net.downloadImage(imgUrl);
        }
    }
    // Cache news images
    List<News> news = newsController.getAllFromDb(mContext);
    for (News n : news) {
        String imgUrl = n.getImage();
        if (!imgUrl.isEmpty() && !"null".equals(imgUrl)) {
            net.downloadImage(imgUrl);
        }
    }
    // Cache kino covers
    kinoDao.getAll().subscribe(it -> {
        for (Kino kino : it) {
            String imgUrl = kino.getCover();
            if (!imgUrl.isEmpty() && !"null".equals(imgUrl)) {
                net.downloadImage(imgUrl);
            }
        }
    });
    // acquire access token
    if (!new AccessTokenManager(mContext).hasValidAccessToken()) {
        return;
    }
    // ALL STUFF BELOW HERE NEEDS A VALID ACCESS TOKEN
    // Sync organisation tree
    TUMOnlineRequest<OrgItemList> requestHandler = new TUMOnlineRequest<>(TUMOnlineConst.Companion.getORG_TREE(), mContext);
    if (shouldRefresh(requestHandler.getRequestURL())) {
        requestHandler.fetch();
    }
    // Sync fee status
    TUMOnlineRequest<TuitionList> requestHandler2 = new TUMOnlineRequest<>(TUMOnlineConst.Companion.getTUITION_FEE_STATUS(), mContext);
    if (shouldRefresh(requestHandler2.getRequestURL())) {
        requestHandler2.fetch();
    }
    // Sync lectures, details and appointments
    importLecturesFromTUMOnline();
    // Sync calendar
    syncCalendar();
}
Also used : TUMOnlineRequest(de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest) AccessTokenManager(de.tum.in.tumcampusapp.api.tumonline.AccessTokenManager) OrgItemList(de.tum.in.tumcampusapp.component.other.departments.model.OrgItemList) TuitionList(de.tum.in.tumcampusapp.component.tumui.tutionfees.model.TuitionList) NewsController(de.tum.in.tumcampusapp.component.ui.news.NewsController) NewsSources(de.tum.in.tumcampusapp.component.ui.news.model.NewsSources) News(de.tum.in.tumcampusapp.component.ui.news.model.News) Kino(de.tum.in.tumcampusapp.component.ui.tufilm.model.Kino)

Aggregations

AccessTokenManager (de.tum.in.tumcampusapp.api.tumonline.AccessTokenManager)1 TUMOnlineRequest (de.tum.in.tumcampusapp.api.tumonline.TUMOnlineRequest)1 OrgItemList (de.tum.in.tumcampusapp.component.other.departments.model.OrgItemList)1 TuitionList (de.tum.in.tumcampusapp.component.tumui.tutionfees.model.TuitionList)1 NewsController (de.tum.in.tumcampusapp.component.ui.news.NewsController)1 News (de.tum.in.tumcampusapp.component.ui.news.model.News)1 NewsSources (de.tum.in.tumcampusapp.component.ui.news.model.NewsSources)1 Kino (de.tum.in.tumcampusapp.component.ui.tufilm.model.Kino)1