|
11 | 11 |
|
12 | 12 | import android.net.Uri; |
13 | 13 |
|
14 | | -import com.facebook.react.bridge.Arguments; |
15 | | -import com.facebook.react.bridge.Callback; |
16 | | -import com.facebook.react.bridge.WritableMap; |
17 | 14 | import com.facebook.common.executors.CallerThreadExecutor; |
18 | 15 | import com.facebook.common.references.CloseableReference; |
19 | 16 | import com.facebook.datasource.BaseDataSubscriber; |
|
23 | 20 | import com.facebook.imagepipeline.image.CloseableImage; |
24 | 21 | import com.facebook.imagepipeline.request.ImageRequest; |
25 | 22 | import com.facebook.imagepipeline.request.ImageRequestBuilder; |
| 23 | +import com.facebook.react.bridge.Arguments; |
26 | 24 | import com.facebook.react.bridge.Promise; |
27 | 25 | import com.facebook.react.bridge.ReactApplicationContext; |
28 | 26 | import com.facebook.react.bridge.ReactContextBaseJavaModule; |
29 | 27 | import com.facebook.react.bridge.ReactMethod; |
| 28 | +import com.facebook.react.bridge.WritableMap; |
30 | 29 |
|
31 | 30 | public class ImageLoaderModule extends ReactContextBaseJavaModule { |
32 | 31 |
|
@@ -83,27 +82,20 @@ protected void onNewResultImpl( |
83 | 82 | sizes.putInt("width", image.getWidth()); |
84 | 83 | sizes.putInt("height", image.getHeight()); |
85 | 84 |
|
86 | | - image.close(); |
87 | 85 | promise.resolve(sizes); |
88 | 86 | } catch (Exception e) { |
89 | 87 | promise.reject(ERROR_GET_SIZE_FAILURE, e); |
90 | 88 | } finally { |
91 | 89 | CloseableReference.closeSafely(ref); |
92 | | - dataSource.close(); |
93 | 90 | } |
94 | 91 | } else { |
95 | | - dataSource.close(); |
96 | 92 | promise.reject(ERROR_GET_SIZE_FAILURE); |
97 | 93 | } |
98 | 94 | } |
99 | 95 |
|
100 | 96 | @Override |
101 | 97 | protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) { |
102 | | - try { |
103 | | - promise.reject(ERROR_GET_SIZE_FAILURE, dataSource.getFailureCause()); |
104 | | - } finally { |
105 | | - dataSource.close(); |
106 | | - } |
| 98 | + promise.reject(ERROR_GET_SIZE_FAILURE, dataSource.getFailureCause()); |
107 | 99 | } |
108 | 100 | }; |
109 | 101 | dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance()); |
|
0 commit comments