Search in sources :

Example 1 with Etudiant

use of ca.etsmtl.applets.etsmobile.model.Etudiant in project ETSMobile-Android2 by ApplETS.

the class ProfilFragment method onRequestSuccess.

@Override
public void onRequestSuccess(Object o) {
    super.onRequestSuccess(o);
    if (o != null) {
        if (o instanceof Etudiant) {
            Etudiant etudiant = (Etudiant) o;
            profileAdapter.updateEtudiant(etudiant);
            if (etudiant.erreur == null) {
                // Save Etudiant class in DB
                profilManager.updateEtudiant(etudiant);
            }
        } else if (o instanceof listeDesProgrammes) {
            listeDesProgrammes listeDesProgrammes = (listeDesProgrammes) o;
            if (listeDesProgrammes.erreur == null) {
                for (Programme p : listeDesProgrammes.liste) {
                    profilManager.updateProgramme(p);
                }
            }
        }
        updateUI();
    }
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) ca.etsmtl.applets.etsmobile.model.listeDesProgrammes(ca.etsmtl.applets.etsmobile.model.listeDesProgrammes) Programme(ca.etsmtl.applets.etsmobile.model.Programme)

Example 2 with Etudiant

use of ca.etsmtl.applets.etsmobile.model.Etudiant in project ETSMobile-Android2 by ApplETS.

the class LoginActivity method onRequestSuccess.

@Override
public void onRequestSuccess(Object o) {
    showProgress(false);
    if (o != null) {
        Etudiant etudiant = (Etudiant) o;
        if (etudiant.erreur != null) {
            mPasswordView.setError(getString(R.string.error_invalid_pwd));
            mPasswordView.requestFocus();
        } else {
            ApplicationManager.userCredentials = userCredentials;
            TodayWidgetProvider.updateAllWidgets(this);
            String accountName = userCredentials.getUsername();
            String accountPassword = userCredentials.getPassword();
            createETSMobileAccount(accountName, accountPassword);
            startActivity(new Intent(LoginActivity.this, MainActivity.class));
            //Run authentication to monETS in another thread not to slow app
            new AuthentificationPortailTask(this).execute(getString(R.string.portail_api_authentification_url), ApplicationManager.userCredentials.getUsername(), ApplicationManager.userCredentials.getPassword());
            finishActivity(1);
        }
    } else {
        mPasswordView.setError(getString(R.string.error_invalid_email));
        mPasswordView.requestFocus();
    }
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) Intent(android.content.Intent) AuthentificationPortailTask(ca.etsmtl.applets.etsmobile.http.AuthentificationPortailTask)

Example 3 with Etudiant

use of ca.etsmtl.applets.etsmobile.model.Etudiant in project ETSMobile-Android2 by ApplETS.

the class MainActivity method initDrawer.

