use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class HoraireFragment method fillSeancesList.
public void fillSeancesList(Date date) {
SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd", getResources().getConfiguration().locale);
String today = seancesFormatter.format(date).toString();
try {
List<Seances> seances = databaseHelper.getDao(Seances.class).queryBuilder().where().like("dateDebut", today + "%").query();
List<Event> events = databaseHelper.getDao(Event.class).queryBuilder().where().like("startDate", today + "%").query();
seanceAdapter.setItemList(seances, events);
} catch (SQLException e) {
e.printStackTrace();
}
seanceAdapter.notifyDataSetChanged();
}
use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class HoraireFragment method setDaysList.
public void setDaysList() {
courseDays = new ArrayList<>();
finalExamDays = new ArrayList<>();
eventDays = new ArrayList<>();
try {
ArrayList<Seances> seancesList = (ArrayList<Seances>) databaseHelper.getDao(Seances.class).queryForAll();
for (Seances seance : seancesList) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date seanceDay = formatter.parse(seance.dateDebut.substring(0, 10), new ParsePosition(0));
if (seance.descriptionActivite.contains("final"))
finalExamDays.add(CalendarDay.from(seanceDay));
else
courseDays.add(CalendarDay.from(seanceDay));
}
ArrayList<Event> eventList = (ArrayList<Event>) databaseHelper.getDao(Event.class).queryForAll();
for (Event event : eventList) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date eventDay = formatter.parse(event.getDateDebut().substring(0, 10), new ParsePosition(0));
eventDays.add(CalendarDay.from(eventDay));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class SeanceAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int viewType = getItemViewType(position);
if (convertView == null) {
if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE.getValue()) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_today_title, parent, false);
ViewSeancesTitleHolder titleHolder = new ViewSeancesTitleHolder();
titleHolder.tvTitle = (TextView) convertView.findViewById(R.id.todays_title);
convertView.setTag(titleHolder);
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_SEANCE.getValue()) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_today_courses, parent, false);
ViewSeancesHolder seancesHolder = new ViewSeancesHolder();
seancesHolder.tvHeureDebut = (TextView) convertView.findViewById(R.id.tv_today_heure_debut);
seancesHolder.tvHeureFin = (TextView) convertView.findViewById(R.id.tv_today_heure_fin);
seancesHolder.tvCoursGroupe = (TextView) convertView.findViewById(R.id.tv_today_cours_groupe);
seancesHolder.tvNomActivite = (TextView) convertView.findViewById(R.id.tv_today_nom_activite);
seancesHolder.tvLibelleCours = (TextView) convertView.findViewById(R.id.tv_today_libelle_cours);
seancesHolder.tvLocal = (TextView) convertView.findViewById(R.id.tv_today_local);
seancesHolder.tvSeparator = (TextView) convertView.findViewById(R.id.tv_vertical_separator);
convertView.setTag(seancesHolder);
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_ETS_EVENT.getValue()) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_today_ets_event, parent, false);
ViewEvenementETSHolder etsEventHolder = new ViewEvenementETSHolder();
etsEventHolder.tvLibelleEvenementETS = (TextView) convertView.findViewById(R.id.tv_today_libelle_ets_evenement);
convertView.setTag(etsEventHolder);
}
}
if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE.getValue()) {
ViewSeancesTitleHolder titleHolder = (ViewSeancesTitleHolder) convertView.getTag();
titleHolder.tvTitle.setText((String) getItem(position));
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_SEANCE.getValue()) {
Seances seance = (Seances) getItem(position);
ViewSeancesHolder viewSeancesHolder = (ViewSeancesHolder) convertView.getTag();
viewSeancesHolder.tvNomActivite.setText(seance.nomActivite);
viewSeancesHolder.tvLibelleCours.setText(seance.libelleCours);
viewSeancesHolder.tvCoursGroupe.setText(seance.coursGroupe);
viewSeancesHolder.tvLocal.setText(seance.local);
if (colors.containsKey(seance.coursGroupe)) {
viewSeancesHolder.tvSeparator.setBackgroundColor(colors.get(seance.coursGroupe));
} else {
colors.put(seance.coursGroupe, rainbow[indexColor % rainbow.length]);
viewSeancesHolder.tvSeparator.setBackgroundColor(rainbow[indexColor % rainbow.length]);
indexColor++;
}
DateTime mDateDebut = DateTime.parse(seance.dateDebut);
DateTime mDateFin = DateTime.parse(seance.dateFin);
String dateDebut = String.format("%dh%02d", mDateDebut.getHourOfDay(), mDateDebut.getMinuteOfHour());
String dateFin = String.format("%dh%02d", mDateFin.getHourOfDay(), mDateFin.getMinuteOfHour());
viewSeancesHolder.tvHeureDebut.setText(dateDebut);
viewSeancesHolder.tvHeureFin.setText(dateFin);
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_ETS_EVENT.getValue()) {
Event event = (Event) getItem(position);
ViewEvenementETSHolder viewSeancesHolder = (ViewEvenementETSHolder) convertView.getTag();
viewSeancesHolder.tvLibelleEvenementETS.setText(event.getTitle());
}
return convertView;
}
use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class HoraireManager method updateCalendar.
/**
* Creates/Updates a new calendar on the user's device
*
* @param joursRemplacesSelected true if the "Jours remplacés" calendar was selected
* @param seancesSelected true if the "Séances" calendar was selected
* @param calPublicSelected true if the "Calendrier public ÉTS" was selected
* @throws Exception if there is an SQL when checking the replaced days (Jours remplacés)
*/
public void updateCalendar(boolean joursRemplacesSelected, boolean seancesSelected, boolean calPublicSelected) throws Exception {
DatabaseHelper dbHelper = new DatabaseHelper(context);
AndroidCalendarManager androidCalendarManager = new AndroidCalendarManager(context);
androidCalendarManager.deleteCalendar(calendarName);
androidCalendarManager.createCalendar(calendarName);
SimpleDateFormat joursRemplacesFormatter = new SimpleDateFormat("yyyy-MM-dd", Locale.CANADA_FRENCH);
if (joursRemplacesSelected) {
//Inserting JoursRemplaces in local calendar
ArrayList<JoursRemplaces> listeJoursRemplaces = (ArrayList<JoursRemplaces>) dbHelper.getDao(JoursRemplaces.class).queryForAll();
for (JoursRemplaces joursRemplaces : listeJoursRemplaces) {
androidCalendarManager.insertEventInCalendar(calendarName, joursRemplaces.description, joursRemplaces.description, "", joursRemplacesFormatter.parse(joursRemplaces.dateOrigine), joursRemplacesFormatter.parse(joursRemplaces.dateOrigine));
}
}
if (seancesSelected) {
//Inserting Seances in local calendar
SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.CANADA_FRENCH);
ArrayList<Seances> seances = (ArrayList<Seances>) dbHelper.getDao(Seances.class).queryForAll();
for (Seances seance : seances) {
androidCalendarManager.insertEventInCalendar(calendarName, seance.descriptionActivite.equals("Examen final") ? "Examen final " + seance.coursGroupe : seance.coursGroupe, seance.libelleCours + " - " + seance.descriptionActivite, seance.local, seancesFormatter.parse(seance.dateDebut), seancesFormatter.parse(seance.dateFin));
}
}
if (calPublicSelected) {
//Inserting public calendar ETS
ArrayList<Event> events = (ArrayList<Event>) dbHelper.getDao(Event.class).queryForAll();
for (Event event : events) {
androidCalendarManager.insertEventInCalendar(calendarName, event.getTitle(), "", "", joursRemplacesFormatter.parse(event.getDateDebut()), joursRemplacesFormatter.parse(event.getDateFin()));
}
}
}
use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class TodayFragment method updateUI.
@Override
void updateUI() {
if (isAdded()) {
dateTime = new DateTime();
DateTime.Property pDoW = dateTime.dayOfWeek();
DateTime.Property pDoM = dateTime.dayOfMonth();
DateTime.Property pMoY = dateTime.monthOfYear();
todaysTv.setText(getActivity().getString(R.string.horaire, pDoW.getAsText(getResources().getConfiguration().locale), pDoM.get(), pMoY.getAsText(getResources().getConfiguration().locale)));
databaseHelper = new DatabaseHelper(getActivity());
listSeances = new ArrayList<Seances>();
events = new ArrayList<Event>();
try {
SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd", getResources().getConfiguration().locale);
listSeances = (ArrayList<Seances>) databaseHelper.getDao(Seances.class).queryBuilder().where().like("dateDebut", seancesFormatter.format(dateTime.toDate()).toString() + "%").query();
Collections.sort(listSeances, new SeanceComparator());
events = (ArrayList<Event>) databaseHelper.getDao(Event.class).queryBuilder().where().like("startDate", seancesFormatter.format(dateTime.toDate()).toString() + "%").query();
} catch (Exception e) {
e.printStackTrace();
}
ArrayList<TodayDataRowItem> dataRowItems = new ArrayList<TodayDataRowItem>();
if (!events.isEmpty()) {
dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_TITLE_EVENT));
for (Event event : events) {
dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_EVENT, event));
}
}
dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE));
if (listSeances.isEmpty()) {
tvNoCourses.setVisibility(View.VISIBLE);
} else {
for (Seances seances : listSeances) {
dataRowItems.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_SEANCE, seances));
}
tvNoCourses.setVisibility(View.GONE);
}
adapter = new TodayAdapter(getActivity(), dataRowItems);
todaysList.setAdapter(adapter);
}
}
Aggregations