Skip to content

Commit ce4778a

Browse files
authored
fix(android,v11): fix takeSnap (#3994)
1 parent 6353180 commit ce4778a

File tree

1 file changed

+10
-1
lines changed
  • android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/v11compat

1 file changed

+10
-1
lines changed

android/src/main/mapbox-v11-compat/v11/com/rnmapbox/rnmbx/v11compat/Image.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ fun ByteArray.toImageData() : DataRef {
2626
}
2727

2828
fun DataRef.toByteArray(): ByteArray {
29-
return this.buffer.array()
29+
if (this.buffer.hasArray()) {
30+
return this.buffer.array()
31+
} else {
32+
val buffer = this.buffer
33+
val bytes = ByteArray(buffer.remaining())
34+
val oldPos = buffer.position()
35+
buffer.get(bytes)
36+
buffer.position(oldPos)
37+
return bytes
38+
}
3039
}
3140
/*
3241
fun Drawable.toImageHolder(drawableId: Int) : ImageHolder {

0 commit comments

Comments
 (0)