use of ca.etsmtl.applets.etsmobile.util.SeanceComparator 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);
}
}
use of ca.etsmtl.applets.etsmobile.util.SeanceComparator in project ETSMobile-Android2 by ApplETS.
the class WearService method onMessageReceived.
@Override
public void onMessageReceived(MessageEvent messageEvent) {
if (messageEvent.getPath().equals("/today_req")) {
final String message = new String(messageEvent.getData());
List<Seances> seances = new ArrayList<>();
DatabaseHelper databaseHelper = new DatabaseHelper(this);
SimpleDateFormat seancesFormatter = new SimpleDateFormat("yyyy-MM-dd", getResources().getConfiguration().locale);
try {
seances = databaseHelper.getDao(Seances.class).queryBuilder().where().like("dateDebut", seancesFormatter.format(DateTime.now().toDate()) + "%").query();
Collections.sort(seances, new SeanceComparator());
} catch (SQLException e) {
e.printStackTrace();
}
new SendToDataLayerThread("/today_req", seances, this).start();
}
}
Aggregations