Search in sources :

Example 1 with IHoraireRows

use of ca.etsmtl.applets.etsmobile.model.IHoraireRows 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));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Seances(ca.etsmtl.applets.etsmobile.model.Seances) IHoraireRows(ca.etsmtl.applets.etsmobile.model.IHoraireRows) HoraireComparator(ca.etsmtl.applets.etsmobile.util.HoraireComparator) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Aggregations

IHoraireRows (ca.etsmtl.applets.etsmobile.model.IHoraireRows)1 Seances (ca.etsmtl.applets.etsmobile.model.Seances)1 HoraireComparator (ca.etsmtl.applets.etsmobile.util.HoraireComparator)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1