use of ca.etsmtl.applets.etsmobile.model.ElementEvaluation in project ETSMobile-Android2 by ApplETS.
the class NoteManager method deleteExpiredListeDesElementsEvaluation.
/**
* Deletes marks in DB that doesn't exist on API
*
* @param
*/
private void deleteExpiredListeDesElementsEvaluation(String id) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
try {
Dao<ListeDesElementsEvaluation, String> listeDesElementsEvaluationDao = dbHelper.getDao(ListeDesElementsEvaluation.class);
ListeDesElementsEvaluation listeDesElementsEvaluation = listeDesElementsEvaluationDao.queryForId(id);
if (listeDesElementsEvaluation != null) {
Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
DeleteBuilder<ElementEvaluation, String> deleteBuilder = elementsEvaluationDao.deleteBuilder();
Where where = deleteBuilder.where();
where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);
where.and();
deleteBuilder.delete();
}
listeDesElementsEvaluationDao.deleteById(id);
} catch (SQLException e) {
e.printStackTrace();
}
}
use of ca.etsmtl.applets.etsmobile.model.ElementEvaluation in project ETSMobile-Android2 by ApplETS.
the class NoteManager method updateElementsEvaluation.
/**
* Rajout de l'id pour identifier les éléments d'évaluation par rapport au cours effectué dans une session
*/
public void updateElementsEvaluation(ListeDesElementsEvaluation listElementsEvaluation) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
try {
dbHelper.getDao(ListeDesElementsEvaluation.class).createOrUpdate(listElementsEvaluation);
for (ElementEvaluation elementEvaluation : listElementsEvaluation.liste) {
elementEvaluation.id = listElementsEvaluation.id + elementEvaluation.nom;
elementEvaluation.listeDesElementsEvaluation = listElementsEvaluation;
dbHelper.getDao(ElementEvaluation.class).createOrUpdate(elementEvaluation);
}
} catch (SQLException e) {
Log.e("SQL Exception", e.getMessage());
}
}
use of ca.etsmtl.applets.etsmobile.model.ElementEvaluation in project ETSMobile-Android2 by ApplETS.
the class NoteManager method deleteExpiredElementsEvaluation.
/**
* Deletes marks in DB that doesn't exist on API
*
* @param
*/
public void deleteExpiredElementsEvaluation(ListeDesElementsEvaluation listeDesElementsEvaluation) {
DatabaseHelper dbHelper = new DatabaseHelper(context);
HashMap<String, ElementEvaluation> elementEvaluationHashMap = new HashMap<String, ElementEvaluation>();
for (ElementEvaluation elem : listeDesElementsEvaluation.liste) {
String id = listeDesElementsEvaluation.id + elem.nom;
elementEvaluationHashMap.put(id, elem);
}
List<ElementEvaluation> elementEvaluationList = null;
try {
Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
QueryBuilder<ElementEvaluation, String> builder = elementsEvaluationDao.queryBuilder();
Where where = builder.where();
where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);
where.and();
elementEvaluationList = builder.query();
for (ElementEvaluation element : elementEvaluationList) {
if (!elementEvaluationHashMap.containsKey(element.id))
elementsEvaluationDao.deleteById(element.id);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
use of ca.etsmtl.applets.etsmobile.model.ElementEvaluation in project ETSMobile-Android2 by ApplETS.
the class MyCourseDetailAdapter method getView.
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
final int type = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
// inflate from xml
convertView = li.inflate(type == MyCourseDetailAdapter.ITEM_VIEW_TYPE_LIST_ITEM ? R.layout.list_item_value : R.layout.list_separator, null);
// init objs
holder.txtViewSeparator = (TextView) convertView.findViewById(R.id.textViewSeparator);
holder.txtView = (TextView) convertView.findViewById(R.id.textView);
holder.txtViewValue = (TextView) convertView.findViewById(R.id.value);
holder.txtViewMoy = (TextView) convertView.findViewById(R.id.item_value_moy);
holder.txtViewMed = (TextView) convertView.findViewById(R.id.item_value_med);
holder.txtViewCent = (TextView) convertView.findViewById(R.id.item_value_centile);
holder.txtViewEcType = (TextView) convertView.findViewById(R.id.item_value_ec_type);
holder.txtViewPond = (TextView) convertView.findViewById(R.id.item_value_pond);
// set tag
convertView.setTag(holder);
} else {
// get tag
holder = (ViewHolder) convertView.getTag();
}
// ui display of inflated xml
if (type == MyCourseDetailAdapter.ITEM_VIEW_TYPE_SEPARATOR) {
if (position == 0) {
holder.txtViewSeparator.setText(R.string.sommaire);
} else {
holder.txtViewSeparator.setText(R.string.mesNotes);
}
} else {
holder.txtViewMoy.setVisibility(View.GONE);
holder.txtViewMed.setVisibility(View.GONE);
holder.txtViewCent.setVisibility(View.GONE);
holder.txtViewEcType.setVisibility(View.GONE);
holder.txtViewPond.setVisibility(View.GONE);
holder.txtViewValue.setTextColor(Color.BLACK);
holder.txtViewPond.setTextColor(Color.BLACK);
holder.txtView.setTextColor(Color.BLACK);
switch(position) {
case // COURS EVAL
1:
holder.txtView.setText(R.string.cote);
holder.txtViewValue.setText(cote);
break;
case // NOTE À CE JOUR
2:
holder.txtView.setText(R.string.noteACejour);
if (courseEvaluation.scoreFinalSur100 != null) {
final String note = courseEvaluation.scoreFinalSur100;
ctx.getString(R.string.noteOnPourcent, note, nf_enUS.format(total), courseEvaluation.noteACeJour);
holder.txtViewValue.setText(ctx.getString(R.string.noteOnPourcent, note, nf_enUS.format(total), courseEvaluation.noteACeJour));
}
break;
case // MOYENNE CLASSE
3:
holder.txtView.setText(R.string.moyenne);
if (courseEvaluation.moyenneClasse != null) {
final String m = courseEvaluation.moyenneClasse;
try {
String value = nf_enUS.format(+(nf_frCA.parse(m).doubleValue() / total) * 100);
holder.txtViewValue.setText(ctx.getString(R.string.noteOnPourcent, m, nf_enUS.format(total), value));
} catch (final ParseException e1) {
e1.printStackTrace();
}
}
break;
case // ?CART TYPE
4:
holder.txtView.setText(R.string.ecartType);
holder.txtViewValue.setText(courseEvaluation.ecartTypeClasse);
break;
case // MÉDIANE
5:
holder.txtView.setText(R.string.mediane);
holder.txtViewValue.setText(courseEvaluation.medianeClasse);
break;
case // RAND CENTILLE
6:
holder.txtView.setText(R.string.rangCentile);
holder.txtViewValue.setText(courseEvaluation.rangCentileClasse);
break;
default:
// ELSE
final ElementEvaluation element = getItem(position);
if (element != null) {
holder.txtView.setText(element.nom);
try {
final String notee = element.note;
final String sur = element.corrigeSur;
double sur100 = 0;
if (element.note != null && sur != null) {
sur100 = nf_frCA.parse(notee).doubleValue() / nf_frCA.parse(sur).doubleValue() * 100;
final String tmp = nf_enUS.format(sur100);
holder.txtViewValue.setText(ctx.getString(R.string.noteOnPourcent, element.note, element.corrigeSur, tmp));
holder.txtViewMoy.setVisibility(View.VISIBLE);
holder.txtViewMed.setVisibility(View.VISIBLE);
holder.txtViewCent.setVisibility(View.VISIBLE);
holder.txtViewEcType.setVisibility(View.VISIBLE);
holder.txtViewPond.setVisibility(View.VISIBLE);
holder.txtViewMoy.setText(ctx.getString(R.string.moyenne) + ": " + nf_enUS.format(nf_frCA.parse(element.moyenne).doubleValue() / nf_frCA.parse(sur).doubleValue() * 100) + "%");
holder.txtViewMed.setText(ctx.getString(R.string.mediane) + ": " + nf_enUS.format(nf_frCA.parse(element.mediane).doubleValue() / nf_frCA.parse(sur).doubleValue() * 100) + "%");
holder.txtViewCent.setText(ctx.getString(R.string.rangCentile) + ": " + element.rangCentile);
holder.txtViewEcType.setText(ctx.getString(R.string.ecartType) + ": " + element.ecartType);
holder.txtViewPond.setText(ctx.getString(R.string.ponderation) + ": " + element.ponderation + "%");
if (element.ignoreDuCalcul.equals("Oui")) {
holder.txtViewValue.setTextColor(Color.RED);
holder.txtViewPond.setTextColor(Color.RED);
holder.txtView.setTextColor(Color.RED);
}
} else {
holder.txtViewPond.setVisibility(View.VISIBLE);
holder.txtViewMoy.setVisibility(View.INVISIBLE);
holder.txtViewValue.setText("/" + sur);
holder.txtViewPond.setText(ctx.getString(R.string.ponderation) + ": " + element.ponderation + "%");
}
} catch (final ParseException e) {
e.printStackTrace();
}
}
break;
}
}
return convertView;
}
use of ca.etsmtl.applets.etsmobile.model.ElementEvaluation in project ETSMobile-Android2 by ApplETS.
the class NotesDetailsFragment method refresh.
private void refresh() {
mlisteDesElementsEvaluation = mNoteManager.getListElementsEvaluation(id);
if (mlisteDesElementsEvaluation != null) {
List<ElementEvaluation> elementsEvaluationList = mNoteManager.getElementsEvaluation(mlisteDesElementsEvaluation);
mlisteDesElementsEvaluation.liste.addAll(elementsEvaluationList);
Activity activity = getActivity();
if (activity != null) {
final MyCourseDetailAdapter myCourseDetailAdapter = new MyCourseDetailAdapter(getActivity(), mlisteDesElementsEvaluation, cote);
getActivity().runOnUiThread(new Runnable() {
public void run() {
mlistView.setAdapter(myCourseDetailAdapter);
}
});
}
}
}
Aggregations