bug #559 fixed

parent 34865a02
...@@ -58,3 +58,5 @@ src/main/resources/ ...@@ -58,3 +58,5 @@ src/main/resources/
gen/ gen/
/Pictogram.iml
/.gitignore
...@@ -43,14 +43,12 @@ public class UserLogin { ...@@ -43,14 +43,12 @@ public class UserLogin {
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName() private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
public static final String PREFS_NAME = "MyPrefsFile";
private void manageSupervisorLogin(final String email, final String password, boolean online, private void manageSupervisorLogin(final String email, final String password, boolean online,
final Activity activity, final Class PictogramActivity, final Class LoginActivity) { final Activity activity, final Class PictogramActivity, final Class LoginActivity) {
if (online) { if (online) {
Log.i(this.getClass().getCanonicalName(), "Online login request for supervisor "+email); Log.i(LOG_TAG, "Online login request for supervisor "+email);
final ProgressDialog progressDialog = ProgressDialog.show(activity, activity.getBaseContext().getString(R.string.userLoadingTxt), final ProgressDialog progressDialog = ProgressDialog.show(activity, activity.getBaseContext().getString(R.string.userLoadingTxt),
activity.getBaseContext().getString(R.string.userLoadingTxt), false, false); activity.getBaseContext().getString(R.string.userLoadingTxt), false, false);
ServerLogin.login_supervisor(email, password, new iRestapiListener() { ServerLogin.login_supervisor(email, password, new iRestapiListener() {
...@@ -66,7 +64,7 @@ public class UserLogin { ...@@ -66,7 +64,7 @@ public class UserLogin {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
String jsonToken; String jsonToken;
JSONObject user; JSONObject user;
try { try {
...@@ -103,7 +101,7 @@ public class UserLogin { ...@@ -103,7 +101,7 @@ public class UserLogin {
@Override @Override
public void error(Exception e) { public void error(Exception e) {
Log.i(this.getClass().getCanonicalName(),"Login fail:"+e.getMessage()+" ("+e.getClass().getCanonicalName()+")"); Log.i(this.getClass().getCanonicalName(),"Login fail:"+e.getMessage()+" ("+e.getClass().getCanonicalName()+")");
progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
if (e instanceof LoginException) if (e instanceof LoginException)
if (((LoginException)e).login_failed()) if (((LoginException)e).login_failed())
GUITools.show_alert(activity, R.string.loginErrorMsg); GUITools.show_alert(activity, R.string.loginErrorMsg);
...@@ -169,7 +167,7 @@ public class UserLogin { ...@@ -169,7 +167,7 @@ public class UserLogin {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
try { try {
JSONObject user = result.getJSONObject(TAG_USER); JSONObject user = result.getJSONObject(TAG_USER);
...@@ -196,13 +194,13 @@ public class UserLogin { ...@@ -196,13 +194,13 @@ public class UserLogin {
} catch (JSONException e) { } catch (JSONException e) {
GUITools.show_alert(activity, R.string.serverError, e.getMessage()); GUITools.show_alert(activity, R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "JSON:"+ e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), "JSON:"+ e.getLocalizedMessage());
progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
} }
} }
@Override @Override
public void error(Exception e) { public void error(Exception e) {
progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
if (e instanceof LoginException) if (e instanceof LoginException)
if (((LoginException)e).login_failed()) if (((LoginException)e).login_failed())
GUITools.show_alert(activity, R.string.loginErrorMsg); GUITools.show_alert(activity, R.string.loginErrorMsg);
...@@ -235,7 +233,7 @@ public class UserLogin { ...@@ -235,7 +233,7 @@ public class UserLogin {
@Override @Override
public void loadComplete() { public void loadComplete() {
PCBcontext.getDevice().insertUser(student); PCBcontext.getDevice().insertUser(student);
progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
activity.startActivity(pictogramActivity); activity.startActivity(pictogramActivity);
} }
...@@ -245,7 +243,7 @@ public class UserLogin { ...@@ -245,7 +243,7 @@ public class UserLogin {
@Override @Override
public void error(Exception e) { public void error(Exception e) {
progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
GUITools.show_alert(activity, R.string.serverError, e.getMessage()); GUITools.show_alert(activity, R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage());
} }
......
...@@ -174,7 +174,7 @@ public final class PCBcontext { ...@@ -174,7 +174,7 @@ public final class PCBcontext {
public static Vocabulary getVocabulary(){ public static Vocabulary getVocabulary(){
if (vocabulary == null) { if (vocabulary == null) {
throw new java.lang.NullPointerException("Vocabulary is null. PCBcontext.set_user" + throw new java.lang.NullPointerException("Vocabulary is null. PCBcontext.set_user" +
"must be invoked previously"); " must be invoked previously");
} }
return vocabulary; return vocabulary;
} }
...@@ -186,7 +186,7 @@ public final class PCBcontext { ...@@ -186,7 +186,7 @@ public final class PCBcontext {
public static ActionLog getActionLog(){ public static ActionLog getActionLog(){
if (actionLog == null) { if (actionLog == null) {
throw new java.lang.NullPointerException("ActionLog is null. PCBcontext.set_user" + throw new java.lang.NullPointerException("ActionLog is null. PCBcontext.set_user" +
"must be invoked previously"); " must be invoked previously");
} }
return actionLog; return actionLog;
} }
......
...@@ -28,7 +28,7 @@ android { ...@@ -28,7 +28,7 @@ android {
resValue "string", "server", "https://dev.yottacode.com" resValue "string", "server", "https://dev.yottacode.com"
} }
DefaultFlavor { DefaultFlavor {
resValue "string", "server", "https://dev.yottacode.com" resValue "string", "server", "https://ci.yottacode.com"
} }
} }
} }
......
...@@ -97,9 +97,10 @@ public class LoginActivity extends FragmentActivity { ...@@ -97,9 +97,10 @@ public class LoginActivity extends FragmentActivity {
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs); downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
} }
@Override @Override
protected void onResume() { protected void onStop() {
super.onResume(); super.onStop();
Log.i(LOG_TAG,"Closing app");
} PCBcontext.getNetService().closeNotifyStatus();
}
} }
...@@ -36,6 +36,7 @@ public class MainActivity extends Activity { ...@@ -36,6 +36,7 @@ public class MainActivity extends Activity {
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
Log.i(LOG_TAG,"Closing app");
PCBcontext.getNetService().closeNotifyStatus(); PCBcontext.getNetService().closeNotifyStatus();
} }
......
...@@ -100,6 +100,11 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -100,6 +100,11 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout); this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout);
this.currentCategory = null; this.currentCategory = null;
this.count_deletelong = 0; this.count_deletelong = 0;
if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG,"No user logged. Restarting app");
PCBcontext.getNetService().restart_app();
return;
}
this.vocabulary = PCBcontext.getVocabulary(); this.vocabulary = PCBcontext.getVocabulary();
this.vocabulary.listen(PCBcontext.getRoom(), this); this.vocabulary.listen(PCBcontext.getRoom(), this);
...@@ -183,7 +188,12 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -183,7 +188,12 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
tts.setLanguage(Locale.getDefault()); tts.setLanguage(Locale.getDefault());
} }
} }
@Override
protected void onStop() {
super.onStop();
Log.i(LOG_TAG,"Closing app");
PCBcontext.getNetService().closeNotifyStatus();
}
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
......
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