Atributo categories e id_scene añadidos a User, y cambiadas las llamadas que…

Atributo categories e id_scene añadidos a User, y cambiadas las llamadas que habia anteriormente en el código por las nuevas para saber si tiene o no categorias
parent 4748b817
...@@ -44,7 +44,6 @@ public class User { ...@@ -44,7 +44,6 @@ public class User {
public static String READ="read"; public static String READ="read";
public static String HIGHLIGHT="highlight"; public static String HIGHLIGHT="highlight";
} }
private String supervisors;
private Img img_stu; private Img img_stu;
private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu; private String nickname_stu, pwd_stu, name_stu, surname_stu, gender_stu, lang_stu;
private JSONObject attributes_stu; private JSONObject attributes_stu;
...@@ -260,7 +259,7 @@ public class User { ...@@ -260,7 +259,7 @@ public class User {
*/ */
public void set_has_categories(boolean categories){ public void set_has_categories(boolean categories){
try { try {
this.attributes_stu.put(JSON_STUDENT_ATTTRS.CATEGORIES, true); this.attributes_stu.put(JSON_STUDENT_ATTTRS.CATEGORIES, categories);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -277,13 +276,6 @@ public class User { ...@@ -277,13 +276,6 @@ public class User {
} }
} }
public String get_Supervisors(){
return this.supervisors;
}
public void set_Supervisors(String newSup) {
this.supervisors = newSup;
}
/** /**
* *
* @return delivery method * @return delivery method
......
...@@ -36,7 +36,8 @@ import java.util.Vector; ...@@ -36,7 +36,8 @@ import java.util.Vector;
*/ */
public class Vocabulary implements Iterable<Picto> { public class Vocabulary implements Iterable<Picto> {
private boolean has_categories;
private int id_scene;
private static final String LOG_TAG = Vocabulary.class.getName(); private static final String LOG_TAG = Vocabulary.class.getName();
Hashtable<Integer,LinkedList<Picto>> pictos; Hashtable<Integer,LinkedList<Picto>> pictos;
static int DEFAULT_VOCABULARY_SIZE=200; static int DEFAULT_VOCABULARY_SIZE=200;
...@@ -94,7 +95,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -94,7 +95,7 @@ public class Vocabulary implements Iterable<Picto> {
JSONObject attrs_picto = args.getJSONObject("attributes"); JSONObject attrs_picto = args.getJSONObject("attributes");
attrs_picto.put(Picto.JSON_ATTTRS.STUPICTO_ID,args.getInt("id")); attrs_picto.put(Picto.JSON_ATTTRS.STUPICTO_ID,args.getInt("id"));
Picto newPicto=new Picto(picto_id, uri, attrs_picto); Picto newPicto=new Picto(picto_id, uri, attrs_picto);
Picto prev_picto=PCBcontext.getPcbdb().getCurrentUser().has_categories() Picto prev_picto=/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories()
? find_picto(newPicto.get_category(), newPicto.get_row(),newPicto.get_column()) ? find_picto(newPicto.get_category(), newPicto.get_row(),newPicto.get_column())
: find_picto(newPicto.getFreeRow(),newPicto.getFreeColumn()); : find_picto(newPicto.getFreeRow(),newPicto.getFreeColumn());
...@@ -172,7 +173,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -172,7 +173,6 @@ public class Vocabulary implements Iterable<Picto> {
// and (ii) downloading // and (ii) downloading
if (!upload_pending) { if (!upload_pending) {
//final String picto_str = "/pictos";
final String picto_str = "/activeScene"; final String picto_str = "/activeScene";
String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str; String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str;
PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() { PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() {
...@@ -189,16 +189,12 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -189,16 +189,12 @@ public class Vocabulary implements Iterable<Picto> {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
if (result != null) { if (result != null) {
//Log.i("TAG_PRUEBAS",result.toString());
/* final String jpicto = "picto";
final String jid = "id";
final String juri = "uri";
final String jattributes = "attributes";*/
JSONObject picto, attributes; JSONObject picto, attributes;
JSONObject stupicto = null; JSONObject stupicto = null;
try { try {
PCBcontext.getPcbdb().getCurrentUser().set_has_categories(result.getBoolean("categories")); //PCBcontext.getPcbdb().getCurrentUser().set_has_categories(result.getBoolean("categories"));
setHas_categories(result.getBoolean("categories"));
setId_scene(result.getInt("id"));
JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los pictos JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los pictos
Picto[] pictos = new Picto[stu_pictos.length()]; Picto[] pictos = new Picto[stu_pictos.length()];
...@@ -212,13 +208,12 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -212,13 +208,12 @@ public class Vocabulary implements Iterable<Picto> {
attributes); attributes);
} }
synchronizeImgs(pictos); synchronizeImgs(pictos);
//HASTA AQUI BIEN
if (PCBcontext.is_user_logged()) { if (PCBcontext.is_user_logged()) {
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this); PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this);
PCBcontext.getPcbdb().setActiveSceneForStudent(result); //Aqui inserto en scene los datos que llegan de la activa PCBcontext.getPcbdb().setActiveSceneForStudent(result); //Aqui inserto en scene los datos que llegan de la activa
}else }else
Log.i(this.getClass().getName(), "Downloaded images ended when the user comes to logout"); Log.i(this.getClass().getName(), "Downloaded images ended when the user comes to logout");
Log.i(this.getClass().getName(), " Pictos downloaded: " + result.length()); Log.i(this.getClass().getName(), " Pictos downloaded: " + result.getJSONArray("pictos").length());
} catch (JSONException e) { } catch (JSONException e) {
StackTraceElement traces[] = e.getStackTrace(); StackTraceElement traces[] = e.getStackTrace();
for (StackTraceElement s : traces) for (StackTraceElement s : traces)
...@@ -231,10 +226,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -231,10 +226,6 @@ public class Vocabulary implements Iterable<Picto> {
} }
} }
/*@Override
public void result(JSONObject result) {
}*/
@Override @Override
public void error(RestapiWrapper.HTTPException e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage()); Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage());
...@@ -408,7 +399,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -408,7 +399,7 @@ public class Vocabulary implements Iterable<Picto> {
* @return list of pictos which should be selectable at the beginning of a sentence. Empty categories are removed * @return list of pictos which should be selectable at the beginning of a sentence. Empty categories are removed
*/ */
public LinkedList<Picto> startSentence(){ public LinkedList<Picto> startSentence(){
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories()) {
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<>();
...@@ -447,7 +438,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -447,7 +438,7 @@ public class Vocabulary implements Iterable<Picto> {
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y,String user_avatar, String path_sound,final iLocalPicto listener) { public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y,String user_avatar, String path_sound,final iLocalPicto listener) {
Picto prev_picto=PCBcontext.getPcbdb().getCurrentUser().has_categories() ? find_picto(cat, coord_x,coord_y) : find_picto(free_category_coord_x,free_category_coord_y); //¿estamos reemplazanddo un picto que ya existe? Picto prev_picto=/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories() ? find_picto(cat, coord_x,coord_y) : find_picto(free_category_coord_x,free_category_coord_y); //¿estamos reemplazanddo un picto que ya existe?
if (prev_picto!=null) { //El picto ya existe if (prev_picto!=null) { //El picto ya existe
removePicto(prev_picto.get_category(),prev_picto.get_id()); //borramos el picto local actual removePicto(prev_picto.get_category(),prev_picto.get_id()); //borramos el picto local actual
...@@ -516,4 +507,20 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -516,4 +507,20 @@ public class Vocabulary implements Iterable<Picto> {
return vocabulary; return vocabulary;
} }
public boolean isHas_categories() {
return has_categories;
}
public void setHas_categories(boolean has_categories) {
this.has_categories = has_categories;
}
public int getId_scene() {
return id_scene;
}
public void setId_scene(int id_scene) {
this.id_scene = id_scene;
}
} }
...@@ -151,7 +151,7 @@ public class PictoUploader { ...@@ -151,7 +151,7 @@ public class PictoUploader {
if (picto.get_user_avatar()!=null) json_attrs.put(Picto.JSON_ATTTRS.USER_AVATAR,picto.get_user_avatar()); if (picto.get_user_avatar()!=null) json_attrs.put(Picto.JSON_ATTTRS.USER_AVATAR,picto.get_user_avatar());
/*json_attrs.put("scene",picto.get_id_scene());*/ /*json_attrs.put("scene",picto.get_id_scene());*/
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories())
json_attrs.put(Picto.JSON_ATTTRS.CATEGORY, picto.get_category()) json_attrs.put(Picto.JSON_ATTTRS.CATEGORY, picto.get_category())
.put(Picto.JSON_ATTTRS.COLUMN, picto.get_column()) .put(Picto.JSON_ATTTRS.COLUMN, picto.get_column())
.put(Picto.JSON_ATTTRS.ROW, picto.get_row()); .put(Picto.JSON_ATTTRS.ROW, picto.get_row());
......
...@@ -77,7 +77,8 @@ public final class PCBcontext { ...@@ -77,7 +77,8 @@ public final class PCBcontext {
@Override @Override
public void change(User updatedStudent) { public void change(User updatedStudent) {
PCBcontext.getDevice().insertUser(updatedStudent); PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || updatedStudent.has_categories()!=getPcbdb().getCurrentUser().has_categories()) if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() /*|| updatedStudent.has_categories()!=getPcbdb().getCurrentUser().has_categories()*/
|| PCBcontext.getVocabulary().isHas_categories() != vocabulary.isHas_categories() || PCBcontext.getVocabulary().getId_scene()!= vocabulary.getId_scene())
PCBcontext.getNetService().restart_app(false); PCBcontext.getNetService().restart_app(false);
else { else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent); PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
......
...@@ -82,7 +82,7 @@ public class PictoMenu { ...@@ -82,7 +82,7 @@ public class PictoMenu {
public void addPicto(int row, int col, int cat, int source) { public void addPicto(int row, int col, int cat, int source) {
//Enviar al PictogramActivity los datos necesarios para crear el picto despues //Enviar al PictogramActivity los datos necesarios para crear el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories()) {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.CATEGORY, cat); activity.getIntent().putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row); activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col); activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
...@@ -108,7 +108,7 @@ public class PictoMenu { ...@@ -108,7 +108,7 @@ public class PictoMenu {
intent.putExtra(ID_PICTO_IMAGE,id_picto); intent.putExtra(ID_PICTO_IMAGE,id_picto);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues //Enviar al PictogramActivity los datos necesarios para editar el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories()) {
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat); intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
intent.putExtra(Picto.JSON_ATTTRS.ROW, row); intent.putExtra(Picto.JSON_ATTTRS.ROW, row);
intent.putExtra(Picto.JSON_ATTTRS.COLUMN, col); intent.putExtra(Picto.JSON_ATTTRS.COLUMN, col);
......
...@@ -562,7 +562,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -562,7 +562,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
Iterator<Picto> pictos=list.iterator(); Iterator<Picto> pictos=list.iterator();
while (pictos.hasNext()) { while (pictos.hasNext()) {
Picto p= pictos.next(); Picto p= pictos.next();
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*/PCBcontext.getVocabulary().isHas_categories()) {
if (p.get_column() != -1 && p.get_row() != -1 if (p.get_column() != -1 && p.get_row() != -1
&& p.get_column() < maxRows && p.get_row() < maxColumns) { && p.get_column() < maxRows && p.get_row() < maxColumns) {
mp[p.get_column()][p.get_row()] = p; mp[p.get_column()][p.get_row()] = p;
...@@ -905,7 +905,7 @@ Log.e(LOG_TAG,"AUDIO:"+(audioFile!=null)+":"+p.get_audioPath()); ...@@ -905,7 +905,7 @@ Log.e(LOG_TAG,"AUDIO:"+(audioFile!=null)+":"+p.get_audioPath());
Picto p = getCurrentPictoGridAdapter().getItem(position); Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p == null) { if (p == null) {
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria // No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria
if (getCurrentCategory() != null || !PCBcontext.getPcbdb().getCurrentUser().has_categories()) { if (getCurrentCategory() != null || /*!PCBcontext.getPcbdb().getCurrentUser().has_categories()*/!PCBcontext.getVocabulary().isHas_categories()) {
int cat = getCurrentCategory() != null ? currentCategory.get_id() : Picto.NO_CATEGORY; int cat = getCurrentCategory() != null ? currentCategory.get_id() : Picto.NO_CATEGORY;
new PictoMenu(PictogramActivity.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), cat); new PictoMenu(PictogramActivity.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), cat);
} else } else
......
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