use of ca.etsmtl.applets.etsmobile.model.Seances 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.model.Seances 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;
}
use of ca.etsmtl.applets.etsmobile.model.Seances 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.Seances in project ETSMobile-Android2 by ApplETS.
the class SeanceAdapter method setItemList.
public void setItemList(List<Seances> itemListSeance, List<Event> itemListEvent) {
listSeances = new ArrayList<>();
ArrayList<IHoraireRows> listRowItems = new ArrayList<IHoraireRows>();
String tempDate = "";
DateTime today = new DateTime();
listRowItems.addAll(itemListEvent);
listRowItems.addAll(itemListSeance);
Collections.sort(listRowItems, new HoraireComparator());
for (IHoraireRows rows : listRowItems) {
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime seanceDay = formatter.parseDateTime(rows.getDateDebut().substring(0, 10));
if (!rows.getDateDebut().substring(0, 10).equals(tempDate)) {
tempDate = rows.getDateDebut().substring(0, 10);
DateTime.Property pDoW = seanceDay.dayOfWeek();
DateTime.Property pDoM = seanceDay.dayOfMonth();
DateTime.Property pMoY = seanceDay.monthOfYear();
this.listSeances.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_TITLE_SEANCE, context.getString(R.string.date_text, pDoW.getAsText(Locale.getDefault()), pDoM.get(), pMoY.getAsText(Locale.getDefault()))));
}
if (rows.getClass().equals(Event.class)) {
this.listSeances.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_ETS_EVENT, rows));
} else if (rows.getClass().equals(Seances.class)) {
this.listSeances.add(new TodayDataRowItem(TodayDataRowItem.viewType.VIEW_TYPE_SEANCE, rows));
}
}
}
use of ca.etsmtl.applets.etsmobile.model.Seances 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