workin on issue #141

parent ae3d9e03
...@@ -78,6 +78,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -78,6 +78,7 @@ public class Vocabulary implements Iterable<Picto> {
modifyAttsPicto(picto_cat, picto_id, args.getJSONObject("attributes")); modifyAttsPicto(picto_cat, picto_id, args.getJSONObject("attributes"));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG,e.getMessage());
} }
break; break;
} }
...@@ -134,6 +135,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -134,6 +135,7 @@ public class Vocabulary implements Iterable<Picto> {
private boolean synchronize_upload() { private boolean synchronize_upload() {
boolean upload_pending=false; boolean upload_pending=false;
try { try {
this.pictos.clear();
PCBcontext.getPcbdb().getStudentVocabulary(this); PCBcontext.getPcbdb().getStudentVocabulary(this);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(this.getClass().getName(), " Picto json error from local storage: " + e.getMessage()); Log.e(this.getClass().getName(), " Picto json error from local storage: " + e.getMessage());
...@@ -252,7 +254,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -252,7 +254,7 @@ public class Vocabulary implements Iterable<Picto> {
pictos_cat = new LinkedList<>(); pictos_cat = new LinkedList<>();
pictos.put(new Integer(picto.get_category()),pictos_cat); pictos.put(new Integer(picto.get_category()),pictos_cat);
} }
pictos_cat.add(picto);
imgs.add(new Img(picto.get_id(), picto.get_url(), Img.VOCABULARY)); imgs.add(new Img(picto.get_id(), picto.get_url(), Img.VOCABULARY));
} }
Log.d(this.getClass().getName(), "Vocabulary size: " + updated_collection.length); Log.d(this.getClass().getName(), "Vocabulary size: " + updated_collection.length);
...@@ -393,13 +395,14 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -393,13 +395,14 @@ public class Vocabulary implements Iterable<Picto> {
return this.pictos.get(new Integer(Picto.NO_CATEGORY)); return this.pictos.get(new Integer(Picto.NO_CATEGORY));
} else { } else {
LinkedList<Picto> freePictos = new LinkedList<>(); LinkedList<Picto> freePictos = new LinkedList<>();
for (LinkedList<Picto> category : pictos.values()) { LinkedList<Picto> category=pictos.get(new Integer(Picto.NO_CATEGORY));
for (Picto picto : category) { //for (Picto picto : category) {
for (Picto picto: category) {
if (picto.getFreeRow() != -1 && picto.getFreeColumn() != -1) { if (picto.getFreeRow() != -1 && picto.getFreeColumn() != -1) {
freePictos.add(picto); freePictos.add(picto);
} }
} }
}
return freePictos; return freePictos;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment