Skip to content

Commit 3a80e4f

Browse files
committed
fix: fix#176 Fresco 3.1.3 compatibility issues with RN 0.73.0, compileDebugKotlin FAILED
1 parent 9c673c2 commit 3a80e4f

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test
1+
name: CI
22
on:
33
pull_request:
44
types: [opened, synchronize, reopened]
@@ -74,7 +74,8 @@ jobs:
7474
assets/**
7575
package.json
7676
!example/ios/**
77-
77+
example/e2e/**
78+
7879
- uses: actions/cache@v3
7980
name: Cache node_modules
8081
if: steps.verify-android-changed-files.outputs.files_changed == 'true'
@@ -143,7 +144,7 @@ jobs:
143144
name: app-release-${{ github.sha }}.apk
144145
path: ${{ github.workspace }}/example/android/app-release-${{ github.sha }}.apk
145146

146-
android-test:
147+
android-api-level-test:
147148
runs-on: macos-latest
148149
needs: android-build
149150
name: Android Test
@@ -165,6 +166,7 @@ jobs:
165166
assets/**
166167
package.json
167168
!example/ios/**
169+
example/e2e/**
168170
169171
- uses: actions/cache@v3
170172
name: Cache node_modules
@@ -247,6 +249,7 @@ jobs:
247249
assets/**
248250
package.json
249251
!example/android/**
252+
example/e2e/**
250253
251254
- uses: actions/cache@v3
252255
name: Cache node_modules
@@ -309,7 +312,7 @@ jobs:
309312
310313
ci-complete:
311314
name: Complete CI
312-
needs: [android-build, android-test, ios-build-test]
315+
needs: [android-build, android-api-level-test, ios-build-test]
313316
if: ${{ always() }}
314317
runs-on: ubuntu-latest
315318
steps:

README.MD

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
</div>
88
<div align="center">
99

10-
[![npm version](https://img.shields.io/npm/v/react-native-image-marker.svg?logo=npm)](https://www.npmjs.com/package/react-native-image-marker)
11-
[![npm](https://img.shields.io/npm/dm/react-native-image-marker?logo=npm)](https://www.npmjs.com/package/react-native-image-marker) [![npm](https://img.shields.io/npm/dt/react-native-image-marker.svg?cacheSeconds=88660&logo=npm&label=total%20downloads)](https://www.npmjs.com/package/react-native-image-marker)
12-
[![stars](https://img.shields.io/github/stars/jimmydaddy/react-native-image-marker?style=social)](https://github.com/JimmyDaddy/react-native-image-marker) [![forks](https://img.shields.io/github/forks/jimmydaddy/react-native-image-marker?style=social)](https://github.com/JimmyDaddy/react-native-image-marker/fork)
13-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?logo=github)](https://github.com/JimmyDaddy/react-native-image-marker/pulls) ![license](https://img.shields.io/npm/l/react-native-image-marker)
14-
[![github](https://img.shields.io/badge/github-repo-blue?logo=github)](https://github.com/JimmyDaddy/react-native-image-marker)
15-
[![Native Build and Test](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/native-ci.yml/badge.svg)](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/native-ci.yml)
16-
![platform-iOS](https://img.shields.io/badge/iOS-black?logo=Apple) ![platform-Android](https://img.shields.io/badge/Android-black?logo=Android)
10+
[![npm version](https://img.shields.io/npm/v/react-native-image-marker.svg?logo=npm&style=for-the-badge&label=latest)](https://www.npmjs.com/package/react-native-image-marker)
11+
[![npm](https://img.shields.io/npm/dm/react-native-image-marker?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/react-native-image-marker) [![npm](https://img.shields.io/npm/dt/react-native-image-marker.svg?cacheSeconds=88660&logo=npm&label=total%20downloads&style=for-the-badge)](https://www.npmjs.com/package/react-native-image-marker)
12+
[![stars](https://img.shields.io/github/stars/jimmydaddy/react-native-image-marker?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker) [![forks](https://img.shields.io/github/forks/jimmydaddy/react-native-image-marker?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker/fork)
13+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker/pulls) ![license](https://img.shields.io/npm/l/react-native-image-marker?style=for-the-badge)
14+
[![github](https://img.shields.io/badge/github-repo-blue?logo=github&style=for-the-badge)](https://github.com/JimmyDaddy/react-native-image-marker)
15+
[![CI](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/ci.yml/badge.svg)](https://github.com/JimmyDaddy/react-native-image-marker/actions/workflows/ci.yml)
16+
![platform-iOS](https://img.shields.io/badge/iOS-black?logo=Apple&style=for-the-badge) ![platform-Android](https://img.shields.io/badge/Android-black?logo=Android&style=for-the-badge)
1717
<br/>
1818

1919
</div>

android/src/main/java/com/jimmydaddy/imagemarker/ImageLoader.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import android.graphics.BitmapFactory
77
import android.os.Build
88
import android.util.Log
99
import androidx.annotation.RequiresApi
10+
import com.facebook.common.internal.Supplier
1011
import com.facebook.common.references.CloseableReference
1112
import com.facebook.datasource.DataSource
1213
import com.facebook.drawee.backends.pipeline.Fresco
14+
import com.facebook.imagepipeline.cache.MemoryCacheParams
1315
import com.facebook.imagepipeline.common.ResizeOptions
1416
import com.facebook.imagepipeline.core.ImagePipelineConfig
1517
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber
@@ -134,9 +136,19 @@ class ImageLoader(private val context: ReactApplicationContext, private val maxS
134136
patch.toString()
135137
) >= 0
136138
) {
137-
val config =
138-
ImagePipelineConfig.newBuilder(context).experiment().setMaxBitmapSize(maxSize)
139-
.build()
139+
val bitmapMemoryCacheParamsSupplier = Supplier<MemoryCacheParams> {
140+
MemoryCacheParams(
141+
maxSize, // max cache entry size
142+
Integer.MAX_VALUE, // max cache entries
143+
maxSize, // max cache size
144+
Integer.MAX_VALUE, // max cache eviction size
145+
Integer.MAX_VALUE // max cache eviction count
146+
)
147+
}
148+
149+
val config = ImagePipelineConfig.newBuilder(context)
150+
.setBitmapMemoryCacheParamsSupplier(bitmapMemoryCacheParamsSupplier)
151+
.build()
140152
Fresco.initialize(context, config)
141153
}
142154
}

ios/RCTImageMarker/ImageMarker.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public final class ImageMarker: NSObject, RCTBridgeModule {
9999
}
100100
}
101101

102-
func markerImgWithText(_ image: UIImage, _ opts: MarkTextOptions) -> UIImage? {
102+
func markImgWithText(_ image: UIImage, _ opts: MarkTextOptions) -> UIImage? {
103103

104104
var bg = image;
105105
if (opts.backgroundImage.scale > 0) {
@@ -258,8 +258,8 @@ public final class ImageMarker: NSObject, RCTBridgeModule {
258258
return aimg
259259
}
260260

261-
func markeImage(with image: UIImage, waterImages: [UIImage], options: MarkImageOptions) -> UIImage? {
262-
261+
func markImage(with image: UIImage, waterImages: [UIImage], options: MarkImageOptions) -> UIImage? {
262+
263263
var bg = image;
264264
if (options.backgroundImage.scale > 0) {
265265
bg = UIImage(cgImage: image.cgImage!, scale: 1 / options.backgroundImage.scale, orientation: image.imageOrientation)
@@ -370,12 +370,12 @@ public final class ImageMarker: NSObject, RCTBridgeModule {
370370
Task(priority: .userInitiated) {
371371
do {
372372
let images = try await loadImages(with: [(markOpts?.backgroundImage)!])
373-
let scaledImage = self.markerImgWithText(images[0], markOpts!)
373+
let scaledImage = self.markImgWithText(images[0], markOpts!)
374374
let res = self.saveImageForMarker(scaledImage!, with: markOpts!)
375375
resolver(res)
376-
print("Loaded images:", images)
376+
print("Loaded images: \(images)")
377377
} catch {
378-
print("Failed to load images:", error)
378+
print("Failed to load images, error: \(error).")
379379
}
380380
}
381381
}
@@ -390,12 +390,12 @@ public final class ImageMarker: NSObject, RCTBridgeModule {
390390
do {
391391
let waterImages = markOpts?.watermarkImages.map { $0.imageOption }
392392
var images = try await loadImages(with: [(markOpts?.backgroundImage)!] + waterImages!)
393-
let scaledImage = self.markeImage(with: images.remove(at: 0), waterImages: images, options: markOpts!)
393+
let scaledImage = self.markImage(with: images.remove(at: 0), waterImages: images, options: markOpts!)
394394
let res = self.saveImageForMarker(scaledImage!, with: markOpts!)
395395
resolver(res)
396-
print("Loaded images:", images)
396+
print("Loaded images: \(images), waterImages: \(String(describing: waterImages))")
397397
} catch {
398-
print("Failed to load images:", error)
398+
print("Failed to load images, error: \(error).")
399399
}
400400
}
401401
}

0 commit comments

Comments
 (0)