Search in sources :

Example 11 with Flickr

use of com.googlecode.flickrjandroid.Flickr in project glimmr by brk3.

the class StackRemoteViewsFactory method getContactsPhotos.

private List<Photo> getContactsPhotos() throws Exception {
    OAuthToken token = mOAuth.getToken();
    Flickr f = FlickrHelper.getInstance().getFlickrAuthed(token.getOauthToken(), token.getOauthTokenSecret());
    boolean justFriends = false;
    boolean singlePhoto = false;
    boolean includeSelf = false;
    return f.getPhotosInterface().getContactsPhotos(Constants.FETCH_PER_PAGE, Constants.EXTRAS, justFriends, singlePhoto, includeSelf, PAGE, Constants.FETCH_PER_PAGE);
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr)

Example 12 with Flickr

use of com.googlecode.flickrjandroid.Flickr in project glimmr by brk3.

the class StackRemoteViewsFactory method getUserPhotos.

private List<Photo> getUserPhotos() throws Exception {
    OAuthToken token = mOAuth.getToken();
    Flickr f = FlickrHelper.getInstance().getFlickrAuthed(token.getOauthToken(), token.getOauthTokenSecret());
    return f.getPeopleInterface().getPhotos(mUser.getId(), Constants.EXTRAS, Constants.FETCH_PER_PAGE, PAGE);
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr)

Example 13 with Flickr

use of com.googlecode.flickrjandroid.Flickr in project glimmr by brk3.

the class AddItemToPhotosetTask method execute.

@Override
public void execute(final ITaskQueueServiceListener listener) {
    if (BuildConfig.DEBUG) {
        Log.d(TAG, String.format("Processing photo id %s for photoset %s", mItemId, mPhotosetId));
    }
    if (mOAuth == null) {
        Log.e(TAG, "AddItemToPhotosetTask requires authentication");
        MAIN_THREAD.post(new Runnable() {

            @Override
            public void run() {
                listener.onFailure(mItemId, false);
            }
        });
        return;
    }
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                OAuthToken token = mOAuth.getToken();
                Flickr f = FlickrHelper.getInstance().getFlickrAuthed(token.getOauthToken(), token.getOauthTokenSecret());
                try {
                    f.getPhotosetsInterface().addPhoto(mPhotosetId, mItemId);
                    /* success */
                    postToMainThread(listener, true, false);
                } catch (FlickrException e) {
                    e.printStackTrace();
                    final String errCode = e.getErrorCode();
                    /* any of the following warrants no retry */
                    if (FLICKR_PHOTOSET_NOT_FOUND.equals(errCode) || FLICKR_PHOTO_NOT_FOUND.equals(errCode) || FLICKR_PHOTO_ALREADY_IN_SET.equals(errCode) || FLICKR_PHOTOSET_FULL.equals(errCode)) {
                        postToMainThread(listener, false, false);
                    } else {
                        Log.e(TAG, "Unknown FlickrException code: " + errCode);
                        postToMainThread(listener, false, false);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    /* failure, queue for retry */
                    postToMainThread(listener, false, true);
                } catch (IOException e) {
                    e.printStackTrace();
                    /* failure, queue for retry */
                    postToMainThread(listener, false, true);
                } catch (Exception e) {
                    e.printStackTrace();
                    /* shouldn't get here, don't retry */
                    postToMainThread(listener, false, false);
                }
            } catch (RuntimeException e) {
                e.printStackTrace();
                /* shouldn't get here, don't retry */
                postToMainThread(listener, false, false);
            }
        }
    }).start();
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr) FlickrException(com.googlecode.flickrjandroid.FlickrException) JSONException(org.json.JSONException) IOException(java.io.IOException) FlickrException(com.googlecode.flickrjandroid.FlickrException) IOException(java.io.IOException) JSONException(org.json.JSONException)

Example 14 with Flickr

use of com.googlecode.flickrjandroid.Flickr in project glimmr by brk3.

the class GetAccessTokenTask method doInBackground.

@Override
protected OAuth doInBackground(String... params) {
    String oauthToken = params[0];
    String oauthTokenSecret = params[1];
    String verifier = params[2];
    Flickr f = FlickrHelper.getInstance().getFlickr();
    OAuthInterface oauthApi = f.getOAuthInterface();
    try {
        return oauthApi.getAccessToken(oauthToken, oauthTokenSecret, verifier);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : Flickr(com.googlecode.flickrjandroid.Flickr) OAuthInterface(com.googlecode.flickrjandroid.oauth.OAuthInterface)

Example 15 with Flickr

use of com.googlecode.flickrjandroid.Flickr in project glimmr by brk3.

the class GetRequestToken method doInBackground.

@Override
protected String doInBackground(Void... params) {
    try {
        Flickr f = FlickrHelper.getInstance().getFlickr();
        OAuthToken oauthToken = f.getOAuthInterface().getRequestToken(mOAuthCallbackUri.toString());
        saveRequestToken(oauthToken.getOauthTokenSecret());
        URL oauthUrl = f.getOAuthInterface().buildAuthenticationUrl(Permission.WRITE, oauthToken);
        return oauthUrl.toString();
    } catch (Exception e) {
        e.printStackTrace();
        mException = e;
    }
    return null;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr) URL(java.net.URL)

Aggregations

Flickr (com.googlecode.flickrjandroid.Flickr)21 OAuthToken (com.googlecode.flickrjandroid.oauth.OAuthToken)19 OAuth (com.googlecode.flickrjandroid.oauth.OAuth)12 FlickrException (com.googlecode.flickrjandroid.FlickrException)3 IOException (java.io.IOException)3 SearchParameters (com.googlecode.flickrjandroid.photos.SearchParameters)2 JSONException (org.json.JSONException)2 Background (com.alexvasilkov.events.Events.Background)1 Subscribe (com.alexvasilkov.events.Events.Subscribe)1 RequestContext (com.googlecode.flickrjandroid.RequestContext)1 OAuthInterface (com.googlecode.flickrjandroid.oauth.OAuthInterface)1 Photo (com.googlecode.flickrjandroid.photos.Photo)1 PhotoList (com.googlecode.flickrjandroid.photos.PhotoList)1 FileInputStream (java.io.FileInputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1