NoCurrentQuestion thrown at a wrong moment, tiny bug fixes

This commit is contained in:
Caesar2011
2017-04-29 15:11:43 +02:00
parent a00b1f6412
commit ef00bc0657
4 changed files with 49 additions and 3 deletions

View File

@@ -1,6 +1,14 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
signingConfigs {
config {
keyAlias 'PostGrachelor'
keyPassword '9ApoTheke'
storeFile file('D:/nextcloud/Documents/Konfigurationen/JavaKeystore/android.jks')
storePassword '9ApoTheke'
}
}
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion "25.0.2" buildToolsVersion "25.0.2"
defaultConfig { defaultConfig {
@@ -15,12 +23,16 @@ android {
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
} }
} }
} }
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })

View File

@@ -82,6 +82,7 @@ public class LoginFragment extends Fragment {
login_btn.setText(login_btn.getResources().getString(R.string.register_btn)); login_btn.setText(login_btn.getResources().getString(R.string.register_btn));
} }
}); });
login_edit.setText("");
return layout; return layout;
} }

View File

@@ -340,7 +340,7 @@ public class GameService {
throw new IllegalStateException(); throw new IllegalStateException();
if (!LoginService.isLoggedIn()) if (!LoginService.isLoggedIn())
throw new NotLoggedInException(); throw new NotLoggedInException();
if (GameService.getQuestion()==null || GameService.getAnswer()==-1) { if (GameService.getQuestion()==null) {
throw new NoCurrentQuestionException(); throw new NoCurrentQuestionException();
} }
@@ -348,6 +348,9 @@ public class GameService {
GameService.setAnswer(id); GameService.setAnswer(id);
GameService.setState(StoredStates.ON_HOLD_LOADING); GameService.setState(StoredStates.ON_HOLD_LOADING);
if (GameService.getAnswer()==-1)
throw new NoCurrentQuestionException();
final String currentToken = GameService.getQuestion().getToken(); final String currentToken = GameService.getQuestion().getToken();
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();

View File

@@ -21,12 +21,13 @@ import de.hwr_berlin.it14.postgrachelor.Utils.JsonRequestPG;
public class LoginService { public class LoginService {
private static final String PREFS_NAME = "PrefsLogin"; private static final String PREFS_NAME = "PrefsLogin";
private static final String NAME = "SERVICE_GAME"; private static final String NAME = "SERVICE_LOGIN";
private static boolean instantiated = false; private static boolean instantiated = false;
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
private static Activity activity = null; private static Activity activity = null;
private static StoredLogin login = null; private static StoredLogin login = null;
private static final HashMap<String, OnLoginEventListener> loginEventListeners = new HashMap<>(); private static final HashMap<String, OnLoginEventListener> loginEventListeners = new HashMap<>();
private static long lastStateChange = 0;
public interface OnLoginEventListener { public interface OnLoginEventListener {
void onLoginEvent(Login login); void onLoginEvent(Login login);
@@ -93,11 +94,17 @@ public class LoginService {
if (!instantiated) if (!instantiated)
throw new NotInitializedException(); throw new NotInitializedException();
LoginService.lastStateChange = System.currentTimeMillis();
final long time = LoginService.lastStateChange;
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("name", name); params.put("name", name);
JsonRequestPG requester = new JsonRequestPG("register.php", params, activity, new JsonRequestPG.AsyncResponse() { JsonRequestPG requester = new JsonRequestPG("register.php", params, activity, new JsonRequestPG.AsyncResponse() {
@Override @Override
public void processFinish(JSONObject output) { public void processFinish(JSONObject output) {
if (time != LoginService.lastStateChange)
return;
Log.d(NAME, "output"); Log.d(NAME, "output");
Log.d(NAME, output.toString()); Log.d(NAME, output.toString());
@@ -110,6 +117,9 @@ public class LoginService {
@Override @Override
public void processError(int status, String message) { public void processError(int status, String message) {
if (time != LoginService.lastStateChange)
return;
Log.d(NAME, "error"); Log.d(NAME, "error");
Log.d(NAME, "status: "+status+" - message: "+message); Log.d(NAME, "status: "+status+" - message: "+message);
// never reached if not instantiated // never reached if not instantiated
@@ -123,11 +133,17 @@ public class LoginService {
if (!instantiated) if (!instantiated)
throw new NotInitializedException(); throw new NotInitializedException();
LoginService.lastStateChange = System.currentTimeMillis();
final long time = LoginService.lastStateChange;
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("uid", uid); params.put("uid", uid);
JsonRequestPG requester = new JsonRequestPG("login.php", params, activity, new JsonRequestPG.AsyncResponse() { JsonRequestPG requester = new JsonRequestPG("login.php", params, activity, new JsonRequestPG.AsyncResponse() {
@Override @Override
public void processFinish(JSONObject output) { public void processFinish(JSONObject output) {
if (time != LoginService.lastStateChange)
return;
Log.d(NAME, "output"); Log.d(NAME, "output");
Log.d(NAME, output.toString()); Log.d(NAME, output.toString());
@@ -140,6 +156,9 @@ public class LoginService {
@Override @Override
public void processError(int status, String message) { public void processError(int status, String message) {
if (time != LoginService.lastStateChange)
return;
Log.d(NAME, "error"); Log.d(NAME, "error");
Log.d(NAME, "status: "+status+" - message: "+message); Log.d(NAME, "status: "+status+" - message: "+message);
} }
@@ -152,6 +171,8 @@ public class LoginService {
throw new NotInitializedException(); throw new NotInitializedException();
} }
LoginService.lastStateChange = System.currentTimeMillis();
GameService.endGame(); GameService.endGame();
GameService.endGame(); GameService.endGame();
LoginService.setLogout(status, message); LoginService.setLogout(status, message);
@@ -161,12 +182,18 @@ public class LoginService {
if (!instantiated) if (!instantiated)
throw new NotInitializedException(); throw new NotInitializedException();
LoginService.lastStateChange = System.currentTimeMillis();
final long time = LoginService.lastStateChange;
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("name", name); params.put("name", name);
params.put("uid", LoginService.getLogin().getUID()); params.put("uid", LoginService.getLogin().getUID());
JsonRequestPG requester = new JsonRequestPG("rename.php", params, activity, new JsonRequestPG.AsyncResponse() { JsonRequestPG requester = new JsonRequestPG("rename.php", params, activity, new JsonRequestPG.AsyncResponse() {
@Override @Override
public void processFinish(JSONObject output) { public void processFinish(JSONObject output) {
if (time != LoginService.lastStateChange)
return;
Log.d(NAME, "output"); Log.d(NAME, "output");
Log.d(NAME, output.toString()); Log.d(NAME, output.toString());
@@ -179,6 +206,9 @@ public class LoginService {
@Override @Override
public void processError(int status, String message) { public void processError(int status, String message) {
if (time != LoginService.lastStateChange)
return;
Log.d(NAME, "error"); Log.d(NAME, "error");
Log.d(NAME, "status: "+status+" - message: "+message); Log.d(NAME, "status: "+status+" - message: "+message);
// never reached if not instantiated // never reached if not instantiated