issue #313 closed

parent 1649886a
......@@ -2,6 +2,7 @@ package com.yottacode.pictogram.dao;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;
import com.yottacode.pictogram.tools.Img;
......@@ -247,6 +248,7 @@ public class User {
}
}
/**
* @return The id of the active scene of this student
*/
......
......@@ -31,7 +31,7 @@ public class StudentTalk implements Emitter.Listener {
if (PCBcontext.getPcbdb()!=null)
try {
JSONObject msg = ((JSONObject) args[0]).getJSONObject("student");
Log.i(this.getClass().getName(), "raw Received message " +msg.toString());
Log.d(this.getClass().getName(), "raw Received message " +msg.toString());
int id=msg.getInt("id");
String username=msg.getString("username");
String name=msg.getString("name");
......@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener {
String pic=msg.getString("pic");
String lang=msg.getString("lang");
String attributes=msg.getString("attributes");
JSONObject license=msg.getJSONObject("license");
User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, id_active_scene, 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_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
for (iStudentListener listener: listeners)
listener.change(updatedUser);
listener.change(updatedUser,license);
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e);
......@@ -61,6 +61,6 @@ public class StudentTalk implements Emitter.Listener {
* @version 1.0
*/
public interface iStudentListener {
void change(User updatedStudent);
void change(User updatedStudent, JSONObject license);
}
}
package com.yottacode.pictogram.tools;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import com.yottacode.net.RestapiWrapper;
......@@ -17,6 +19,9 @@ import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.net.websockets.Room;
import com.yottacode.pictogram.net.websockets.StudentTalk;
import org.json.JSONException;
import org.json.JSONObject;
public final class PCBcontext {
private static Context context;
private static PCBDBHelper pcbdb;
......@@ -75,16 +80,33 @@ public final class PCBcontext {
studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
@Override
public void change(User updatedStudent) {
PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories()
|| updatedStudent.get_active_scene() != PCBcontext.getPcbdb().getCurrentUser().get_active_scene()){
public void change(User updatedStudent, JSONObject license) {
try {
if (!license.getBoolean("isValid")) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(activityContext);
builder1.setMessage(R.string.loginNoLicenseMsg);
builder1.setPositiveButton(
R.string.accept,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
PCBcontext.getNetService().restart_app(false);
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
return;
}
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(),"No license attr! "+license.toString());
}
PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories()
|| updatedStudent.get_active_scene() != PCBcontext.getPcbdb().getCurrentUser().get_active_scene())
PCBcontext.getNetService().restart_app(false);
}else {
else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
}
......
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