fix imports

This commit is contained in:
Salakar 2017-11-28 09:09:58 +00:00
parent 13c43f2efe
commit a94943bfc0
5 changed files with 23 additions and 10 deletions

View File

@ -13,6 +13,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseApp;
import com.google.firebase.database.DatabaseException;
import com.google.firebase.database.Logger; import com.google.firebase.database.Logger;
import com.google.firebase.database.MutableData; import com.google.firebase.database.MutableData;
import com.google.firebase.database.OnDisconnect; import com.google.firebase.database.OnDisconnect;
@ -35,6 +36,7 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
private static final String TAG = "RNFirebaseDatabase"; private static final String TAG = "RNFirebaseDatabase";
private boolean enableLogging = false; private boolean enableLogging = false;
private HashMap<String, RNFirebaseDatabaseReference> references = new HashMap<>(); private HashMap<String, RNFirebaseDatabaseReference> references = new HashMap<>();
private HashMap<String, Boolean> loggingLevelSet = new HashMap<>();
private SparseArray<RNFirebaseTransactionHandler> transactionHandlers = new SparseArray<>(); private SparseArray<RNFirebaseTransactionHandler> transactionHandlers = new SparseArray<>();
RNFirebaseDatabase(ReactApplicationContext reactContext) { RNFirebaseDatabase(ReactApplicationContext reactContext) {
@ -89,6 +91,8 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
enableLogging = enabled; enableLogging = enabled;
List<FirebaseApp> firebaseAppList = FirebaseApp.getApps(getReactApplicationContext()); List<FirebaseApp> firebaseAppList = FirebaseApp.getApps(getReactApplicationContext());
for (FirebaseApp app : firebaseAppList) { for (FirebaseApp app : firebaseAppList) {
loggingLevelSet.put(app.getName(), enabled);
if (enableLogging) { if (enableLogging) {
FirebaseDatabase.getInstance(app).setLogLevel(Logger.Level.DEBUG); FirebaseDatabase.getInstance(app).setLogLevel(Logger.Level.DEBUG);
} else { } else {
@ -488,12 +492,21 @@ public class RNFirebaseDatabase extends ReactContextBaseJavaModule {
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName); FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp); FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp);
// todo errors 'calls must be made before any other usage of database instance if (enableLogging && !loggingLevelSet.get(firebaseDatabase.getApp().getName())) {
// if (enableLogging) { try {
// firebaseDatabase.setLogLevel(Logger.Level.DEBUG); loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging);
// } else { firebaseDatabase.setLogLevel(Logger.Level.DEBUG);
// firebaseDatabase.setLogLevel(Logger.Level.WARN); } catch (DatabaseException dex) {
// } // do nothing - to catch 'calls to setLogLevel must be made for use of database' errors
}
} else if (!enableLogging && loggingLevelSet.get(firebaseDatabase.getApp().getName())) {
try {
loggingLevelSet.put(firebaseDatabase.getApp().getName(), enableLogging);
firebaseDatabase.setLogLevel(Logger.Level.WARN);
} catch (DatabaseException dex) {
// do nothing - to catch 'calls to setLogLevel must be made for use of database' errors
}
}
return firebaseDatabase; return firebaseDatabase;
} }

View File

@ -3,7 +3,7 @@
*/ */
import { NativeEventEmitter } from 'react-native'; import { NativeEventEmitter } from 'react-native';
import INTERNALS from './../internals'; import INTERNALS from './internals';
import DatabaseSnapshot from './../modules/database/snapshot'; import DatabaseSnapshot from './../modules/database/snapshot';
import DatabaseReference from './../modules/database/reference'; import DatabaseReference from './../modules/database/reference';
import { isString, nativeToJSError } from './../utils'; import { isString, nativeToJSError } from './../utils';

View File

@ -1,7 +1,7 @@
import { Platform } from 'react-native'; import { Platform } from 'react-native';
import firebase from 'firebase'; import firebase from 'firebase';
import RNfirebase from './../firebase/firebase'; import RNfirebase from './../firebase';
import DatabaseContents from './tests/support/DatabaseContents'; import DatabaseContents from './tests/support/DatabaseContents';

View File

@ -1,7 +1,7 @@
import { Platform } from 'react-native'; import { Platform } from 'react-native';
import should from 'should'; import should from 'should';
import RNFirebase from './../../../firebase/firebase'; import RNFirebase from './../../../firebase';
const androidTestConfig = { const androidTestConfig = {
// firebase android sdk completely ignores client id // firebase android sdk completely ignores client id

View File

@ -1,4 +1,4 @@
import RNfirebase from './../../../firebase/firebase'; import RNfirebase from './../../../firebase';
function storageTests({ describe, it, firebase, tryCatch }) { function storageTests({ describe, it, firebase, tryCatch }) {
describe('ref(:path)', () => { describe('ref(:path)', () => {