当前位置: 首页>>代码示例>>Java>>正文


Java PhotoList.isEmpty方法代码示例

本文整理汇总了Java中com.flickr4java.flickr.photos.PhotoList.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java PhotoList.isEmpty方法的具体用法?Java PhotoList.isEmpty怎么用?Java PhotoList.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.flickr4java.flickr.photos.PhotoList的用法示例。


在下文中一共展示了PhotoList.isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retrieveAccountFeed

import com.flickr4java.flickr.photos.PhotoList; //导入方法依赖的package包/类
@Override
public Response retrieveAccountFeed(AccountFeed feed, Integer maxRequests) {
	
	Response response = new Response();
	List<Post> items = new ArrayList<Post>();
	
	Date dateToRetrieve = feed.getSinceDate();
	String label = feed.getLabel();
	
	int page=1, pages=1; //pagination
	int numberOfRequests = 0;
	
	//Here we search the user by the userId given (NSID) - 
	// however we can get NSID via flickrAPI given user's username
	String userID = feed.getId();
	
	if(userID == null) {
		logger.info("#Flickr : No source feed");
		return response;
	}
	
	PhotosInterface photosInteface = flickr.getPhotosInterface();
	SearchParameters params = new SearchParameters();
	params.setUserId(userID);
	params.setMinUploadDate(dateToRetrieve);
	
	Set<String> extras = new HashSet<String>(Extras.ALL_EXTRAS);
	extras.remove(Extras.MACHINE_TAGS);
	params.setExtras(extras);
	
	while(page<=pages && numberOfRequests<=maxRequests) {
		
		PhotoList<Photo> photos;
		try {
			numberOfRequests++;
			photos = photosInteface.search(params , PER_PAGE, page++);
		} catch (Exception e) {
			break;
		}
		
		pages = photos.getPages();

		if(photos.isEmpty()) {
			break;
		}
	
		for(Photo photo : photos) {

			String userid = photo.getOwner().getId();
			UserAccount streamUser = userMap.get(userid);
			if(streamUser == null) {
				streamUser = getStreamUser(userid);
				userMap.put(userid, streamUser);
			}

			FlickrPost flickrItem = new FlickrPost(photo);
			flickrItem.setLabel(label);
			
			items.add(flickrItem);
		}
	}
	
	response.setPosts(items);
	response.setRequests(numberOfRequests);
	return response;
}
 
开发者ID:MKLab-ITI,项目名称:simmo-stream-manager,代码行数:67,代码来源:FlickrRetriever.java

示例2: retrieveUserFeeds

import com.flickr4java.flickr.photos.PhotoList; //导入方法依赖的package包/类
@Override
	public List<Item> retrieveUserFeeds(SourceFeed feed) {
		
		List<Item> items = new ArrayList<Item>();
		
		long currRunningTime = System.currentTimeMillis();
		
		Date dateToRetrieve = feed.getDateToRetrieve();
		String label = feed.getLabel();
		
		int page=1, pages=1; //pagination
		int numberOfRequests = 0;
		int numberOfResults = 0;
		
		//Here we search the user by the userId given (NSID) - 
		// however we can get NSID via flickrAPI given user's username
		Source source = feed.getSource();
		String userID = source.getId();
		
		if(userID == null) {
			logger.info("#Flickr : No source feed");
			return items;
		}
		
		PhotosInterface photosInteface = flickr.getPhotosInterface();
		SearchParameters params = new SearchParameters();
		params.setUserId(userID);
		params.setMinUploadDate(dateToRetrieve);
		
		Set<String> extras = new HashSet<String>(Extras.ALL_EXTRAS);
		extras.remove(Extras.MACHINE_TAGS);
		params.setExtras(extras);
		
		while(page<=pages && numberOfRequests<=maxRequests && numberOfResults<=maxResults &&
				(System.currentTimeMillis()-currRunningTime)<maxRunningTime) {
			
			PhotoList<Photo> photos;
			try {
				numberOfRequests++;
				photos = photosInteface.search(params , PER_PAGE, page++);
			} catch (Exception e) {
				break;
			}
			
			pages = photos.getPages();
			numberOfResults += photos.size();

			if(photos.isEmpty()) {
				break;
			}
		
			for(Photo photo : photos) {

				String userid = photo.getOwner().getId();
				StreamUser streamUser = userMap.get(userid);
				if(streamUser == null) {
					streamUser = getStreamUser(userid);
					userMap.put(userid, streamUser);
				}

				FlickrItem flickrItem = new FlickrItem(photo, streamUser);
				flickrItem.setList(label);
				
				items.add(flickrItem);
			}
		}
		
		//logger.info("#Flickr : Done retrieving for this session");
//		logger.info("#Flickr : Handler fetched " + items.size() + " photos from " + userID + 
//				" [ " + lastItemDate + " - " + new Date(System.currentTimeMillis()) + " ]");
		
		// The next request will retrieve only items of the last day
		dateToRetrieve = new Date(System.currentTimeMillis() - (24*3600*1000));
		feed.setDateToRetrieve(dateToRetrieve);
		
		return items;
	}
 
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:78,代码来源:FlickrRetriever.java

示例3: retrieveLocationFeeds

import com.flickr4java.flickr.photos.PhotoList; //导入方法依赖的package包/类
@Override
public List<Item> retrieveLocationFeeds(LocationFeed feed){
	
	List<Item> items = new ArrayList<Item>();
	
	long currRunningTime = System.currentTimeMillis();
	
	Date dateToRetrieve = feed.getDateToRetrieve();
	String label = feed.getLabel();
	
	Double[][] bbox = feed.getLocation().getbbox();
	
	if(bbox == null || bbox.length==0)
		return items;
	
	int page=1, pages=1;
	int numberOfRequests = 0;
	int numberOfResults = 0;
	
	PhotosInterface photosInteface = flickr.getPhotosInterface();
	SearchParameters params = new SearchParameters();
	params.setBBox(bbox[0][0].toString(), bbox[0][1].toString(), bbox[1][0].toString(), bbox[1][1].toString());
	params.setMinUploadDate(dateToRetrieve);
	
	Set<String> extras = new HashSet<String>(Extras.ALL_EXTRAS);
	extras.remove(Extras.MACHINE_TAGS);
	params.setExtras(extras);
	
	while(page<=pages && numberOfRequests<=maxRequests && numberOfResults<=maxResults &&
			(System.currentTimeMillis()-currRunningTime)<maxRunningTime) {
		
		PhotoList<Photo> photos;
		try {
			photos = photosInteface.search(params , PER_PAGE, page++);
		} catch (FlickrException e) {
			break;
		}
		
		pages = photos.getPages();
		numberOfResults += photos.size();

		if(photos.isEmpty()) {
			break;
		}
	
		for(Photo photo : photos) {

			String userid = photo.getOwner().getId();
			StreamUser streamUser = userMap.get(userid);
			if(streamUser == null) {
				streamUser = getStreamUser(userid);

				userMap.put(userid, streamUser);
			}

			FlickrItem flickrItem = new FlickrItem(photo, streamUser);
			flickrItem.setList(label);
			
			items.add(flickrItem);
		}
	}
	
	logger.info("#Flickr : Handler fetched " + items.size() + " photos "+ 
			" [ " + dateToRetrieve + " - " + new Date(System.currentTimeMillis()) + " ]");
	
	return items;
   }
 
开发者ID:socialsensor,项目名称:socialmedia-abstractions,代码行数:68,代码来源:FlickrRetriever.java


注:本文中的com.flickr4java.flickr.photos.PhotoList.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。