use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class HoraireManager method deleteExpiredEvent.
/**
* Deletes entries in DB that doesn't exist on API
*
* @param
*/
private void deleteExpiredEvent(EventList envEventList) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
ArrayList<Event> dbEvents = new ArrayList<Event>();
try {
dbEvents = (ArrayList<Event>) dbHelper.getDao(Event.class).queryForAll();
for (Event eventsNew : dbEvents) {
if (!dbEvents.contains(eventsNew.getId())) {
Dao<Event, String> eventDao = dbHelper.getDao(Event.class);
eventDao.deleteById(eventsNew.getId());
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class HoraireFragment method fillListView.
public void fillListView() {
try {
List<Seances> seances = databaseHelper.getDao(Seances.class).queryForAll();
List<Event> events = databaseHelper.getDao(Event.class).queryForAll();
allseanceAdapter.setItemList(seances, events);
List<Seances> upcomingSeances = new ArrayList<>();
List<Event> upcomingEvents = new ArrayList<>();
DateTime now = new DateTime();
for (Seances sc : seances) {
DateTime scDate = DateTime.parse(sc.getDateDebut());
if (DateTimeComparator.getDateOnlyInstance().compare(now, scDate) <= 0) {
upcomingSeances.add(sc);
}
}
for (Event ev : events) {
DateTime evDate = DateTime.parse(ev.getDateDebut());
if (DateTimeComparator.getDateOnlyInstance().compare(now, evDate) <= 0) {
upcomingEvents.add(ev);
}
}
upcomingseanceAdapter.setItemList(upcomingSeances, upcomingEvents);
} catch (SQLException e) {
e.printStackTrace();
}
allseanceAdapter.notifyDataSetChanged();
upcomingseanceAdapter.notifyDataSetChanged();
}
use of ca.etsmtl.applets.etsmobile.model.Event in project ETSMobile-Android2 by ApplETS.
the class TodayAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
int viewType = getItemViewType(position);
Object data = getItem(position);
if (convertView == null) {
if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_TITLE_EVENT.getValue()) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_today_title, parent, false);
TextView textView = (TextView) convertView.findViewById(R.id.todays_title);
textView.setText(context.getText(R.string.today_event));
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_EVENT.getValue()) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_event, parent, false);
ViewEventHolder eventHolder = new ViewEventHolder();
eventHolder.tvEvent = (TextView) convertView.findViewById(R.id.event_text);
convertView.setTag(eventHolder);
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE.getValue()) {
convertView = LayoutInflater.from(context).inflate(R.layout.row_today_title, parent, false);
TextView textView = (TextView) convertView.findViewById(R.id.todays_title);
textView.setText(context.getText(R.string.today_course));
} 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);
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);
ViewEtsEventHolder etsEventHolder = new ViewEtsEventHolder();
etsEventHolder.tvLibelleEvenementETS = (TextView) convertView.findViewById(R.id.tv_today_libelle_ets_evenement);
convertView.setTag(etsEventHolder);
}
}
if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_EVENT.getValue()) {
Event event = (Event) data;
ViewEventHolder viewEventHolder = (ViewEventHolder) convertView.getTag();
viewEventHolder.tvEvent.setText(event.getTitle());
} else if (viewType == TodayDataRowItem.viewType.VIEW_TYPE_SEANCE.getValue()) {
Seances seance = (Seances) data;
ViewSeancesHolder viewSeancesHolder = (ViewSeancesHolder) convertView.getTag();
viewSeancesHolder.tvNomActivite.setText(seance.nomActivite);
viewSeancesHolder.tvCoursGroupe.setText(seance.coursGroupe);
viewSeancesHolder.tvLibelleCours.setText(seance.libelleCours);
viewSeancesHolder.tvLocal.setText(seance.local);
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);
}
return convertView;
}
Aggregations