expo-image 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/expo/modules/image/ExpoImageModule.kt +3 -7
- package/android/src/main/java/expo/modules/image/ExpoImageViewWrapper.kt +4 -2
- package/android/src/main/java/expo/modules/image/ImageLoadTask.kt +21 -27
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 2.0.3 — 2024-11-29
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- [Android] Fixed `useImage` causing a native crash when uri is unresolvable. ([#33268](https://github.com/expo/expo/pull/33268) by [@lukmccall](https://github.com/lukmccall))
|
|
18
|
+
- [Android] Fixes adding a blurhash placeholder to `Image` or `ImageBackground` causing blurry version of the image. ([#33272](https://github.com/expo/expo/pull/33272) by [@lukmccall](https://github.com/lukmccall))
|
|
19
|
+
|
|
13
20
|
## 2.0.2 — 2024-11-22
|
|
14
21
|
|
|
15
22
|
### 💡 Others
|
package/android/build.gradle
CHANGED
|
@@ -18,7 +18,7 @@ android {
|
|
|
18
18
|
namespace "expo.modules.image"
|
|
19
19
|
defaultConfig {
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName "2.0.
|
|
21
|
+
versionName "2.0.3"
|
|
22
22
|
consumerProguardFiles("proguard-rules.pro")
|
|
23
23
|
|
|
24
24
|
buildConfigField("boolean", "ALLOW_GLIDE_LOGS", project.properties.get("EXPO_ALLOW_GLIDE_LOGS", "false"))
|
|
@@ -31,15 +31,13 @@ import expo.modules.image.records.SourceMap
|
|
|
31
31
|
import expo.modules.kotlin.Promise
|
|
32
32
|
import expo.modules.kotlin.apifeatures.EitherType
|
|
33
33
|
import expo.modules.kotlin.exception.Exceptions
|
|
34
|
+
import expo.modules.kotlin.functions.Coroutine
|
|
34
35
|
import expo.modules.kotlin.functions.Queues
|
|
35
36
|
import expo.modules.kotlin.modules.Module
|
|
36
37
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
37
38
|
import expo.modules.kotlin.sharedobjects.SharedRef
|
|
38
39
|
import expo.modules.kotlin.types.EitherOfThree
|
|
39
40
|
import expo.modules.kotlin.types.toKClass
|
|
40
|
-
import kotlinx.coroutines.CoroutineScope
|
|
41
|
-
import kotlinx.coroutines.Dispatchers
|
|
42
|
-
import kotlinx.coroutines.launch
|
|
43
41
|
|
|
44
42
|
class ExpoImageModule : Module() {
|
|
45
43
|
override fun definition() = ModuleDefinition {
|
|
@@ -110,10 +108,8 @@ class ExpoImageModule : Module() {
|
|
|
110
108
|
}
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
AsyncFunction("loadAsync") { source: SourceMap, options: ImageLoadOptions
|
|
114
|
-
|
|
115
|
-
ImageLoadTask(appContext, source, options ?: ImageLoadOptions()).load(promise)
|
|
116
|
-
}
|
|
111
|
+
AsyncFunction("loadAsync") Coroutine { source: SourceMap, options: ImageLoadOptions? ->
|
|
112
|
+
ImageLoadTask(appContext, source, options ?: ImageLoadOptions()).load()
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
Class(Image::class) {
|
|
@@ -540,8 +540,10 @@ class ExpoImageViewWrapper(context: Context, appContext: AppContext) : ExpoView(
|
|
|
540
540
|
}
|
|
541
541
|
newTarget.placeholderContentFit = newPlaceholderContentFit
|
|
542
542
|
|
|
543
|
-
thumbnail(
|
|
544
|
-
.
|
|
543
|
+
thumbnail(
|
|
544
|
+
requestManager.load(placeholderModel.getGlideModel())
|
|
545
|
+
.apply(placeholderSource.createGlideOptions(context))
|
|
546
|
+
)
|
|
545
547
|
}
|
|
546
548
|
.downsample(downsampleStrategy)
|
|
547
549
|
.addListener(GlideRequestListener(WeakReference(this)))
|
|
@@ -1,42 +1,36 @@
|
|
|
1
1
|
package expo.modules.image
|
|
2
2
|
|
|
3
|
-
import android.graphics.drawable.Drawable
|
|
4
3
|
import com.bumptech.glide.Glide
|
|
5
4
|
import expo.modules.image.records.ImageLoadOptions
|
|
6
5
|
import expo.modules.image.records.SourceMap
|
|
7
6
|
import expo.modules.kotlin.AppContext
|
|
8
|
-
import expo.modules.kotlin.Promise
|
|
9
7
|
import expo.modules.kotlin.exception.Exceptions
|
|
10
8
|
import kotlinx.coroutines.Dispatchers
|
|
11
|
-
import kotlinx.coroutines.Job
|
|
12
|
-
import kotlinx.coroutines.async
|
|
13
|
-
import kotlinx.coroutines.coroutineScope
|
|
14
9
|
import kotlinx.coroutines.withContext
|
|
15
10
|
|
|
16
|
-
open class ImageLoadTask(
|
|
17
|
-
private
|
|
11
|
+
open class ImageLoadTask(
|
|
12
|
+
private val appContext: AppContext,
|
|
13
|
+
private val source: SourceMap,
|
|
14
|
+
private val options: ImageLoadOptions
|
|
15
|
+
) {
|
|
16
|
+
suspend fun load(): Image {
|
|
17
|
+
val context =
|
|
18
|
+
this@ImageLoadTask.appContext.reactContext ?: throw Exceptions.ReactContextLost()
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.centerInside()
|
|
29
|
-
.submit(options.maxWidth, options.maxHeight)
|
|
30
|
-
.get()
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
task = deferred
|
|
34
|
-
try {
|
|
35
|
-
val bitmap: Drawable = deferred.await()
|
|
36
|
-
promise.resolve(Image(bitmap))
|
|
37
|
-
} catch (e: Exception) {
|
|
38
|
-
promise.reject(ImageLoadFailed(e))
|
|
20
|
+
try {
|
|
21
|
+
val bitmap = withContext(Dispatchers.IO) {
|
|
22
|
+
Glide
|
|
23
|
+
.with(context)
|
|
24
|
+
.asDrawable()
|
|
25
|
+
.load(source.uri)
|
|
26
|
+
.centerInside()
|
|
27
|
+
.submit(options.maxWidth, options.maxHeight)
|
|
28
|
+
.get()
|
|
39
29
|
}
|
|
30
|
+
|
|
31
|
+
return Image(bitmap)
|
|
32
|
+
} catch (e: Exception) {
|
|
33
|
+
throw ImageLoadFailed(e)
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image",
|
|
3
3
|
"title": "Expo Image",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"description": "A cross-platform, performant image component for React Native and Expo with Web support",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"optional": true
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "728158f99d680cf64fb06f08301d3806c18c6f63"
|
|
45
45
|
}
|