Ejemplo n.º 1
0
        private void DisplayData(object result)
        {
            //Debug.Log("Displaying data");
            string json = ((WWW)result).text; //Debug.Log(json);

            try                               // deserialize
            {
                PhotosSearchResponse response = (PhotosSearchResponse)JsonReader.Deserialize(json, typeof(PhotosSearchResponse));
                if (response.Stat != "ok")
                {
                    Alert.Show("Error", response.Message, AlertButtonFlag.Ok);
                    return;
                }

                var count = 0;

                // load images
                response.Photos.Photo.ForEach(delegate(Photo photo)
                {
                    var data = new PhotoData(photo.Title)
                    {
                        ImageUrl = photo.GetUrl(ImageSize)
                    };
                    _dataProvider.AddItemAt(data, count); // add it to the beginning off the list

                    // load thumbnails asynchronously, then update each item
                    _thumbnailLoader.Load(photo.GetUrl(ThumbnailSize), delegate(Texture texture)
                    {
                        data.Thumbnail = texture;
                        _dataProvider.ItemUpdated(data, "Thumbnail", null, texture);
                    });

                    count++;
                });
            }
            catch (Exception)
            {
                Alert.Show("Error", "No images found", AlertButtonFlag.Ok);
            }
        }
Ejemplo n.º 2
0
        private void DisplayData(object result)
        {
            //Debug.Log("Displaying data");
            string json = ((WWW)result).text; //Debug.Log(json);

            try // deserialize
            {
                PhotosSearchResponse response = (PhotosSearchResponse)JsonReader.Deserialize(json, typeof(PhotosSearchResponse));
                if (response.Stat != "ok")
                {
                    Alert.Show("Error", response.Message, AlertButtonFlag.Ok);
                    return;
                }

                var count = 0;

                // load images
                response.Photos.Photo.ForEach(delegate(Photo photo)
                {
                    var data = new PhotoData(photo.Title)
                    {
                        ImageUrl = photo.GetUrl(ImageSize)
                    };
                    _dataProvider.AddItemAt(data, count); // add it to the beginning off the list

                    // load thumbnails asynchronously, then update each item
                    _thumbnailLoader.Load(photo.GetUrl(ThumbnailSize), delegate(Texture texture)
                    {
                        data.Thumbnail = texture;
                        _dataProvider.ItemUpdated(data, "Thumbnail", null, texture);
                    });

                    count++;
                });
            }
            catch (Exception)
            {
                Alert.Show("Error", "No images found", AlertButtonFlag.Ok);
            }
        }