From 842b7be3a3a1f829e6f0f9a949b17ce2573f6e5f Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Thu, 11 Apr 2019 14:02:18 -0300 Subject: [PATCH] reset database immediately when the new account is stored (otherwise this might lead to inconsistency) --- .../owncloudnewsreader/LoginDialogActivity.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java index 9a81a5a4..42ea0d83 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/LoginDialogActivity.java @@ -252,6 +252,8 @@ public class LoginDialogActivity extends AppCompatActivity { editor.putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, true); editor.commit(); + resetDatabase(); + SingleAccountHelper.setCurrentAccount(this, importedAccount.name); mApi.initApi(new NextcloudAPI.ApiConnectedListener() { @@ -337,6 +339,8 @@ public class LoginDialogActivity extends AppCompatActivity { editor.putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, false); editor.commit(); + resetDatabase(); + final ProgressDialog dialogLogin = buildPendingDialogWhileLoggingIn(); dialogLogin.show(); @@ -357,7 +361,13 @@ public class LoginDialogActivity extends AppCompatActivity { } } - private void finishLogin(final ProgressDialog dialogLogin) { + private void resetDatabase() { + //Reset Database + DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(LoginDialogActivity.this); + dbConn.resetDatabase(); + } + + private void finishLogin(final ProgressDialog dialogLogin) { mApi.getAPI().version() .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) @@ -409,10 +419,6 @@ public class LoginDialogActivity extends AppCompatActivity { Log.v(TAG, "onComplete() called"); if(loginSuccessful) { - //Reset Database - DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(LoginDialogActivity.this); - dbConn.resetDatabase(); - Intent returnIntent = new Intent(); setResult(RESULT_OK, returnIntent);