Commit 4b8c29d7 by german

Arreglado bug por el cual no aparecian todos los supervisores asociados a un…

Arreglado bug por el cual no aparecian todos los supervisores asociados a un niño en el tablet (Solucion añadir el id de stu tambien a la busqueda para ver si esta en local)
parent 59530c7e
......@@ -192,9 +192,9 @@ public class Device extends SQLiteOpenHelper {
* @return
* @throws JSONException
*/
public Boolean isSupervisorOnLocal(int id_sup) throws JSONException{
public Boolean isSupervisorOnLocal(int id_sup,int id_stu) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(" SELECT * FROM supervisor WHERE id = " + id_sup, null);
Cursor cursor = db.rawQuery(" SELECT * FROM users_detail WHERE id_stu = " + id_stu+ " AND id_sup ="+id_sup, null);
if(cursor.moveToFirst())
return true;
cursor.close();
......@@ -212,8 +212,10 @@ public class Device extends SQLiteOpenHelper {
SQLiteDatabase db = this.getReadableDatabase();
Hashtable<String, String> users = new Hashtable<>(3);
Cursor cursor = db.rawQuery(" SELECT email_sup, name_sup, surname_sup,id_sup FROM users_detail WHERE id_stu = "+id_stu ,null);
while (cursor.moveToNext())
users.put(cursor.getString(0), cursor.getString(1)+", "+cursor.getString(2)+";"+cursor.getInt(3));
while (cursor.moveToNext()) {
users.put(cursor.getString(0), cursor.getString(1) + ", " + cursor.getString(2) + ";" + cursor.getInt(3));
Log.i(LOG_TAG,"Supervisor recuperado: "+cursor.getString(1));
}
cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users;
......
......@@ -243,13 +243,14 @@ public class StudentFragmentGrid extends Fragment{
try {
supervisor = supervisors.getJSONObject(i);
idSupervisoresJSON.add(supervisor.getString("email"));
if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"))) {//Para comprobar si ya existe en local
if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"),stu_id)) {//Para comprobar si ya existe en local
User currentUser = PCBcontext.getPcbdb().getCurrentUser();
PCBcontext.getDevice().insertUser(new User(stu_id, currentUser.get_nickname_stu(), currentUser.get_pwd_stu()
, currentUser.get_name_stu(),currentUser.get_surname_stu(),currentUser.get_active_scene(), currentUser.get_url_img_stu()
, currentUser.get_gender_stu(), currentUser.get_lang_stu(), currentUser.get_json_attrs(),
(int) supervisor.get("id"), supervisor.get("email").toString(), "_", supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(),
supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString()));
Log.i(LOG_TAG,"Supervisor: "+supervisor.getString("name")+" insertado");
}
} catch (JSONException e) {
e.printStackTrace();
......
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