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


Java REST类代码示例

本文整理汇总了Java中com.googlecode.flickrjandroid.REST的典型用法代码示例。如果您正苦于以下问题:Java REST类的具体用法?Java REST怎么用?Java REST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: dequeue

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
public static void dequeue(Collection<Media> medias) {
	int nbDequeued = 0;
	Transaction t = new Transaction();
	try {
		for (final Media media : medias) {
			if (media.isQueued()) {
				LOG.debug("dequeueing " + media);
				media.setStatus(STATUS.PAUSED, t);
				nbDequeued++;
				if (media.equals(mediaCurrentlyUploading)) {
					REST.kill(media);
				}
			}
		}
		t.setSuccessful(true);
	} finally {
		t.finish();
	}
	if (nbDequeued > 0) {
		checkQueue();
		for (UploadProgressListener uploadProgressListener : uploadProgressListeners) {
			uploadProgressListener.onDequeued(nbDequeued);
		}
	}
	wake();
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:27,代码来源:UploadService.java

示例2: getFlickr

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
public Flickr getFlickr() {
	try {
		Flickr f = new Flickr(API_KEY, API_SEC, new REST());
		return f;
	} catch (ParserConfigurationException e) {
		return null;
	}
}
 
开发者ID:fwingy,项目名称:LittleFlickr,代码行数:9,代码来源:FlickrHelper.java

示例3: getFlickr

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
public Flickr getFlickr() {
    try {
        return new Flickr(Keys.API_KEY, Keys.API_SECRET, new REST());
    } catch (ParserConfigurationException e) {
        return null;
    }
}
 
开发者ID:brk3,项目名称:glimmr,代码行数:8,代码来源:FlickrHelper.java

示例4: Uploader

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
/**
 * Construct an Uploader.
 * 
 * @param apiKey
 *            The API key
 */
public Uploader(String apiKey, String sharedSecret) {
	try {
		this.apiKey = apiKey;
		this.sharedSecret = sharedSecret;
		this.transport = new REST(Flickr.DEFAULT_API_HOST);
		this.transport.setResponseClass(UploaderResponse.class);
	} catch (ParserConfigurationException e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:17,代码来源:Uploader.java

示例5: clear

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
public static void clear(final int status, final Callback<Void> callback) {
	if (status == STATUS.FAILED || status == STATUS.QUEUED) {
		BackgroundExecutor.execute(new Runnable() {
			@Override
			public void run() {
				int nbModified = 0;
				List<Media> medias = Utils.loadMedia(false);
				Transaction t = new Transaction();
				try {
					for (final Media media : medias) {
						if (media.getStatus() == status) {
							if (media.isQueued() && media.equals(mediaCurrentlyUploading)) {
								REST.kill(media);
							}
							media.setStatus(STATUS.PAUSED, t);
							nbModified++;
						}
					}
					t.setSuccessful(true);
				} finally {
					t.finish();
				}
				if (nbModified > 0) {
					checkQueue();
				}
				if (callback != null)
					callback.onResult(null);
			}
		});
	} else {
		LOG.error("status " + status + " is not supported");
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:34,代码来源:UploadService.java

示例6: upload

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
/**
	 * Upload a photo from an InputStream.
	 * 
	 * @param in
	 * @param metaData
	 * @return photoId for sync mode or ticketId for async mode
	 * @throws IOException
	 * @throws FlickrException
	 * @throws SAXException
	 */
	public String upload(String imageName, File file, UploadMetaData metaData, Media media) throws IOException, FlickrException, SAXException {
		List<Parameter> parameters = new ArrayList<Parameter>();
		parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, this.apiKey));

		String title = metaData.getTitle();
		if (title != null)
			parameters.add(new Parameter("title", title));

		String description = metaData.getDescription();
		if (description != null)
			parameters.add(new Parameter("description", description));

		Collection<String> tags = metaData.getTags();
		if (tags != null) {
			parameters.add(new Parameter("tags", StringUtilities.join(tags, " ")));
		}

		parameters.add(new Parameter("is_public", metaData.isPublicFlag() ? "1" : "0"));
		parameters.add(new Parameter("is_family", metaData.isFamilyFlag() ? "1" : "0"));
		parameters.add(new Parameter("is_friend", metaData.isFriendFlag() ? "1" : "0"));
		parameters.add(new Parameter("async", metaData.isAsync() ? "1" : "0"));
		if (metaData.getSafetyLevel() != null) {
			parameters.add(new Parameter("safety_level", metaData.getSafetyLevel()));
		}
		if (metaData.getContentType() != null) {
			parameters.add(new Parameter("content_type", metaData.getContentType()));
		}

		parameters.add(new ImageParameter(imageName, file));
		OAuthUtils.addOAuthToken(parameters);
		OAuthUtils.addOAuthParams(sharedSecret, Uploader.URL_UPLOAD, parameters);
		UploaderResponse response = (UploaderResponse) ((REST) transport).sendUpload(Uploader.UPLOAD_PATH, parameters, media);

//		UploaderResponse response = (UploaderResponse) ((REST) transport).upload(sharedSecret, parameters, progressListener);
		if (response.isError()) {
			throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
		}
		String id = "";
		if (metaData.isAsync()) {
			id = response.getTicketId();
		} else {
			id = response.getPhotoId();
		}
		return id;
	}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:56,代码来源:Uploader.java

示例7: OAuthInterface

import com.googlecode.flickrjandroid.REST; //导入依赖的package包/类
/**
 * Construct the AuthInterface.
 * 
 * @param apiKey
 *            The API key
 * @param transport
 *            The Transport interface
 */
public OAuthInterface(String apiKey, String sharedSecret, Transport transport) {
	this.apiKey = apiKey;
	this.sharedSecret = sharedSecret;
	this.oauthTransport = (REST) transport;
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:14,代码来源:OAuthInterface.java


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