private void initDrawer() {
    boolean isUserLoggedIn = ApplicationManager.userCredentials != null;
    String studentName = "";
    String codeUniversel = "";
    ProfilManager profilManager = new ProfilManager(this);
    Etudiant etudiant = profilManager.getEtudiant();
    if (etudiant != null) {
        String prenom = etudiant.prenom != null ? etudiant.prenom.trim() : "";
        String nom = etudiant.nom != null ? etudiant.nom.trim() : "";
        studentName = prenom + " " + nom;
        codeUniversel = etudiant.codePerm != null ? etudiant.codePerm : "";
    }
    headerResult = new AccountHeaderBuilder().withActivity(this).withHeaderBackground(R.drawable.ets_background_grayscale).withSelectionListEnabledForSingleProfile(false).addProfiles(new ProfileDrawerItem().withName(codeUniversel).withEmail(studentName).withSelectedTextColor(ContextCompat.getColor(this, R.color.red)).withIcon(R.drawable.ic_user).withSelectable(isUserLoggedIn)).withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {

        @Override
        public boolean onProfileChanged(View view, IProfile profile, boolean current) {
            goToFragment(new ProfilFragment(), ProfilFragment.class.getName());
            return false;
        }
    }).build();
    DrawerBuilder drawerBuilder = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult).withSelectedItem(isUserLoggedIn ? TODAY_FRAGMENT : ABOUT_FRAGMENT).withDisplayBelowStatusBar(true).withShowDrawerOnFirstLaunch(true).addDrawerItems(new ExpandableDrawerItem().withName(R.string.menu_section_1_moi).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_1_ajd).withIdentifier(TODAY_FRAGMENT).withIcon(R.drawable.ic_ico_aujourdhui).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_horaire).withIdentifier(SCHEDULE_FRAGMENT).withIcon(R.drawable.ic_ico_schedule).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_notes).withIdentifier(COURSE_FRAGMENT).withIcon(R.drawable.ic_ico_notes).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_2_moodle).withIdentifier(MOODLE_FRAGMENT).withIcon(R.drawable.ic_moodle_icon_small).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_monETS).withIdentifier(MONETS_FRAGMENT).withIcon(R.drawable.ic_monets).withEnabled(isUserLoggedIn), new SecondaryDrawerItem().withName(R.string.menu_section_1_bandwith).withIdentifier(BANDWIDTH_FRAGMENT).withIcon(R.drawable.ic_ico_internet)).withIsExpanded(true), new ExpandableDrawerItem().withName(R.string.menu_section_2_ets).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_2_news).withIdentifier(NEWS_FRAGMENT).withIcon(R.drawable.ic_ico_news), new SecondaryDrawerItem().withName(R.string.menu_section_2_events).withIdentifier(EVENTS_FRAGMENT).withIcon(R.drawable.ic_event_available), new SecondaryDrawerItem().withName(R.string.menu_section_2_bottin).withIdentifier(DIRECTORY_FRAGMENT).withIcon(R.drawable.ic_ico_bottin), new SecondaryDrawerItem().withName(R.string.menu_section_2_biblio).withIdentifier(LIBRARY_FRAGMENT).withIcon(R.drawable.ic_ico_library), new SecondaryDrawerItem().withName(R.string.menu_section_2_securite).withIdentifier(SECURITY_FRAGMENT).withIcon(R.drawable.ic_ico_security)), new ExpandableDrawerItem().withName(R.string.menu_section_3_applets).withSelectable(false).withSubItems(new SecondaryDrawerItem().withName(R.string.menu_section_3_apps).withIdentifier(ACHIEVEMENTS_FRAGMENT).withIcon(R.drawable.ic_star_60x60), new SecondaryDrawerItem().withName(R.string.menu_section_3_about).withIdentifier(ABOUT_FRAGMENT).withIcon(R.drawable.ic_logo_icon_final), new SecondaryDrawerItem().withName(R.string.menu_section_3_comms).withIdentifier(COMMENTS_FRAGMENT).withIcon(R.drawable.ic_ico_comment), new SecondaryDrawerItem().withName(R.string.menu_section_3_sponsors).withIdentifier(SPONSOR_FRAGMENT).withIcon(R.drawable.ic_ico_partners), new SecondaryDrawerItem().withName(R.string.menu_section_3_faq).withIdentifier(FAQ_FRAGMENT).withIcon(R.drawable.ic_ico_faq)));
    if (isUserLoggedIn)
        drawerBuilder.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.action_logout).withIdentifier(LOGOUT).withTextColorRes(R.color.red));
    else
        drawerBuilder.addStickyDrawerItems(new SecondaryDrawerItem().withName(R.string.action_login).withIdentifier(LOGIN));
    drawerBuilder.withOnDrawerItemClickListener(drawerItemClickListener);
    drawerBuilder.build();
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) ProfilFragment(ca.etsmtl.applets.etsmobile.ui.fragment.ProfilFragment) ProfileDrawerItem(com.mikepenz.materialdrawer.model.ProfileDrawerItem) AccountHeaderBuilder(com.mikepenz.materialdrawer.AccountHeaderBuilder) View(android.view.View) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) AccountHeader(com.mikepenz.materialdrawer.AccountHeader) ExpandableDrawerItem(com.mikepenz.materialdrawer.model.ExpandableDrawerItem) IProfile(com.mikepenz.materialdrawer.model.interfaces.IProfile) DrawerBuilder(com.mikepenz.materialdrawer.DrawerBuilder) ProfilManager(ca.etsmtl.applets.etsmobile.util.ProfilManager)

