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();
}
Aggregations