NoCurrentQuestion thrown at a wrong moment, tiny bug fixes
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
signingConfigs {
|
||||
config {
|
||||
keyAlias 'PostGrachelor'
|
||||
keyPassword '9ApoTheke'
|
||||
storeFile file('D:/nextcloud/Documents/Konfigurationen/JavaKeystore/android.jks')
|
||||
storePassword '9ApoTheke'
|
||||
}
|
||||
}
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion "25.0.2"
|
||||
defaultConfig {
|
||||
@@ -15,12 +23,16 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.config
|
||||
}
|
||||
debug {
|
||||
signingConfig signingConfigs.config
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
|
||||
@@ -82,6 +82,7 @@ public class LoginFragment extends Fragment {
|
||||
login_btn.setText(login_btn.getResources().getString(R.string.register_btn));
|
||||
}
|
||||
});
|
||||
login_edit.setText("");
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ public class GameService {
|
||||
throw new IllegalStateException();
|
||||
if (!LoginService.isLoggedIn())
|
||||
throw new NotLoggedInException();
|
||||
if (GameService.getQuestion()==null || GameService.getAnswer()==-1) {
|
||||
if (GameService.getQuestion()==null) {
|
||||
throw new NoCurrentQuestionException();
|
||||
}
|
||||
|
||||
@@ -348,6 +348,9 @@ public class GameService {
|
||||
GameService.setAnswer(id);
|
||||
GameService.setState(StoredStates.ON_HOLD_LOADING);
|
||||
|
||||
if (GameService.getAnswer()==-1)
|
||||
throw new NoCurrentQuestionException();
|
||||
|
||||
final String currentToken = GameService.getQuestion().getToken();
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
|
||||
@@ -21,12 +21,13 @@ import de.hwr_berlin.it14.postgrachelor.Utils.JsonRequestPG;
|
||||
|
||||
public class LoginService {
|
||||
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;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Activity activity = null;
|
||||
private static StoredLogin login = null;
|
||||
private static final HashMap<String, OnLoginEventListener> loginEventListeners = new HashMap<>();
|
||||
private static long lastStateChange = 0;
|
||||
|
||||
public interface OnLoginEventListener {
|
||||
void onLoginEvent(Login login);
|
||||
@@ -93,11 +94,17 @@ public class LoginService {
|
||||
if (!instantiated)
|
||||
throw new NotInitializedException();
|
||||
|
||||
LoginService.lastStateChange = System.currentTimeMillis();
|
||||
final long time = LoginService.lastStateChange;
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
JsonRequestPG requester = new JsonRequestPG("register.php", params, activity, new JsonRequestPG.AsyncResponse() {
|
||||
@Override
|
||||
public void processFinish(JSONObject output) {
|
||||
if (time != LoginService.lastStateChange)
|
||||
return;
|
||||
|
||||
Log.d(NAME, "output");
|
||||
Log.d(NAME, output.toString());
|
||||
|
||||
@@ -110,6 +117,9 @@ public class LoginService {
|
||||
|
||||
@Override
|
||||
public void processError(int status, String message) {
|
||||
if (time != LoginService.lastStateChange)
|
||||
return;
|
||||
|
||||
Log.d(NAME, "error");
|
||||
Log.d(NAME, "status: "+status+" - message: "+message);
|
||||
// never reached if not instantiated
|
||||
@@ -123,11 +133,17 @@ public class LoginService {
|
||||
if (!instantiated)
|
||||
throw new NotInitializedException();
|
||||
|
||||
LoginService.lastStateChange = System.currentTimeMillis();
|
||||
final long time = LoginService.lastStateChange;
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("uid", uid);
|
||||
JsonRequestPG requester = new JsonRequestPG("login.php", params, activity, new JsonRequestPG.AsyncResponse() {
|
||||
@Override
|
||||
public void processFinish(JSONObject output) {
|
||||
if (time != LoginService.lastStateChange)
|
||||
return;
|
||||
|
||||
Log.d(NAME, "output");
|
||||
Log.d(NAME, output.toString());
|
||||
|
||||
@@ -140,6 +156,9 @@ public class LoginService {
|
||||
|
||||
@Override
|
||||
public void processError(int status, String message) {
|
||||
if (time != LoginService.lastStateChange)
|
||||
return;
|
||||
|
||||
Log.d(NAME, "error");
|
||||
Log.d(NAME, "status: "+status+" - message: "+message);
|
||||
}
|
||||
@@ -152,6 +171,8 @@ public class LoginService {
|
||||
throw new NotInitializedException();
|
||||
}
|
||||
|
||||
LoginService.lastStateChange = System.currentTimeMillis();
|
||||
|
||||
GameService.endGame();
|
||||
GameService.endGame();
|
||||
LoginService.setLogout(status, message);
|
||||
@@ -161,12 +182,18 @@ public class LoginService {
|
||||
if (!instantiated)
|
||||
throw new NotInitializedException();
|
||||
|
||||
LoginService.lastStateChange = System.currentTimeMillis();
|
||||
final long time = LoginService.lastStateChange;
|
||||
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
params.put("uid", LoginService.getLogin().getUID());
|
||||
JsonRequestPG requester = new JsonRequestPG("rename.php", params, activity, new JsonRequestPG.AsyncResponse() {
|
||||
@Override
|
||||
public void processFinish(JSONObject output) {
|
||||
if (time != LoginService.lastStateChange)
|
||||
return;
|
||||
|
||||
Log.d(NAME, "output");
|
||||
Log.d(NAME, output.toString());
|
||||
|
||||
@@ -179,6 +206,9 @@ public class LoginService {
|
||||
|
||||
@Override
|
||||
public void processError(int status, String message) {
|
||||
if (time != LoginService.lastStateChange)
|
||||
return;
|
||||
|
||||
Log.d(NAME, "error");
|
||||
Log.d(NAME, "status: "+status+" - message: "+message);
|
||||
// never reached if not instantiated
|
||||
|
||||
Reference in New Issue
Block a user