@nativescript-community/ui-image 4.3.10 → 4.3.12
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 +11 -333
- package/index-common.d.ts +30 -30
- package/index-common.js +159 -78
- package/index.android.d.ts +2 -0
- package/index.android.js +204 -227
- package/index.ios.js +6 -6
- package/package.json +2 -2
- package/platforms/android/include.gradle +1 -0
- package/platforms/android/java/com/nativescript/image/DraweeView.java +96 -4
- package/platforms/android/ui_image.aar +0 -0
- package/typings/android.d.ts +1 -0
@@ -1,6 +1,10 @@
|
|
1
1
|
package com.nativescript.image;
|
2
2
|
|
3
3
|
import com.facebook.drawee.view.SimpleDraweeView;
|
4
|
+
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
5
|
+
import com.facebook.imagepipeline.request.ImageRequest;
|
6
|
+
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
|
7
|
+
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
4
8
|
|
5
9
|
import android.graphics.Outline;
|
6
10
|
import android.graphics.Rect;
|
@@ -10,6 +14,7 @@ import android.view.View;
|
|
10
14
|
import android.content.Context;
|
11
15
|
import android.os.Build;
|
12
16
|
import android.util.Log;
|
17
|
+
import android.util.AttributeSet;
|
13
18
|
|
14
19
|
import android.graphics.Canvas;
|
15
20
|
import android.graphics.Path;
|
@@ -22,6 +27,10 @@ import android.view.ViewOutlineProvider;
|
|
22
27
|
|
23
28
|
import org.nativescript.widgets.BorderDrawable;
|
24
29
|
|
30
|
+
import org.json.JSONArray;
|
31
|
+
import org.json.JSONObject;
|
32
|
+
import org.json.JSONException;
|
33
|
+
|
25
34
|
import java.util.Arrays;
|
26
35
|
|
27
36
|
public class DraweeView extends SimpleDraweeView {
|
@@ -31,6 +40,26 @@ public class DraweeView extends SimpleDraweeView {
|
|
31
40
|
|
32
41
|
private boolean clipEnabled = true;
|
33
42
|
|
43
|
+
public DraweeView(Context context, GenericDraweeHierarchy hierarchy) {
|
44
|
+
super(context);
|
45
|
+
setClipToBounds(clipEnabled);
|
46
|
+
}
|
47
|
+
|
48
|
+
public DraweeView(Context context) {
|
49
|
+
super(context);
|
50
|
+
setClipToBounds(clipEnabled);
|
51
|
+
}
|
52
|
+
|
53
|
+
public DraweeView(Context context, AttributeSet attrs) {
|
54
|
+
super(context, attrs);
|
55
|
+
setClipToBounds(clipEnabled);
|
56
|
+
}
|
57
|
+
|
58
|
+
public DraweeView(Context context, AttributeSet attrs, int defStyle) {
|
59
|
+
super(context, attrs, defStyle);
|
60
|
+
setClipToBounds(clipEnabled);
|
61
|
+
}
|
62
|
+
|
34
63
|
public void setClipToBounds(boolean value) {
|
35
64
|
clipEnabled = value;
|
36
65
|
if (value) {
|
@@ -74,10 +103,6 @@ public class DraweeView extends SimpleDraweeView {
|
|
74
103
|
return clipEnabled;
|
75
104
|
}
|
76
105
|
|
77
|
-
public DraweeView(Context context) {
|
78
|
-
super(context);
|
79
|
-
setClipToBounds(clipEnabled);
|
80
|
-
}
|
81
106
|
|
82
107
|
@Override
|
83
108
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
@@ -120,6 +145,7 @@ public class DraweeView extends SimpleDraweeView {
|
|
120
145
|
&& (borderLeftWidth == 0 && borderBottomWidth == 0 && borderTopWidth == 0 && borderRightWidth == 0))
|
121
146
|
|| (borderTopLeftRadius == 0 && borderTopRightRadius == 0 && borderBottomRightRadius == 0
|
122
147
|
&& borderBottomLeftRadius == 0))) {
|
148
|
+
// we can use outline
|
123
149
|
return null;
|
124
150
|
}
|
125
151
|
if (innerBorderPath == null) {
|
@@ -178,4 +204,70 @@ public class DraweeView extends SimpleDraweeView {
|
|
178
204
|
}
|
179
205
|
super.onDraw(canvas);
|
180
206
|
}
|
207
|
+
|
208
|
+
public void setUri(android.net.Uri uri, String jsonOptions, com.facebook.drawee.controller.ControllerListener listener) {
|
209
|
+
Log.d("JS", "setUri " + uri.toString());
|
210
|
+
ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions( com.facebook.imagepipeline.common.RotationOptions.autoRotate());
|
211
|
+
JSONObject object = null;
|
212
|
+
if (jsonOptions.length() > 2) {
|
213
|
+
try {
|
214
|
+
object = new JSONObject(jsonOptions);
|
215
|
+
} catch (Exception ignored) {
|
216
|
+
}
|
217
|
+
}
|
218
|
+
if (object != null) {
|
219
|
+
if (object.optBoolean("progressiveRenderingEnabled")) {
|
220
|
+
requestBuilder = requestBuilder.setProgressiveRenderingEnabled(true);
|
221
|
+
}
|
222
|
+
if (object.optBoolean("localThumbnailPreviewsEnabled")) {
|
223
|
+
requestBuilder = requestBuilder.setLocalThumbnailPreviewsEnabled(true);
|
224
|
+
}
|
225
|
+
int decodeWidth = object.optInt("decodeWidth");
|
226
|
+
int decodeHeight = object.optInt("decodeHeight");
|
227
|
+
|
228
|
+
if (decodeWidth > 0 && decodeHeight > 0) {
|
229
|
+
requestBuilder = requestBuilder.setResizeOptions(new com.facebook.imagepipeline.common.ResizeOptions(decodeWidth, decodeHeight));
|
230
|
+
}
|
231
|
+
int blurRadius = object.optInt("blurRadius", 0);
|
232
|
+
if (blurRadius > 0) {
|
233
|
+
int blurDownSampling = object.optInt("blurDownSampling", 1);
|
234
|
+
requestBuilder = requestBuilder.setPostprocessor(new com.nativescript.image.ScalingBlurPostprocessor(2, blurRadius, blurDownSampling));
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
ImageRequest request = requestBuilder.build();
|
239
|
+
PipelineDraweeControllerBuilder builder = com.facebook.drawee.backends.pipeline.Fresco.newDraweeControllerBuilder();
|
240
|
+
builder.setImageRequest(request);
|
241
|
+
builder.setCallerContext(uri.toString());
|
242
|
+
builder.setControllerListener(listener);
|
243
|
+
builder.setOldController(getController());
|
244
|
+
// if (Trace.isEnabled()) {
|
245
|
+
// builder.setPerfDataListener(
|
246
|
+
// new com.facebook.drawee.backends.pipeline.info.ImagePerfDataListener({
|
247
|
+
// onImageLoadStatusUpdated(param0: com.facebook.drawee.backends.pipeline.info.ImagePerfData, param1: number) {
|
248
|
+
// CLog(CLogTypes.info, 'onImageLoadStatusUpdated', param0, param1);
|
249
|
+
// },
|
250
|
+
// onImageVisibilityUpdated(param0: com.facebook.drawee.backends.pipeline.info.ImagePerfData, param1: number) {
|
251
|
+
// CLog(CLogTypes.info, 'onImageVisibilityUpdated', param0, param1);
|
252
|
+
// }
|
253
|
+
// })
|
254
|
+
// );
|
255
|
+
// }
|
256
|
+
if (object != null) {
|
257
|
+
String lowerResSrc = object.optString("lowerResSrc");
|
258
|
+
if (lowerResSrc != null) {
|
259
|
+
builder.setLowResImageRequest(com.facebook.imagepipeline.request.ImageRequest.fromUri(android.net.Uri.parse(lowerResSrc)));
|
260
|
+
}
|
261
|
+
|
262
|
+
if (object.optBoolean("autoPlayAnimations")) {
|
263
|
+
builder.setAutoPlayAnimations(true);
|
264
|
+
}
|
265
|
+
|
266
|
+
if (object.optBoolean("tapToRetryEnabled")) {
|
267
|
+
builder.setTapToRetryEnabled(true);
|
268
|
+
}
|
269
|
+
}
|
270
|
+
Log.d("JS", "setUri " + uri.toString() + " " + object);
|
271
|
+
setController(builder.build());
|
272
|
+
}
|
181
273
|
}
|
Binary file
|
package/typings/android.d.ts
CHANGED
@@ -7,6 +7,7 @@ declare namespace com {
|
|
7
7
|
class DraweeView extends facebook.drawee.view.SimpleDraweeView {
|
8
8
|
imageWidth: number;
|
9
9
|
imageHeight: number;
|
10
|
+
setUri(uri: globalAndroid.net.Uri, options: string, listener: facebook.drawee.controller.ControllerListener);
|
10
11
|
}
|
11
12
|
class ScalingBlurPostprocessor extends facebook.imagepipeline.request.BasePostprocessor {
|
12
13
|
public constructor(iterations: number, blurRadius: number, scaleRatio: number);
|