Modificaciones para el modo OFFLINE

parent afbb66b9
......@@ -114,8 +114,8 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
if (!RestapiWrapper.ping(getResources().getString(R.string.server),"server/ping",this)) {
// MODO OFFLINE
try {
Log.d(LOG_TAG, "username guardado:" + username);
Log.d(LOG_TAG, "password guardado:" + password);
Log.d(LOG_TAG, "username utilizado:" + username);
Log.d(LOG_TAG, "password utilizado:" + password);
Vector<User> localUsers = PCBcontext.getDevice().findUser(username, password);
// Si sólo hay 1 estudiante, cargo el st_id
......@@ -155,6 +155,10 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Vuelvo al serial para que se identifique
Intent serialActivity = new Intent(LoginActivity.this, SerialActivity.class);
serialActivity.putExtra("activity_name","SerialActivity");
startActivity(serialActivity);
}
});
} else if (e.no_students()){
......@@ -163,6 +167,10 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Vuelvo al serial para que se identifique
Intent serialActivity = new Intent(LoginActivity.this, SerialActivity.class);
serialActivity.putExtra("activity_name","SerialActivity");
startActivity(serialActivity);
}
});
} else{
......@@ -171,9 +179,15 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Vuelvo al serial para que se identifique
Intent serialActivity = new Intent(LoginActivity.this, SerialActivity.class);
serialActivity.putExtra("activity_name","SerialActivity");
startActivity(serialActivity);
}
});
}
AlertDialog alert = builder.create();
alert.show();
e.printStackTrace();
}
} else{
......@@ -247,6 +261,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
// Añado un par <student-supervisor>
int st_id_int = st_id.intValue();
int st_supervision_int = st_supervision.intValue();
// Si es terapeuta lo añado directamente
if (st_supervision_int==2){
student = new User(st_id_int,"nickname_stu","pwd_stu", st_name, st_surname, st_pic, st_gender, st_lang, st_attributes,
sup_id, username, password,"", "", "", "M", "es-es", "");
......@@ -260,7 +275,6 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
if (users.size() == 1){
//User student = PCBcontext.getDevice().findUser(st_id_int, sup_id);
PCBcontext.set_user(student, token, null); // no hay que hacer nada cuando termine
} else{
student = new User(-1, "nickname_stu","pwd_stu","", "", "", "M", "es-es", "",
sup_id, username, password,"", "", "", "M", "es-es", "");
......@@ -285,13 +299,13 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
if (users.size() > 0){
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String currentDateandTime = sdf.format(new Date());
Log.d(LOG_TAG, "Entro en synchronizeUsers en " + currentDateandTime);
//Log.d(LOG_TAG, "Entro en synchronizeUsers en " + currentDateandTime);
PCBcontext.getDevice().synchronizeUsers(users, new iImgDownloaderListener() {
@Override
public void loadComplete() {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
String currentDateandTime = sdf.format(new Date());
Log.d(LOG_TAG, "LoadComplete en " + currentDateandTime);
//Log.d(LOG_TAG, "LoadComplete en " + currentDateandTime);
Vector<User> users = null;
try {
users = PCBcontext.getDevice().getUsers();
......
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