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);
}
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();
}
}
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();
}
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();
}
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");
}
Aggregations