Example 4 with Etudiant

use of ca.etsmtl.applets.etsmobile.model.Etudiant in project ETSMobile-Android2 by ApplETS.

the class DataManager method getDataFromSignet.

/**
	 * Robospice request manager for everything not related to Signet-Mobile the
	 * class (result) must be mapped with Gson
	 * 
	 * @param request
	 * @param listener
	 * @return true if request is sent
	 */
// public boolean sendRequest(TypedRequest request, RequestListener<Object>
// listener) {
//
// final Object key = request.createCacheKey();
// spiceManager.execute(request, key, DurationInMillis.ONE_SECOND,
// listener);
// return true;
// }
/**
	 * Send a request to Signet-Mobile Web Service
	 * 
	 * @param method
	 *            Int, methods are stored in SignetMethod
	 * @param creds
	 *            User Credentials
	 * @param listener
	 *            The callback
	 * @param params
	 *            Some methods require more than the credentials pass them here
	 */
public void getDataFromSignet(int method, final UserCredentials creds, final RequestListener<Object> listener, String... params) {
    // inline asynctask
    new AsyncTask<Object, Void, Object>() {

        private Exception exception = null;

        private Object result;

        @Override
        protected Object doInBackground(Object... params) {
            try {
                final int methodID = (Integer) params[0];
                String[] reqParams = (String[]) params[1];
                final SignetsMobileSoap signetsMobileSoap = new SignetsMobileSoap();
                String username = "";
                String password = "";
                if (methodID < SignetMethods.BOTTIN_LIST_DEPT || methodID > SignetMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP) {
                    username = creds.getUsername();
                    password = creds.getPassword();
                }
                switch(methodID) {
                    case SignetMethods.INFO_ETUDIANT:
                        result = signetsMobileSoap.infoEtudiant(username, password);
                        dbHelper.getDao(Etudiant.class).createOrUpdate((Etudiant) result);
                        break;
                    case SignetMethods.LIST_COURS:
                        result = signetsMobileSoap.listeCours(username, password);
                        break;
                    case SignetMethods.LIST_INT_SESSION:
                        String SesFin = reqParams[0];
                        String SesDebut = reqParams[1];
                        result = signetsMobileSoap.listeCoursIntervalleSessions(username, password, SesDebut, SesFin);
                        break;
                    case SignetMethods.LIST_SESSION:
                        result = signetsMobileSoap.listeSessions(username, password);
                        break;
                    case SignetMethods.LIST_PROGRAM:
                        result = signetsMobileSoap.listeProgrammes(username, password);
                        break;
                    case SignetMethods.LIST_COEQ:
                        String pNomElementEval = reqParams[0];
                        String pSession = reqParams[1];
                        String pGroupe = reqParams[2];
                        String pSigle = reqParams[3];
                        result = signetsMobileSoap.listeCoequipiers(username, password, pSigle, pGroupe, pSession, pNomElementEval);
                        break;
                    case SignetMethods.LIST_EVAL:
                        String pSession1 = reqParams[0];
                        String pGroupe1 = reqParams[1];
                        String pSigle1 = reqParams[2];
                        result = signetsMobileSoap.listeElementsEvaluation(username, password, pSigle1, pGroupe1, pSession1);
                        break;
                    case SignetMethods.LIST_HORAIRE_PROF:
                        String pSession2 = reqParams[0];
                        result = signetsMobileSoap.listeHoraireEtProf(username, password, pSession2);
                        break;
                    case SignetMethods.LIRE_HORAIRE:
                        String pSession3 = reqParams[0];
                        String prefixeSigleCours = reqParams[1];
                        result = signetsMobileSoap.lireHoraire(pSession3, prefixeSigleCours);
                        break;
                    case SignetMethods.LIRE_JOURS_REMPLACES:
                        String pSession4 = reqParams[0];
                        result = signetsMobileSoap.lireJoursRemplaces(pSession4);
                        break;
                    case SignetMethods.BOTTIN_LIST_DEPT:
                        result = new WebServiceSoap().GetListeDepartement();
                        break;
                    case SignetMethods.BOTTIN_GET_FICHE:
                        String numero = reqParams[0];
                        String PathFiche = reqParams[1];
                        result = new WebServiceSoap().GetFiche(numero, PathFiche);
                        break;
                    case SignetMethods.BOTTIN_GET_FICHE_DATA:
                        String Id = reqParams[0];
                        result = new WebServiceSoap().GetFicheData(Id);
                        break;
                    case SignetMethods.BOTTIN_GET_ALL:
                        result = new WebServiceSoap().Recherche(null, null, null);
                        break;
                    case SignetMethods.BOTTIN_GET_FICHE_BY_SERVICE:
                        String filtreServiceCode = reqParams[0];
                        result = new WebServiceSoap().Recherche(null, null, filtreServiceCode);
                        break;
                    case SignetMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP:
                        ArrayOfService arrayOfService = new WebServiceSoap().GetListeDepartement();
                        HashMap<String, List<FicheEmploye>> listeEmployeByService = new HashMap<String, List<FicheEmploye>>();
                        ArrayOfFicheEmploye arrayOfFicheEmploye;
                        for (int i = 0; i < arrayOfService.size(); i++) {
                            Service service = arrayOfService.get(i);
                            arrayOfFicheEmploye = new WebServiceSoap().Recherche(null, null, "" + service.ServiceCode);
                            listeEmployeByService.put(service.Nom, arrayOfFicheEmploye);
                        }
                        result = listeEmployeByService;
                        break;
                    case SignetMethods.LIST_EXAMENS_FINAUX:
                        String pSession5 = reqParams[0];
                        result = signetsMobileSoap.listeHoraireExamensFin(username, password, pSession5);
                        break;
                    case SignetMethods.LIST_SEANCES:
                        String pCoursGroupe = reqParams[0];
                        String pSession6 = reqParams[1];
                        String pDateDebut = reqParams[2];
                        String pDateFin = reqParams[3];
                        result = signetsMobileSoap.lireHoraireDesSeances(username, password, pCoursGroupe, pSession6, pDateDebut, pDateFin);
                        break;
                    case SignetMethods.LIST_SEANCES_CURRENT_AND_NEXT_SESSION:
                        ListeDeSessions listeDeSessions = signetsMobileSoap.listeSessions(username, password);
                        listeSeances listeSeances = new listeSeances();
                        DateTime dt = new DateTime();
                        DateTime dtEnd = new DateTime();
                        for (Trimestre trimestre : listeDeSessions.liste) {
                            dtEnd = new DateTime(trimestre.dateFin);
                            if (dt.isBefore(dtEnd.plusDays(1))) {
                                listeSeances.ListeDesSeances.addAll(signetsMobileSoap.lireHoraireDesSeances(username, password, "", trimestre.abrege, "", "").ListeDesSeances);
                            }
                        }
                        result = listeSeances;
                        break;
                    case SignetMethods.LIST_EXAM_CURRENT_AND_NEXT_SESSION:
                        ListeDeSessions listeDeSessions2 = signetsMobileSoap.listeSessions(username, password);
                        listeHoraireExamensFinaux listeHoraireExamensFinaux = new listeHoraireExamensFinaux();
                        DateTime dt2 = new DateTime();
                        DateTime dtEnd2 = new DateTime();
                        for (Trimestre trimestre : listeDeSessions2.liste) {
                            dtEnd2 = new DateTime(trimestre.dateFin);
                            if (dt2.isBefore(dtEnd2.plusDays(1))) {
                                listeHoraireExamensFinaux.listeHoraire.addAll(signetsMobileSoap.listeHoraireExamensFin(username, password, trimestre.abrege).listeHoraire);
                            }
                        }
                        result = listeHoraireExamensFinaux;
                        break;
                    case SignetMethods.LIST_JOURSREMPLACES_CURRENT_AND_NEXT_SESSION:
                        ListeDeSessions listeDeSessions3 = signetsMobileSoap.listeSessions(username, password);
                        listeJoursRemplaces listeJoursRemplaces = new listeJoursRemplaces();
                        DateTime dt3 = new DateTime();
                        DateTime dtEnd3 = new DateTime();
                        for (Trimestre trimestre : listeDeSessions3.liste) {
                            dtEnd3 = new DateTime(trimestre.dateFin);
                            if (dt3.isBefore(dtEnd3.plusDays(1))) {
                                listeJoursRemplaces.listeJours.addAll(signetsMobileSoap.lireJoursRemplaces(trimestre.abrege).listeJours);
                            }
                        }
                        result = listeJoursRemplaces;
                        break;
                    default:
                        break;
                }
            } catch (Exception e) {
                e.printStackTrace();
                exception = e;
            }
            return null;
        }

        protected void onPostExecute(Object result2) {
            if (exception != null) {
                listener.onRequestFailure(new SpiceException("Couldn't get datas"));
            } else {
                listener.onRequestSuccess(result);
            }
        }
    }.execute(method, params);
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) HashMap(java.util.HashMap) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) WebServiceSoap(ca.etsmtl.applets.etsmobile.http.soap.WebServiceSoap) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) Service(ca.etsmtl.applets.etsmobile.model.Service) ListeDeSessions(ca.etsmtl.applets.etsmobile.model.ListeDeSessions) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye) SQLException(java.sql.SQLException) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) DateTime(org.joda.time.DateTime) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) ca.etsmtl.applets.etsmobile.model.listeSeances(ca.etsmtl.applets.etsmobile.model.listeSeances) ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces(ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces) Trimestre(ca.etsmtl.applets.etsmobile.model.Trimestre) SignetsMobileSoap(ca.etsmtl.applets.etsmobile.http.soap.SignetsMobileSoap) List(java.util.List) ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux(ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)

