Search in sources :

Example 6 with SyncManager

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;
    }
}
Also used : SyncManager(de.tum.in.tumcampusapp.utils.sync.SyncManager) Intent(android.content.Intent) Date(java.util.Date)

Example 7 with SyncManager

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);
}
Also used : SyncManager(de.tum.in.tumcampusapp.utils.sync.SyncManager) CalendarRow(de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarRow)

Aggregations

SyncManager (de.tum.in.tumcampusapp.utils.sync.SyncManager)7 JSONObject (org.json.JSONObject)3 NetUtils (de.tum.in.tumcampusapp.utils.NetUtils)2 JSONArray (org.json.JSONArray)2 Intent (android.content.Intent)1 CalendarRow (de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarRow)1 CafeteriaViewModel (de.tum.in.tumcampusapp.component.ui.cafeteria.details.CafeteriaViewModel)1 CafeteriaLocalRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaLocalRepository)1 CafeteriaRemoteRepository (de.tum.in.tumcampusapp.component.ui.cafeteria.repository.CafeteriaRemoteRepository)1 KinoViewModel (de.tum.in.tumcampusapp.component.ui.news.KinoViewModel)1 News (de.tum.in.tumcampusapp.component.ui.news.model.News)1 NewsSources (de.tum.in.tumcampusapp.component.ui.news.model.NewsSources)1 StudyRoom (de.tum.in.tumcampusapp.component.ui.studyroom.model.StudyRoom)1 StudyRoomGroup (de.tum.in.tumcampusapp.component.ui.studyroom.model.StudyRoomGroup)1 Date (java.util.Date)1 JSONException (org.json.JSONException)1 Before (org.junit.Before)1