use of de.tum.in.tumcampusapp.utils.sync.SyncManager in project TumCampusApp by TCA-Team.
the class CalendarActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get a reference for the week view in the layout.
mWeekView = findViewById(R.id.weekView);
// The week view has infinite scrolling horizontally. We have to provide the events of a
// month every time the month changes on the week view.
mWeekView.setMonthChangeListener(this);
mWeekView.setOnEventClickListener(this);
// Get time to show e.g. a lectures starting time or 0 for now
Intent i = getIntent();
mShowDate = Calendar.getInstance();
if (i != null && i.hasExtra(EVENT_TIME)) {
long time = i.getLongExtra(EVENT_TIME, 0);
mShowDate.setTime(new Date(time));
} else {
mShowDate.setTime(new Date());
}
// Get setting from sharedprefs and refresh the view with everything
this.mWeekMode = Utils.getSettingBool(this, Const.CALENDAR_WEEK_MODE, false);
this.refreshWeekView();
calendarController = new CalendarController(this);
// Set the time space between now and after this date and before this
// Dates before the current date
requestHandler.setParameter("pMonateVor", String.valueOf(MONTH_BEFORE));
// Dates after the current date
requestHandler.setParameter("pMonateNach", String.valueOf(MONTH_AFTER));
if (new SyncManager(this).needSync(Const.SYNC_CALENDAR_IMPORT, TIME_TO_SYNC_CALENDAR)) {
requestFetch();
} else {
isFetched = true;
}
}
use of de.tum.in.tumcampusapp.utils.sync.SyncManager in project TumCampusApp by TCA-Team.
the class CalendarController method importCalendar.
public void importCalendar(CalendarRowSet myCalendarList) {
// Cleanup cache before importing
removeCache();
// reading xml
List<CalendarRow> myCalendar = myCalendarList.getKalendarList();
if (myCalendar != null) {
for (CalendarRow row : myCalendar) {
// insert into database
try {
replaceIntoDb(row);
} catch (Exception e) {
Utils.log(e);
}
}
}
new SyncManager(mContext).replaceIntoDb(Const.SYNC_CALENDAR_IMPORT);
}
Aggregations