Search in sources :

Example 1 with FlickrPhotoClient

use of io.jawg.osmcontributor.flickr.rest.FlickrPhotoClient in project osm-contributor by jawg.

the class PhotoActivity method setPhotoLocation.

private void setPhotoLocation(final String photoId) {
    if (flickrPhotoClient == null) {
        flickrPhotoClient = FlickrPhotoUtils.getAdapter().create(FlickrPhotoClient.class);
    }
    OAuthRequest oauthRequest = new OAuthRequest(configManager.getFlickrApiKey(), configManager.getFlickrApiKeySecret());
    oauthRequest.setRequestUrl(FLICKR_API_SERVICES);
    oauthRequest.setOAuthToken(configManager.getFlickrToken());
    oauthRequest.setOAuthTokenSecret(configManager.getFlickrTokenSecret());
    oauthRequest.initParam(OAuthParams.getOAuthParams().put(OAuthParams.OAUTH_TOKEN, configManager.getFlickrToken()).put("method", "flickr.photos.geo.setLocation").put("photo_id", photoId).put("lat", String.valueOf(latitude)).put("lon", String.valueOf(longitude)).toMap());
    oauthRequest.signRequest(Verb.GET);
    flickrPhotoClient.setProperties(oauthRequest.getParams()).enqueue(new Callback<String>() {

        @Override
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                try {
                    setPhotoTag(photoId);
                } catch (UnsupportedEncodingException e) {
                    onFailure(call, new RuntimeException(e));
                }
            }
        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            Toast.makeText(PhotoActivity.this, R.string.picture_sent_failure, Toast.LENGTH_LONG).show();
            progressDialog.dismiss();
        }
    });
}
Also used : OAuthRequest(io.jawg.osmcontributor.flickr.oauth.OAuthRequest) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FlickrPhotoClient(io.jawg.osmcontributor.flickr.rest.FlickrPhotoClient)

Example 2 with FlickrPhotoClient

use of io.jawg.osmcontributor.flickr.rest.FlickrPhotoClient in project osm-contributor by jawg.

the class PhotoActivity method onUploadFinishedEvent.

public void onUploadFinishedEvent(final String photoId) {
    // Retrieve picture URL
    if (flickrPhotoClient == null) {
        flickrPhotoClient = FlickrPhotoUtils.getAdapter().create(FlickrPhotoClient.class);
    }
    OAuthRequest oauthRequest = new OAuthRequest(configManager.getFlickrApiKey(), configManager.getFlickrApiKeySecret());
    oauthRequest.setRequestUrl(FLICKR_API_SERVICES);
    oauthRequest.setOAuthToken(configManager.getFlickrToken());
    oauthRequest.setOAuthTokenSecret(configManager.getFlickrTokenSecret());
    oauthRequest.initParam(OAuthParams.getOAuthParams().put(OAuthParams.OAUTH_TOKEN, configManager.getFlickrToken()).put("method", "flickr.photos.getInfo").put("photo_id", photoId).toMap());
    oauthRequest.signRequest(Verb.GET);
    flickrPhotoClient.setProperties(oauthRequest.getParams()).enqueue(new Callback<String>() {

        @Override
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                defineImageOnPoi(ResponseConverter.convertImageUrl(response.body()));
                setPhotoLocation(photoId);
            }
        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            Toast.makeText(PhotoActivity.this, R.string.flickr_communication_failure, Toast.LENGTH_LONG).show();
            progressDialog.dismiss();
        }
    });
}
Also used : OAuthRequest(io.jawg.osmcontributor.flickr.oauth.OAuthRequest) FlickrPhotoClient(io.jawg.osmcontributor.flickr.rest.FlickrPhotoClient)

Aggregations

OAuthRequest (io.jawg.osmcontributor.flickr.oauth.OAuthRequest)2 FlickrPhotoClient (io.jawg.osmcontributor.flickr.rest.FlickrPhotoClient)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1