Example 5 with Etudiant

use of ca.etsmtl.applets.etsmobile.model.Etudiant in project ETSMobile-Android2 by ApplETS.

the class ProfilManager method getEtudiant.

public Etudiant getEtudiant() {
    DatabaseHelper dbHelper = new DatabaseHelper(context);
    Etudiant etudiant = null;
    try {
        List<Etudiant> etudiantList = dbHelper.getDao(Etudiant.class).queryForAll();
        if (!etudiantList.isEmpty())
            // Get Student if exists
            etudiant = etudiantList.get(0);
    } catch (SQLException e) {
        Log.e("SQL Exception", e.getMessage());
    }
    return etudiant;
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException)

Aggregations

Etudiant (ca.etsmtl.applets.etsmobile.model.Etudiant)7 Programme (ca.etsmtl.applets.etsmobile.model.Programme)2 SQLException (java.sql.SQLException)2 Intent (android.content.Intent)1 View (android.view.View)1 DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)1 AuthentificationPortailTask (ca.etsmtl.applets.etsmobile.http.AuthentificationPortailTask)1 SignetsMobileSoap (ca.etsmtl.applets.etsmobile.http.soap.SignetsMobileSoap)1 WebServiceSoap (ca.etsmtl.applets.etsmobile.http.soap.WebServiceSoap)1 ArrayOfFicheEmploye (ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)1 ArrayOfService (ca.etsmtl.applets.etsmobile.model.ArrayOfService)1 FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)1 ListeDeSessions (ca.etsmtl.applets.etsmobile.model.ListeDeSessions)1 Service (ca.etsmtl.applets.etsmobile.model.Service)1 Trimestre (ca.etsmtl.applets.etsmobile.model.Trimestre)1 ca.etsmtl.applets.etsmobile.model.listeDesProgrammes (ca.etsmtl.applets.etsmobile.model.listeDesProgrammes)1 ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux (ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux)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 ProfilFragment (ca.etsmtl.applets.etsmobile.ui.fragment.ProfilFragment)1