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


Java FlickrException类代码示例

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


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

示例1: replace

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Upload a photo from an InputStream.
 * 
 * 
 * @param imageName
 * @param in
 * @param photoId
 * @return photoId for sync mode or ticketId for async mode
 * @throws IOException
 * @throws FlickrException
 * @throws SAXException
 * @deprecated This is not working at moment!
 */
public String replace(String imageName, InputStream in, String photoId, boolean async) throws IOException, FlickrException, SAXException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, this.apiKey));

	parameters.add(new Parameter("async", async ? "1" : "0"));
	parameters.add(new Parameter("photo_id", photoId));

	parameters.add(new ImageParameter(imageName, in));
	OAuthUtils.addOAuthToken(parameters);

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

示例2: create

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Create a new photoset.
 * 
 * @param title
 *            The photoset title
 * @param description
 *            The photoset description
 * @param primaryPhotoId
 *            The primary photo id
 * @return The new Photset
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public Photoset create(String title, String description, String primaryPhotoId) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_CREATE));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("title", title));
	parameters.add(new Parameter("description", description));
	parameters.add(new Parameter("primary_photo_id", primaryPhotoId));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
	JSONObject photosetElement = response.getData().getJSONObject("photoset");
	Photoset photoset = new Photoset();
	photoset.setId(photosetElement.getString("id"));
	photoset.setUrl(photosetElement.getString("url"));
	return photoset;
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:35,代码来源:PhotosetsInterface.java

示例3: editMeta

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Modify the meta-data for a photoset.
 * 
 * @param photosetId
 *            The photoset ID
 * @param title
 *            A new title
 * @param description
 *            A new description (can be null)
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public void editMeta(String photosetId, String title, String description) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_EDIT_META));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	parameters.add(new Parameter("title", title));
	if (description != null) {
		parameters.add(new Parameter("description", description));
	}
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:31,代码来源:PhotosetsInterface.java

示例4: editPhotos

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Edit which photos are in the photoset.
 * 
 * @param photosetId
 *            The photoset ID
 * @param primaryPhotoId
 *            The primary photo Id
 * @param photoIds
 *            The photo IDs for the photos in the set
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public void editPhotos(String photosetId, String primaryPhotoId, String[] photoIds) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_EDIT_PHOTOS));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	parameters.add(new Parameter("primary_photo_id", primaryPhotoId));
	parameters.add(new Parameter("photo_ids", StringUtilities.join(photoIds, ",")));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:29,代码来源:PhotosetsInterface.java

示例5: testLogin

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
public User testLogin() throws FlickrException, IOException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_TEST_LOGIN));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));
	OAuthUtils.addOAuthToken(parameters);
	Response response = this.oauthTransport.postJSON(this.sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}

	JSONObject jObj = response.getData();
	JSONObject userObj = jObj.getJSONObject("user");
	String id = userObj.getString("id");
	String name = userObj.getJSONObject("username").getString("_content");
	User user = new User();
	user.setId(id);
	user.setUsername(name);
	return user;
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:20,代码来源:OAuthInterface.java

示例6: handleFlickrUnavailable

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Check if exception e is the cause of Flickr being down and show some toast.
 * @param context
 * @return true if flickr is down
 */
public boolean handleFlickrUnavailable(Context context, Exception e) {
    if (e != null && e instanceof FlickrException) {
        if (((FlickrException) e).getErrorCode().equals(
                Constants.ERR_CODE_FLICKR_UNAVAILABLE)) {
            e.printStackTrace();
            Log.w(TAG, "Flickr seems down at the moment");
            Toast.makeText(context, context.getString(R.string.flickr_unavailable),
                    Toast.LENGTH_LONG).show();
            return true;
        }
    }
    return false;
}
 
开发者ID:brk3,项目名称:glimmr,代码行数:19,代码来源:FlickrHelper.java

示例7: addPhoto

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Add a photo to the end of the photoset.
 * <p/>
 * Note: requires authentication with the new authentication API with 'write' permission.
 * 
 * @param photosetId
 *            The photoset ID
 * @param photoId
 *            The photo ID
 * @throws JSONException
 */
public void addPhoto(String photosetId, String photoId) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_ADD_PHOTO));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	parameters.add(new Parameter("photo_id", photoId));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:26,代码来源:PhotosetsInterface.java

示例8: delete

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Delete the specified photoset.
 * 
 * @param photosetId
 *            The photoset ID
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public void delete(String photosetId) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_DELETE));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:23,代码来源:PhotosetsInterface.java

示例9: getInfo

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Get the information for a specified photoset.
 * 
 * This method does not require authentication.
 * 
 * @param photosetId
 *            The photoset ID
 * @return The Photoset
 * @throws FlickrException
 * @throws IOException
 * @throws JSONException
 */
