Java Reference
In-Depth Information
All properties in this
Value
can be used either by key (for example,
item.created
or
item.title
)orbyindex(
item.content[0][1]
[0]
), in the same way as a multidimensional array in Java. In our example,
we are interested in object
item.content[3][1][1]
, which has the
url
attribute pointing to the actual picture address in Flickr's services.
Once we understand exactly what we are fetching, the rest of the work is
easy: create a new
Flow
object, add header text, loop through the
Value
structure, getting each item's photo URL, and call the
getPicture()
method, from the API class. This method asynchronously downloads
each image, scales it to the screen width and 1/3 of the screen height
and places it on the
Flow
object. The
getPicture()
method calls the
server-side Image Service, which downloads images from the web and
scales them to fit the screen of a mobile device.
Once we are done downloading the pictures, we use API's
push-
Shell()
method to display the list of images to the users, filtered by
the search criteria and nicely scaled to fit the mobile phone screen.
Figure A.9 shows the output of a search for 'puppies'.
Users can perform a new search by pressing Back, which is handled by
actionPerformed()
and pops this view from the shell stack, returning
to the previous, Form, view.
Now that you have finished developing Flickr Viewer, you can publish
the widget so that all the WidSets community can use it. There are two
ways to do that: zip the contents of the
flickr_viewer
folder and
upload it to the website by clicking the Create a new widget/upload
menu item, or go directly to Publish to library, select Flickr Viewer from
the list and click on Publish. Keep in mind that this only works if you
have been using your own account for development.
Figure A.9
A list of puppy images