Search in sources :

Example 6 with Event

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();
    }
}
Also used : DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Event(ca.etsmtl.applets.etsmobile.model.Event)

Example 7 with Event

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();
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Event(ca.etsmtl.applets.etsmobile.model.Event) Seances(ca.etsmtl.applets.etsmobile.model.Seances) DateTime(org.joda.time.DateTime)

Example 8 with Event

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;
}
Also used : Event(ca.etsmtl.applets.etsmobile.model.Event) TextView(android.widget.TextView) Seances(ca.etsmtl.applets.etsmobile.model.Seances) DateTime(org.joda.time.DateTime)

Aggregations

Event (ca.etsmtl.applets.etsmobile.model.Event)8 Seances (ca.etsmtl.applets.etsmobile.model.Seances)7 ArrayList (java.util.ArrayList)5 SQLException (java.sql.SQLException)4 SimpleDateFormat (java.text.SimpleDateFormat)4 DateTime (org.joda.time.DateTime)4 DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)3 TextView (android.widget.TextView)2 JoursRemplaces (ca.etsmtl.applets.etsmobile.model.JoursRemplaces)1 ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces (ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces)1 ca.etsmtl.applets.etsmobile.model.listeSeances (ca.etsmtl.applets.etsmobile.model.listeSeances)1 TodayAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.TodayAdapter)1 TodayDataRowItem (ca.etsmtl.applets.etsmobile.ui.adapter.TodayDataRowItem)1 SeanceComparator (ca.etsmtl.applets.etsmobile.util.SeanceComparator)1 SpiceException (com.octo.android.robospice.persistence.exception.SpiceException)1 ParsePosition (java.text.ParsePosition)1 Date (java.util.Date)1 Locale (java.util.Locale)1