bug #559 fixed

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