[android][database] fix boolean issue

This commit is contained in:
Salakar 2017-11-28 12:27:38 +00:00
parent a94943bfc0
commit 99dfdfc982
1 changed files with 3 additions and 2 deletions

View File

@ -491,15 +491,16 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
private FirebaseDatabase getDatabaseForApp(String appName) { private FirebaseDatabase getDatabaseForApp(String appName) {
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName); FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp); FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp);
Boolean logLevel = loggingLevelSet.get(firebaseDatabase.getApp().getName());
if (enableLogging && !loggingLevelSet.get(firebaseDatabase.getApp().getName())) { if (enableLogging && (logLevel == null || !logLevel)) {
try { try {
loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging); loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging);
firebaseDatabase.setLogLevel(Logger.Level.DEBUG); firebaseDatabase.setLogLevel(Logger.Level.DEBUG);
} catch (DatabaseException dex) { } catch (DatabaseException dex) {
// do nothing - to catch 'calls to setLogLevel must be made for use of database' errors // do nothing - to catch 'calls to setLogLevel must be made for use of database' errors
} }
} else if (!enableLogging && loggingLevelSet.get(firebaseDatabase.getApp().getName())) { } else if (!enableLogging && (logLevel != null && logLevel)) {
try { try {
loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging); loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging);
firebaseDatabase.setLogLevel(Logger.Level.WARN); firebaseDatabase.setLogLevel(Logger.Level.WARN);