Skip to content

Commit a8c666b

Browse files
committed
fix(android): zoomimage not showing anything
1 parent 13da80c commit a8c666b

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

packages/image/platforms/android/java/com/nativescript/image/DraweeView.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.facebook.imagepipeline.request.ImageRequestBuilder;
55
import com.facebook.imagepipeline.request.ImageRequest;
66
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
7+
import com.facebook.drawee.generic.GenericDraweeHierarchy;
78

89
import android.graphics.Outline;
910
import android.graphics.Rect;
@@ -13,6 +14,7 @@
1314
import android.content.Context;
1415
import android.os.Build;
1516
import android.util.Log;
17+
import android.util.AttributeSet;
1618

1719
import android.graphics.Canvas;
1820
import android.graphics.Path;
@@ -38,6 +40,26 @@ public class DraweeView extends SimpleDraweeView {
3840

3941
private boolean clipEnabled = true;
4042

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+
4163
public void setClipToBounds(boolean value) {
4264
clipEnabled = value;
4365
if (value) {
@@ -81,10 +103,6 @@ public boolean getClipToBounds() {
81103
return clipEnabled;
82104
}
83105

84-
public DraweeView(Context context) {
85-
super(context);
86-
setClipToBounds(clipEnabled);
87-
}
88106

89107
@Override
90108
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
@@ -188,7 +206,7 @@ protected void onDraw(Canvas canvas) {
188206
}
189207

190208
public void setUri(android.net.Uri uri, String jsonOptions, com.facebook.drawee.controller.ControllerListener listener) {
191-
long start = System.nanoTime();
209+
Log.d("JS", "setUri " + uri.toString());
192210
ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setRotationOptions( com.facebook.imagepipeline.common.RotationOptions.autoRotate());
193211
JSONObject object = null;
194212
if (jsonOptions.length() > 2) {
@@ -249,7 +267,7 @@ public void setUri(android.net.Uri uri, String jsonOptions, com.facebook.drawee.
249267
builder.setTapToRetryEnabled(true);
250268
}
251269
}
252-
270+
Log.d("JS", "setUri " + uri.toString() + " " + object);
253271
setController(builder.build());
254272
}
255273
}

packages/zoomimage/platforms/android/java/com/facebook/samples/zoomable/ZoomableDraweeView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
2626
import com.facebook.drawee.generic.GenericDraweeHierarchyInflater;
2727
import com.facebook.drawee.interfaces.DraweeController;
28-
import com.facebook.drawee.view.DraweeView;
28+
import com.nativescript.image.DraweeView;
2929

3030
/**
3131
* DraweeView that has zoomable capabilities.
3232
*
3333
* <p>Once the image loads, pinch-to-zoom and translation gestures are enabled.
3434
*/
35-
public class ZoomableDraweeView extends DraweeView<GenericDraweeHierarchy>
35+
public class ZoomableDraweeView extends DraweeView
3636
implements ScrollingView {
3737

3838
private static final Class<?> TAG = ZoomableDraweeView.class;
@@ -42,7 +42,7 @@ public class ZoomableDraweeView extends DraweeView<GenericDraweeHierarchy>
4242
private final RectF mImageBounds = new RectF();
4343
private final RectF mViewBounds = new RectF();
4444

45-
private DraweeController mHugeImageController;
45+
private DraweeController mHugeImageController;
4646
private ZoomableController mZoomableController;
4747
private GestureDetector mTapGestureDetector;
4848
private boolean mAllowTouchInterceptionWhileZoomed = true;

0 commit comments

Comments
 (0)