public Photoset getInfo(String photosetId) throws FlickrException, IOException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_GET_INFO));
	parameters.add(new Parameter("api_key", apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));

	Response response = transportAPI.get(transportAPI.getPath(), parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
	JSONObject photosetElement = response.getData().getJSONObject("photoset");
	Photoset photoset = new Photoset();
	photoset.setId(photosetElement.getString("id"));

	User owner = new User();
	owner.setId(photosetElement.getString("owner"));
	photoset.setOwner(owner);

	Photo primaryPhoto = new Photo();
	primaryPhoto.setId(photosetElement.getString("primary"));
	primaryPhoto.setSecret(photosetElement.getString("secret")); // TODO verify that this is the secret for the photo
	primaryPhoto.setServer(photosetElement.getString("server")); // TODO verify that this is the server for the photo
	primaryPhoto.setFarm(photosetElement.getString("farm"));
	photoset.setPrimaryPhoto(primaryPhoto);

	// TODO remove secret/server/farm from photoset?
	// It's rather related to the primaryPhoto, then to the photoset itself.
	photoset.setSecret(photosetElement.getString("secret"));
	photoset.setServer(photosetElement.getString("server"));
	photoset.setFarm(photosetElement.getString("farm"));
	photoset.setPhotoCount(photosetElement.getString("photos"));

	photoset.setTitle(JSONUtils.getChildValue(photosetElement, "title"));
	photoset.setDescription(JSONUtils.getChildValue(photosetElement, "description"));
	photoset.setPrimaryPhoto(primaryPhoto);

	return photoset;
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:52,代码来源:PhotosetsInterface.java

示例10: orderSets

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Set the order in which sets are returned for the user.
 * 
 * This method requires authentication with 'write' permission.
 * 
 * @param photosetIds
 *            An array of Ids
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public void orderSets(String[] photosetIds) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_ORDER_SETS));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_ids", StringUtilities.join(photosetIds, ",")));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:25,代码来源:PhotosetsInterface.java

示例11: reorderPhotos

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Set the order in which sets are returned for the user.
 * 
 * This method requires authentication with 'write' permission.
 * 
 * @param photosetIds
 *            An array of Ids
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public void reorderPhotos(String photosetId, List<String> photoIds) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_REORDER_PHOTOS));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	parameters.add(new Parameter("photo_ids", StringUtilities.join(photoIds, ",")));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:26,代码来源:PhotosetsInterface.java

示例12: removePhoto

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Remove a photo from the set.
 * 
 * @param photosetId
 *            The photoset ID
 * @param photoId
 *            The photo ID
 * @throws IOException
 * @throws FlickrException
 * @throws JSONException
 */
public void removePhoto(String photosetId, String photoId) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_REMOVE_PHOTO));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	parameters.add(new Parameter("photo_id", photoId));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:26,代码来源:PhotosetsInterface.java

示例13: setPrimaryPhoto

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
public void setPrimaryPhoto(String photosetId, String photoId) throws IOException, FlickrException, JSONException {
	List<Parameter> parameters = new ArrayList<Parameter>();
	parameters.add(new Parameter("method", METHOD_SET_PRIMARY_PHOTO));
	parameters.add(new Parameter(OAuthInterface.PARAM_OAUTH_CONSUMER_KEY, apiKey));

	parameters.add(new Parameter("photoset_id", photosetId));
	parameters.add(new Parameter("photo_id", photoId));
	OAuthUtils.addOAuthToken(parameters);

	Response response = transportAPI.postJSON(sharedSecret, parameters);
	if (response.isError()) {
		throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:15,代码来源:PhotosetsInterface.java

示例14: getOriginalUrl

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
/**
 * Get the original image URL.
 * 
 * @return The original image URL
 */
public String getOriginalUrl() throws FlickrException {
	if (originalSize == null) {
		if (originalFormat != null) {
			return getOriginalBaseImageUrl() + "_o." + originalFormat;
		}
		return getOriginalBaseImageUrl() + DEFAULT_ORIGINAL_IMAGE_SUFFIX;
	} else {
		return originalSize.getSource();
	}
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:16,代码来源:Photo.java

示例15: getOriginalBaseImageUrl

import com.googlecode.flickrjandroid.FlickrException; //导入依赖的package包/类
private StringBuffer getOriginalBaseImageUrl() throws FlickrException, NullPointerException {
	StringBuffer buffer = new StringBuffer();
	buffer.append(_getBaseImageUrl());
	if (getOriginalSecret().length() > 8) {
		buffer.append(getOriginalSecret());
	} else {
		throw new FlickrException("0", "OriginalUrl not available because of missing originalsecret.");
	}
	return buffer;
}
 
开发者ID:rafali,项目名称:flickr-uploader,代码行数:11,代码来源:Photo.java


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