Skip to content

Commit d8b235c

Browse files
author
Krzysztof Borowy
committed
change flag name, expose storage for brownfield
1 parent 4946614 commit d8b235c

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ if( newDbSize != null && newDbSize.isLong()) {
6161

6262
// Instead of reusing AsyncTask thread pool, AsyncStorage can use its own executor
6363
def useDedicatedExecutor = getFlagOrDefault('AsyncStorage_dedicatedExecutor', false)
64-
def useNext = getFlagOrDefault("AsyncStorage_useNext", false)
64+
def useNextStorage = getFlagOrDefault("AsyncStorage_useNextStorage", false)
6565

6666
apply plugin: 'com.android.library'
67-
if(useNext) {
67+
if(useNextStorage) {
6868
apply plugin: 'kotlin-android'
6969
apply plugin: 'kotlin-kapt'
7070
}
@@ -77,7 +77,7 @@ android {
7777
targetSdkVersion safeExtGet('targetSdkVersion', 28)
7878
buildConfigField "Long", "AsyncStorage_db_size", "${dbSizeInMB}L"
7979
buildConfigField "boolean", "AsyncStorage_useDedicatedExecutor", "${useDedicatedExecutor}"
80-
buildConfigField "boolean", "AsyncStorage_useNext", "${useNext}"
80+
buildConfigField "boolean", "AsyncStorage_useNextStorage", "${useNextStorage}"
8181
}
8282
lintOptions {
8383
abortOnError false
@@ -95,7 +95,7 @@ repositories {
9595

9696
dependencies {
9797

98-
if(useNext) {
98+
if(useNextStorage) {
9999
def room_version = "2.2.6"
100100
def coroutines_version = "1.3.9"
101101

android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
2424

2525
List<NativeModule> moduleList = new ArrayList<>(1);
2626

27-
if (BuildConfig.AsyncStorage_useNext) {
27+
if (BuildConfig.AsyncStorage_useNextStorage) {
2828
try {
2929
Class storageClass = Class.forName("com.reactnativecommunity.asyncstorage.next.StorageModule");
3030
NativeModule inst = (NativeModule) storageClass.getDeclaredConstructor(new Class[]{ReactContext.class}).newInstance(reactContext);

android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageModule.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.reactnativecommunity.asyncstorage.next
22

3+
import android.content.Context
34
import com.facebook.react.bridge.Arguments
45
import com.facebook.react.bridge.Callback
56
import com.facebook.react.bridge.ReactContext
@@ -20,10 +21,16 @@ class StorageModule(reactContext: ReactContext) : ReactContextBaseJavaModule(),
2021

2122
private val storage = StorageSupplier.getInstance(reactContext)
2223

24+
companion object {
25+
@JvmStatic
26+
fun getStorageInstance(ctx: Context): AsyncStorageAccess {
27+
return StorageSupplier.getInstance(ctx)
28+
}
29+
}
30+
2331
/**
2432
* Todo:
25-
* - Documenting the migration,
26-
* - access from Native (Java interop)
33+
* - DB tests
2734
*/
2835

2936
@ReactMethod

0 commit comments

Comments
 (0)