Search in sources :

Example 6 with FicheEmploye

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

the class BottinFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.menu_item_update:
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_bottin_refresh).setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_bottin, null)).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    //Suppression du bottin
                    DatabaseHelper dbHelper = new DatabaseHelper(getActivity());
                    try {
                        Dao<FicheEmploye, ?> ficheEmployeDao = dbHelper.getDao(FicheEmploye.class);
                        List<FicheEmploye> ficheEmployeList = ficheEmployeDao.queryForAll();
                        for (FicheEmploye ficheEmploye : ficheEmployeList) {
                            ficheEmployeDao.delete(ficheEmploye);
                        }
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                    //Mise à jour de la liste
                    listDataHeader = new ArrayList<>();
                    listDataChild = new HashMap<>();
                    listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, listDataChild);
                    expListView.setAdapter(listAdapter);
                    updateUI();
                    dialogInterface.dismiss();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            });
            builder.create().show();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) SQLException(java.sql.SQLException) QueryBuilder(com.j256.ormlite.stmt.QueryBuilder) ExpandableListAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) OnClickListener(android.view.View.OnClickListener)

Example 7 with FicheEmploye

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

the class BottinFragment method onRequestSuccess.

@Override
public void onRequestSuccess(Object o) {
    super.onRequestSuccess(o);
    if (o instanceof HashMap<?, ?>) {
        mProgressDialog.hide();
        @SuppressWarnings("unchecked") HashMap<String, List<FicheEmploye>> listeEmployeByService = (HashMap<String, List<FicheEmploye>>) o;
        // Écriture dans la base de données
        DatabaseHelper dbHelper = new DatabaseHelper(getActivity());
        for (String nomService : listeEmployeByService.keySet()) {
            List<FicheEmploye> listeEmployes = listeEmployeByService.get(nomService);
            if (listeEmployes.size() > 0) {
                for (FicheEmploye ficheEmploye : listeEmployeByService.get(nomService)) {
                    try {
                        dbHelper.getDao(FicheEmploye.class).createOrUpdate(ficheEmploye);
                    } catch (SQLException e) {
                        Log.e(DatabaseHelper.class.getName(), "SQLException", e);
                        throw new RuntimeException(e);
                    }
                }
            }
        }
        updateUI();
    }
}
Also used : HashMap(java.util.HashMap) DatabaseHelper(ca.etsmtl.applets.etsmobile.db.DatabaseHelper) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) List(java.util.List) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye)

Example 8 with FicheEmploye

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

the class ExpandableListAdapter method filterDataWithOneHeader.

public void filterDataWithOneHeader(String query) {
    query = query.toLowerCase();
    //		Log.v("MyListAdapter", String.valueOf(_listDataHeader.size()));
    _listDataChild.clear();
    _listDataHeader.clear();
    // Si le contenu de la recherche est vide
    if (query.isEmpty()) {
        _listDataChild = (HashMap<String, List<FicheEmploye>>) _listDataChildOriginal.clone();
        _listDataHeader.addAll(_listDataHeaderOriginal);
    } else {
        _listDataHeader.add(query);
        List<FicheEmploye> newList = new ArrayList<FicheEmploye>();
        for (Entry<String, List<FicheEmploye>> entry : _listDataChildOriginal.entrySet()) {
            List<FicheEmploye> listeFicheEmploye = entry.getValue();
            for (FicheEmploye ficheEmploye : listeFicheEmploye) {
                String nom = ficheEmploye.Nom == null ? "" : ficheEmploye.Nom.toLowerCase();
                String prenom = ficheEmploye.Prenom == null ? "" : ficheEmploye.Prenom.toLowerCase();
                Boolean exists = true;
                Boolean nomUsed = false;
                Boolean prenomUsed = false;
                for (String theQuery : query.split(" ")) {
                    if (nom.startsWith(theQuery) && !nomUsed) {
                        nomUsed = true;
                    } else if (prenom.startsWith(theQuery) && !prenomUsed) {
                        prenomUsed = true;
                    } else {
                        exists = false;
                    }
                }
                if (exists) {
                    newList.add(ficheEmploye);
                }
            }
        }
        if (!newList.isEmpty()) {
            _listDataChild.put(query, newList);
            newList = new ArrayList<FicheEmploye>();
        }
        Collections.sort(_listDataHeader);
    }
    notifyDataSetChanged();
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye)

