photoCount = 1;
//
// Connect to flickr
//
Flickr flickr = new Flickr( this._api_key, this._api_secret, rest );
PhotoList newPhotoList = null;
String userToken = Program.getProperty( "flickr.userToken" );
String sPhotosets = Program.getProperty( "flickr.photosets" );
if( sPhotosets != "" )
{
PhotosetsInterface photosetsI = flickr.getPhotosetsInterface();
Photosets photosets = null;
try
{
photosets = photosetsI.getList(userToken);
}
catch (Exception e) //IOException e2, SAXException e2, FlickrException e2) {
{
e.printStackTrace();
return null;
}
if( photosets != null )
{
// If we have a list of photosets, just get the photos from there.
@SuppressWarnings("unchecked")
Collection<Photoset> photosetCollection = photosets.getPhotosets();
PhotoList photosetsPhotoList = new PhotoList();
String[] photosetsNamesArray = sPhotosets.split(";");
int photosetsPhotoCount = photoCount / photosetsNamesArray.length;
int photosetsPhotoCountExtra = 0;
for( Photoset photoset : photosetCollection )
{
String photosetName = photoset.getTitle();
for( int i = 0; i<photosetsNamesArray.length;i++)
{
if( photosetsNamesArray[i] != "" &&
photosetsNamesArray[i].compareToIgnoreCase(photosetName) == 0 )
{
PhotoList photoList = null;
try
{
photoList = photosetsI.getPhotos(photoset.getId(), photosetsPhotoCount + photosetsPhotoCountExtra, 1);
}
catch( Exception e) //catch (IOException e), catch (SAXException e), catch (FlickrException e)
{
e.printStackTrace();
return null;
}
if( photoList != null )
{
@SuppressWarnings("unchecked")
Iterator<com.aetrion.flickr.photos.Photo> p = (Iterator<com.aetrion.flickr.photos.Photo>)photoList.iterator();
int photosAdded = 0;
for(; p.hasNext();)
{
com.aetrion.flickr.photos.Photo photo = p.next();
if( ! photosetsPhotoList.contains(photo) )
{
photosetsPhotoList.add(photo);
photosAdded++;
}
}
photosetsPhotoCountExtra += photosetsPhotoCount - photosAdded;
}
}
}
}
newPhotoList = photosetsPhotoList;
}
}
else
{
PeopleInterface pi = flickr.getPeopleInterface();
try
{
newPhotoList = pi.getPublicPhotos(userToken, photoCount,1);
}