Add Image#getSize for Android

Summary:
I've implemented the getSize method on Image for Android.

**Test plan (required)**

The result in the UIExample app can be seen here:

![android-getsize](https://cloud.githubusercontent.com/assets/570297/15442613/a29c9178-1ee2-11e6-97df-adc20aad0c32.jpg)
Closes https://github.com/facebook/react-native/pull/7664

Differential Revision: D3331704

fbshipit-source-id: d784c861cbc653cd6b49310f4b5516c6583486ca
This commit is contained in:
Corné Dorrestijn
2016-05-20 18:40:59 -07:00
committed by Facebook Github Bot 1
parent fb5d0ff587
commit c1558bc7db
3 changed files with 79 additions and 1 deletions

View File

@@ -113,6 +113,21 @@ var Image = React.createClass({
statics: {
resizeMode: ImageResizeMode,
getSize(
url: string,
success: (width: number, height: number) => void,
failure: (error: any) => void,
) {
return ImageLoader.getSize(url)
.then(function(sizes) {
success(sizes.width, sizes.height);
})
.catch(failure || function() {
console.warn('Failed to get size for image: ' + url);
});
},
/**
* Prefetches a remote image for later use by downloading it to the disk
* cache