Fix crash with getting db

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-01-13 00:24:41 +01:00
parent 3f21d8bfbe
commit 8dbd381adb

View file

@ -96,8 +96,15 @@ public final class MainActivity extends AppCompatActivity implements ActionBarPr
router = Conductor.attachRouter(this, container, savedInstanceState);
if (!router.hasRootController() && sqlCipherDatabaseSource.getWritableDatabase() != null &&
userUtils.anyUserExists()) {
boolean hasDb = true;
try {
sqlCipherDatabaseSource.getWritableDatabase();
} catch (Exception exception) {
hasDb = false;
}
if (!router.hasRootController() && hasDb && userUtils.anyUserExists()) {
router.setRoot(RouterTransaction.with(new MagicBottomNavigationController())
.pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()));