use of de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarItem in project TumCampusApp by TCA-Team.
the class CalendarDaoTest method createCalendarItem.
private CalendarItem createCalendarItem(String status, DateTime startDate, DateTime endDate) {
CalendarItem item = new CalendarItem(Integer.toString(nr), status, "dummy url", "title " + Integer.toString(nr), "dummy description", DateUtils.getDateTimeString(startDate.toDate()), DateUtils.getDateTimeString(endDate.toDate()), "dummy location", false);
nr++;
return item;
}
use of de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarItem in project TumCampusApp by TCA-Team.
the class RoomLocationsDaoTest method createCalendarItem.
private CalendarItem createCalendarItem(DateTime startDate, String location) {
CalendarItem item = new CalendarItem(Integer.toString(nr), "good", "dummy url", "title " + Integer.toString(nr), "dummy description", DateUtils.getDateTimeString(startDate.toDate()), DateUtils.getDateTimeString(startDate.toDate()), location, false);
nr++;
return item;
}
use of de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarItem in project TumCampusApp by TCA-Team.
the class CalendarActivity method onMonthChange.
@Override
public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) {
// Populate the week view with the events of the month to display
List<WeekViewEvent> events = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
// Note the (-1), since the calendar starts with month 0, but we get months starting with 1
calendar.set(newYear, newMonth - 1, 1);
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
// Probably refactor this to a good SQL query
for (int curDay = 1; curDay <= daysInMonth; curDay++) {
calendar.set(Calendar.DAY_OF_MONTH, curDay);
List<CalendarItem> calendarItems = calendarController.getFromDbForDate(new Date(calendar.getTimeInMillis()));
for (CalendarItem calendarItem : calendarItems) {
events.add(new IntegratedCalendarEvent(calendarItem, this));
}
}
return events;
}
use of de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarItem in project TumCampusApp by TCA-Team.
the class CalendarController method getNextDaysFromDb.
/**
* Returns all stored events in the next days from db.
* If there is a valid widget id (> 0) the events are filtered by the widgets blacklist
*
* @param dayCount The number of days
* @param widgetId The id of the widget
* @return List<IntegratedCalendarEvent> List of Events
*/
public List<IntegratedCalendarEvent> getNextDaysFromDb(int dayCount, int widgetId) {
Calendar calendar = Calendar.getInstance();
String from = DateUtils.getDateTimeString(calendar.getTime());
calendar.add(Calendar.DAY_OF_YEAR, dayCount);
String to = DateUtils.getDateTimeString(calendar.getTime());
List<IntegratedCalendarEvent> calendarEvents = new ArrayList<>();
List<CalendarItem> calendarItems = calendarDao.getNextDays(from, to, String.valueOf(widgetId));
for (CalendarItem calendarItem : calendarItems) {
calendarEvents.add(new IntegratedCalendarEvent(calendarItem, mContext));
}
return calendarEvents;
}
use of de.tum.in.tumcampusapp.component.tumui.calendar.model.CalendarItem in project TumCampusApp by TCA-Team.
the class CalendarController method addEvents.
private static void addEvents(Context c, Uri uri) {
if (ContextCompat.checkSelfPermission(c, Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) {
return;
}
// Get ID
ContentResolver contentResolver = c.getContentResolver();
String id = "0";
try (Cursor cursor = contentResolver.query(uri, PROJECTION, null, null, null)) {
while (cursor.moveToNext()) {
id = cursor.getString(0);
}
}
CalendarDao calendarDao = TcaDb.getInstance(c).calendarDao();
List<CalendarItem> calendarItems = calendarDao.getAllNotCancelled();
for (CalendarItem calendarItem : calendarItems) {
ContentValues values = calendarItem.toContentValues();
values.put(CalendarContract.Events.CALENDAR_ID, id);
values.put(CalendarContract.Events.EVENT_TIMEZONE, R.string.calendarTimeZone);
contentResolver.insert(CalendarContract.Events.CONTENT_URI, values);
}
}
Aggregations