Skip to content

Commit 3e9ce56

Browse files
authored
Merge pull request #244 from mJordan8/main
🐛 fix: react native 0.81.x build issues in android and ios
2 parents 3f10d9b + 41ac9f4 commit 3e9ce56

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

MultipleImagePicker.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Pod::Spec.new do |s|
4242
add_dependency(s, "React-jsinspector", :framework_name => "jsinspector_modern")
4343
add_dependency(s, "React-rendererconsistency", :framework_name => "React_rendererconsistency")
4444
add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing')
45+
add_dependency(s, "React-jsinspectorcdp", :framework_name => 'jsinspector_moderncdp')
4546
end
4647

4748
load 'nitrogen/generated/ios/MultipleImagePicker+autolinking.rb'

android/src/main/java/com/margelo/nitro/multipleimagepicker/CameraEngine.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.margelo.nitro.multipleimagepicker
22

33
import android.content.Context
4+
import android.graphics.Color
45
import androidx.fragment.app.Fragment
56
import com.bumptech.glide.Glide
67
import com.facebook.react.bridge.ColorPropConverter
@@ -30,7 +31,7 @@ class CameraEngine(
3031
camera.setOutputPathDir(getSandboxCameraOutputPath())
3132

3233
config.color?.let {
33-
val primaryColor = ColorPropConverter.getColor(it, appContext)
34+
val primaryColor = ColorPropConverter.getColor(it, appContext) ?: Color.BLACK
3435
camera.setCaptureLoadingColor(primaryColor)
3536
}
3637

android/src/main/java/com/margelo/nitro/multipleimagepicker/MultipleImagePickerImp.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
6565
rejected: (reject: Double) -> Unit
6666
) {
6767
PictureAppMaster.getInstance().app = this
68-
val activity = currentActivity
68+
val activity = reactApplicationContext.currentActivity
69+
?: throw IllegalStateException("No current Activity available")
6970
val imageEngine = GlideEngine.createGlideEngine()
7071

7172
// set global config
@@ -258,7 +259,7 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
258259
// Add listener before starting UCrop
259260
reactApplicationContext.addActivityEventListener(cropActivityEventListener)
260261

261-
currentActivity?.let { uCrop.start(it, REQUEST_CROP) }
262+
reactApplicationContext.currentActivity?.let { uCrop.start(it, REQUEST_CROP) }
262263
} catch (e: Exception) {
263264
rejected(0.0)
264265
}
@@ -310,8 +311,10 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
310311
}
311312
}
312313

314+
val activity = reactApplicationContext.currentActivity
315+
?: throw IllegalStateException("No current Activity available")
313316
PictureSelector
314-
.create(currentActivity)
317+
.create(activity)
315318
.openPreview()
316319
.setImageEngine(imageEngine)
317320
.setLanguage(getLanguage(config.language))
@@ -345,7 +348,8 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
345348
resolved: (result: CameraResult) -> Unit,
346349
rejected: (reject: Double) -> Unit
347350
) {
348-
val activity = currentActivity
351+
val activity = reactApplicationContext.currentActivity
352+
?: throw IllegalStateException("No current Activity available")
349353
val chooseMode = getChooseMode(config.mediaType)
350354

351355
PictureSelector
@@ -361,7 +365,7 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
361365
setCropEngine(CropEngine(cropOption))
362366
}
363367
}
364-
.forResultActivity(object : OnResultCallbackListener<LocalMedia?> {
368+
.forResult(object : OnResultCallbackListener<LocalMedia?> {
365369
override fun onResult(results: java.util.ArrayList<LocalMedia?>?) {
366370
results?.first()?.let {
367371
val result = getResult(it)
@@ -505,7 +509,7 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
505509
val iconBack =
506510
if (isDark) com.luck.picture.lib.R.drawable.ps_ic_back else com.luck.picture.lib.R.drawable.ps_ic_black_back
507511

508-
cropOption.setLogoColor(primaryColor)
512+
cropOption.setLogoColor(primaryColor ?: Color.BLACK)
509513

510514
// TITLE BAR
511515
titleBar.titleBackgroundColor = background
@@ -547,7 +551,7 @@ class MultipleImagePickerImp(reactContext: ReactApplicationContext?) :
547551
mainStyle.isAdapterItemIncludeEdge = true
548552
mainStyle.isPreviewSelectRelativeBottom = false
549553
// mainStyle.previewSelectTextSize = Constant.TOOLBAR_TEXT_SIZE
550-
mainStyle.selectTextColor = primaryColor
554+
mainStyle.selectTextColor = primaryColor ?: Color.BLACK
551555
// mainStyle.selectTextSize = Constant.TOOLBAR_TEXT_SIZE
552556
mainStyle.selectBackground = selectType
553557
mainStyle.isSelectNumberStyle = isNumber

0 commit comments

Comments
 (0)