Search in sources :

Example 1 with AppletsApiCalendarRequest

use of ca.etsmtl.applets.etsmobile.http.AppletsApiCalendarRequest in project ETSMobile-Android2 by ApplETS.

the class TodayWidgetProvider method requestEventList.

/**
     * Procédure déclenchant une requête additionnelle pour permettre la synchronisation de la liste
     * d'événements et satisfaire la condition syncEventListEnded dans
     * {@link ca.etsmtl.applets.etsmobile.util.HoraireManager#onRequestSuccess(Object)}
     *
     * @param listeDeSessions
     */
private void requestEventList(ListeDeSessions listeDeSessions) {
    Trimestre derniereSession = Collections.max(listeDeSessions.liste, new TrimestreComparator());
    DateTime dateDebut = new DateTime(derniereSession.dateDebut);
    if (DateTime.now().isBefore(dateDebut)) {
        dateDebut = DateTime.now();
    }
    DateTime dateEnd = new DateTime(derniereSession.dateFin);
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    String dateDebutFormatted = formatter.format(dateDebut.toDate());
    String dateFinFormatted = formatter.format(dateEnd.toDate());
    dataManager.start();
    dataManager.sendRequest(new AppletsApiCalendarRequest(context, dateDebutFormatted, dateFinFormatted), this);
}
Also used : Trimestre(ca.etsmtl.applets.etsmobile.model.Trimestre) TrimestreComparator(ca.etsmtl.applets.etsmobile.util.TrimestreComparator) AppletsApiCalendarRequest(ca.etsmtl.applets.etsmobile.http.AppletsApiCalendarRequest) SimpleDateFormat(java.text.SimpleDateFormat) DateTime(org.joda.time.DateTime)

Example 2 with AppletsApiCalendarRequest

use of ca.etsmtl.applets.etsmobile.http.AppletsApiCalendarRequest in project ETSMobile-Android2 by ApplETS.

the class HoraireFragment method onRequestSuccess.

@Override
public void onRequestSuccess(final Object o) {
    if (o instanceof ListeDeSessions && !((ListeDeSessions) o).liste.isEmpty()) {
        ListeDeSessions listeDeSessions = (ListeDeSessions) o;
        Trimestre derniereSession = Collections.max(listeDeSessions.liste, new TrimestreComparator());
        DateTime dateDebut = new DateTime(derniereSession.dateDebut);
        if (DateTime.now().isBefore(dateDebut)) {
            dateDebut = DateTime.now();
        }
        DateTime dateEnd = new DateTime(derniereSession.dateFin);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateDebutFormatted = formatter.format(dateDebut.toDate());
        String dateFinFormatted = formatter.format(dateEnd.toDate());
        dataManager.sendRequest(new AppletsApiCalendarRequest(getActivity(), dateDebutFormatted, dateFinFormatted), this);
    }
    horaireManager.onRequestSuccess(o);
}
Also used : ListeDeSessions(ca.etsmtl.applets.etsmobile.model.ListeDeSessions) Trimestre(ca.etsmtl.applets.etsmobile.model.Trimestre) TrimestreComparator(ca.etsmtl.applets.etsmobile.util.TrimestreComparator) AppletsApiCalendarRequest(ca.etsmtl.applets.etsmobile.http.AppletsApiCalendarRequest) SimpleDateFormat(java.text.SimpleDateFormat) DateTime(org.joda.time.DateTime)

Aggregations

AppletsApiCalendarRequest (ca.etsmtl.applets.etsmobile.http.AppletsApiCalendarRequest)2 Trimestre (ca.etsmtl.applets.etsmobile.model.Trimestre)2 TrimestreComparator (ca.etsmtl.applets.etsmobile.util.TrimestreComparator)2 SimpleDateFormat (java.text.SimpleDateFormat)2 DateTime (org.joda.time.DateTime)2 ListeDeSessions (ca.etsmtl.applets.etsmobile.model.ListeDeSessions)1