Example 9 with FicheEmploye

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

the class ExpandableListAdapter method filterData.

public void filterData(String query) {
    query = query.toLowerCase();
    //		Log.v("MyListAdapter", String.valueOf(_listDataHeader.size()));
    _listDataChild.clear();
    _listDataHeader.clear();
    if (query.isEmpty()) {
        _listDataChild = (HashMap<String, List<FicheEmploye>>) _listDataChildOriginal.clone();
        _listDataHeader.addAll(_listDataHeaderOriginal);
    } else {
        List<FicheEmploye> newList = new ArrayList<FicheEmploye>();
        for (Entry<String, List<FicheEmploye>> entry : _listDataChildOriginal.entrySet()) {
            String departement = entry.getKey();
            List<FicheEmploye> listeFicheEmploye = entry.getValue();
            for (FicheEmploye ficheEmploye : listeFicheEmploye) {
                String nom = ficheEmploye.Nom == null ? "" : ficheEmploye.Nom.toLowerCase();
                String prenom = ficheEmploye.Prenom == null ? "" : ficheEmploye.Prenom.toLowerCase();
                if (nom.contains(query) || prenom.contains(query)) {
                    newList.add(ficheEmploye);
                }
            }
            if (!newList.isEmpty()) {
                _listDataChild.put(departement, newList);
                _listDataHeader.add(departement);
                newList = new ArrayList<FicheEmploye>();
            }
        }
        Collections.sort(_listDataHeader);
    }
    notifyDataSetChanged();
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye)

Example 10 with FicheEmploye

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

the class WebServiceSoap method GetFicheData.

public FicheEmploye GetFicheData(final String Id) throws Exception {
    return (FicheEmploye) execute(new IWcfMethod() {

        @Override
        public ExtendedSoapSerializationEnvelope CreateSoapEnvelope() {
            ExtendedSoapSerializationEnvelope __envelope = createEnvelope();
            SoapObject __soapReq = new SoapObject("http://etsmtl.ca/", "GetFicheData");
            __envelope.setOutputSoapObject(__soapReq);
            PropertyInfo __info = null;
            __info = new PropertyInfo();
            __info.namespace = "http://etsmtl.ca/";
            __info.name = "Id";
            __info.type = PropertyInfo.STRING_CLASS;
            __info.setValue(Id);
            __soapReq.addProperty(__info);
            return __envelope;
        }

        @Override
        public Object ProcessResult(ExtendedSoapSerializationEnvelope __envelope, SoapObject __result) throws Exception {
            return (FicheEmploye) getResult(FicheEmploye.class, __result, "GetFicheDataResult", __envelope);
        }
    }, "http://etsmtl.ca/GetFicheData");
}
Also used : SoapObject(org.ksoap2.serialization.SoapObject) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) PropertyInfo(org.ksoap2.serialization.PropertyInfo)

Aggregations

FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)10 SQLException (java.sql.SQLException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 DatabaseHelper (ca.etsmtl.applets.etsmobile.db.DatabaseHelper)3 ExpandableListAdapter (ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListAdapter)3 ArrayOfFicheEmploye (ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)2 QueryBuilder (com.j256.ormlite.stmt.QueryBuilder)2 SpiceException (com.octo.android.robospice.persistence.exception.SpiceException)2 HashMap (java.util.HashMap)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 SearchView (android.support.v7.widget.SearchView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ViewGroup (android.view.ViewGroup)1 ExpandableListView (android.widget.ExpandableListView)1