Skip to content

Commit b8e81ec

Browse files
Merge pull request #203 from thetaungg/fix/rn-81-issues
fix: react-native 0.81 build error for currentActivity and rt error on android for getDecibel func
2 parents 050fd75 + 55d34d4 commit b8e81ec

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

android/src/main/java/com/audiowaveform/AudioWaveformModule.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,19 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav
5959

6060
@ReactMethod
6161
fun checkHasAudioRecorderPermission(promise: Promise) {
62-
audioRecorder.checkPermission(currentActivity, promise)
62+
audioRecorder.checkPermission(reactApplicationContext.currentActivity, promise)
6363
}
6464

6565
@ReactMethod
6666
fun getAudioRecorderPermission(promise: Promise) {
67-
audioRecorder.getPermission(currentActivity, promise)
67+
audioRecorder.getPermission(reactApplicationContext.currentActivity, promise)
6868
}
6969

7070
@ReactMethod
7171
fun initRecorder(obj: ReadableMap?, promise: Promise) {
7272
checkPathAndInitialiseRecorder(encoder, outputFormat, sampleRate, bitRate, promise, obj)
7373
}
7474

75-
@ReactMethod
76-
fun getDecibel(): Double? {
77-
return audioRecorder.getDecibel(recorder)
78-
}
79-
8075
@ReactMethod
8176
fun startRecording(obj: ReadableMap?, promise: Promise) {
8277
initRecorder(obj, promise)
@@ -379,7 +374,7 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav
379374
Log.e(Constants.LOG_TAG, "Failed to initialise Recorder")
380375
}
381376
if (path == null) {
382-
val outputDir = currentActivity?.cacheDir
377+
val outputDir = reactApplicationContext.currentActivity?.cacheDir
383378
val outputFile: File?
384379
val dateTimeInstance = SimpleDateFormat(Constants.fileNameFormat, Locale.US)
385380
val currentDate = dateTimeInstance.format(Date())
@@ -413,7 +408,7 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav
413408

414409
private val emitLiveRecordValue = object : Runnable {
415410
override fun run() {
416-
val currentDecibel = getDecibel()
411+
val currentDecibel = audioRecorder.getDecibel(recorder)
417412
val args: WritableMap = Arguments.createMap()
418413
if (currentDecibel == Double.NEGATIVE_INFINITY) {
419414
args.putDouble(Constants.currentDecibel, 0.0)

0 commit comments

Comments
 (0)