use of ca.etsmtl.applets.etsmobile.ui.adapter.TodayAdapter 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