Cambios varios

parent fee15f4f
...@@ -51,7 +51,7 @@ public abstract class Action { ...@@ -51,7 +51,7 @@ public abstract class Action {
Log.d("TIMESTAMP-----------> ", datetime.format(currentTime)); Log.d("TIMESTAMP-----------> ", datetime.format(currentTime));
if (PCBcontext.getPcbdb().getCurrentUser().has_supervisor()) { if (PCBcontext.getPcbdb().getCurrentUser().has_supervisor()) {
jsonObject.put(param_id_sup, PCBcontext.getPcbdb().getCurrentUser().get_id_sup()); jsonObject.put(param_id_sup, PCBcontext.getPcbdb().getCurrentUser().get_id_sup());
jsonObject.put(param_id_scene, PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); jsonObject.put(param_id_scene, PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); //TODO: Esto coge -1
} }
//TODO Decidir qué almacenar con DEVICE //TODO Decidir qué almacenar con DEVICE
//if (PCBcontext.getDevice().getDeviceID()!=null) //if (PCBcontext.getDevice().getDeviceID()!=null)
......
...@@ -11,6 +11,7 @@ import android.util.Log; ...@@ -11,6 +11,7 @@ import android.util.Log;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONException; import org.json.JSONException;
......
...@@ -203,7 +203,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -203,7 +203,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException { public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException {
int id_stu = this.getCurrentUser().get_id_stu(); int id_stu = this.getCurrentUser().get_id_stu();
int id_scene = this.getCurrentUser().get_active_scene(); int id_scene = this.getCurrentUser().get_active_scene();
Log.i(LOG_TAG,"Active Scene: "+id_scene+" id_Stu: "+id_stu);
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * FROM collection_detail WHERE id_stu = "+id_stu+" AND id_scene = "+id_scene,null); Cursor cursor = db.rawQuery("SELECT * FROM collection_detail WHERE id_stu = "+id_stu+" AND id_scene = "+id_scene,null);
......
...@@ -258,12 +258,12 @@ public class User { ...@@ -258,12 +258,12 @@ public class User {
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return 134; return -1;
//return -1;
} }
public void set_active_scene(int id) { public void set_active_scene(int id) {
try { try {
this.id_scene_stu = id;
this.attributes_stu.put(JSON_STUDENT_ATTTRS.ID_ACTIVE_SCENE,id); this.attributes_stu.put(JSON_STUDENT_ATTTRS.ID_ACTIVE_SCENE,id);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -182,7 +182,7 @@ public class UserLogin { ...@@ -182,7 +182,7 @@ public class UserLogin {
JSONObject user = result.getJSONObject(TAG_USER); JSONObject user = result.getJSONObject(TAG_USER);
Log.i(LOG_TAG,user.toString()); Log.i(LOG_TAG,user.toString());
int st_id_int = user.getInt(TAG_ID); int st_id_int = user.getInt(TAG_ID);
//int st_id_scene = user.getInt(TAG_ID_SCENE); int st_id_scene = user.getInt(TAG_ID_SCENE);
String st_name = user.getString(TAG_NAME); String st_name = user.getString(TAG_NAME);
String st_surname = user.getString(TAG_SURNAME); String st_surname = user.getString(TAG_SURNAME);
String st_pic = user.getString(TAG_PIC); String st_pic = user.getString(TAG_PIC);
...@@ -195,7 +195,7 @@ public class UserLogin { ...@@ -195,7 +195,7 @@ public class UserLogin {
password, password,
st_name, st_name,
st_surname, st_surname,
134/*st_id_scene*/, st_id_scene,
st_pic, st_pic,
st_gender, st_gender,
st_lang, st_lang,
......
...@@ -164,7 +164,6 @@ public class PictoUploader { ...@@ -164,7 +164,6 @@ public class PictoUploader {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG, " Error: " + e.getLocalizedMessage()); Log.e(LOG_TAG, " Error: " + e.getLocalizedMessage());
} }
Log.i(LOG_TAG,"Uploading attributes ");
PictoUploader.this.picto.set_local_status(false); PictoUploader.this.picto.set_local_status(false);
PCBcontext.getRestapiWrapper().ask(PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto/"+id_picto, params, "post", true, new RestapiWrapper.iRestapiListener() { PCBcontext.getRestapiWrapper().ask(PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto/"+id_picto, params, "post", true, new RestapiWrapper.iRestapiListener() {
@Override @Override
......
...@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener { ...@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener {
String username=msg.getString("username"); String username=msg.getString("username");
String name=msg.getString("name"); String name=msg.getString("name");
String surname=msg.getString("surname"); String surname=msg.getString("surname");
//int id_active_scene = msg.getInt("id_active_scene");
String gender=msg.getString("gender"); String gender=msg.getString("gender");
String pic=msg.getString("pic"); String pic=msg.getString("pic");
String lang=msg.getString("lang"); String lang=msg.getString("lang");
String attributes=msg.getString("attributes"); String attributes=msg.getString("attributes");
User user=PCBcontext.getPcbdb().getCurrentUser(); User user=PCBcontext.getPcbdb().getCurrentUser();
//TODO: Obtener el id de la scene del JSONObject en lugar de poner 134 User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname,user.get_active_scene(), pic, gender, lang, attributes,
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname,134, pic, gender, lang, attributes,
user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(), user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(),
user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office()); user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length); Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
......
...@@ -53,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -53,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener {
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto); JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto);
int picto_id = picto_stupicto.getInt(param_picto_id); int picto_id = picto_stupicto.getInt(param_picto_id);
int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0; int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
/*TODO: if(PCBcontext.getVocabulary().getId_scene() == msg.get("id_scene")) {*/ if(PCBcontext.getVocabulary().getId_scene() == msg.getJSONObject("attributes").getInt("id_scene")) {
PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets
Log.i(LOG_TAG, "Received message '" + action + Log.i(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto); "' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto);
...@@ -63,7 +63,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -63,7 +63,7 @@ public class VocabularyTalk implements Emitter.Listener {
: action.equals(action_add) ? iVocabularyListener.action.add : action.equals(action_add) ? iVocabularyListener.action.add
: iVocabularyListener.action.delete : iVocabularyListener.action.delete
, picto_cat, picto_id, stu_picto); , picto_cat, picto_id, stu_picto);
//} }
} catch (JSONException e) { } catch (JSONException e) {
Log.e(LOG_TAG, e.getClass().getCanonicalName() + "--" + e); Log.e(LOG_TAG, e.getClass().getCanonicalName() + "--" + e);
} }
......
...@@ -77,10 +77,13 @@ public final class PCBcontext { ...@@ -77,10 +77,13 @@ public final class PCBcontext {
@Override @Override
public void change(User updatedStudent) { public void change(User updatedStudent) {
PCBcontext.getDevice().insertUser(updatedStudent); PCBcontext.getDevice().insertUser(updatedStudent);
Log.i("TAG_PRUEBAS","ID_SCENE_VOCAB: "+PCBcontext.getVocabulary().getId_scene()+
"ID_SCENE_USER: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories() if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories()
|| PCBcontext.getVocabulary().getId_scene()!= PCBcontext.getPcbdb().getCurrentUser().get_active_scene()) /*|| PCBcontext.getVocabulary().getId_scene()!= PCBcontext.getPcbdb().getCurrentUser().get_active_scene()*/) {
PCBcontext.getNetService().restart_app(false); PCBcontext.getNetService().restart_app(false);
else {
}else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent); PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent); PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
} }
......
...@@ -93,15 +93,18 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -93,15 +93,18 @@ public class StudentFragmentGrid extends Fragment{
private void new_user(int i) { private void new_user(int i) {
JSONObject st = this.downloaded_students.get(i); JSONObject st = this.downloaded_students.get(i);
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
try { try {
Log.i(LOG_TAG,st.toString());
PCBcontext.getPcbdb();
User new_user = new User( User new_user = new User(
st.getInt(TAG_ID), st.getInt(TAG_ID),
st.getString(TAG_USERNAME), st.getString(TAG_USERNAME),
null, null,
st.getString(TAG_NAME), st.getString(TAG_NAME),
st.getString(TAG_SURNAME), st.getString(TAG_SURNAME),
105/*st.getInt(TAG_ID_SCENE)*/, st.getInt(TAG_ID_SCENE),
st.getString(TAG_PIC), st.getString(TAG_PIC),
st.getString(TAG_GENDER), st.getString(TAG_GENDER),
st.getString(TAG_LANG), st.getString(TAG_LANG),
......
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