Search in sources :

Example 11 with OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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 OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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 OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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 OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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)

Example 15 with OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken in project glimmr by brk3.

the class LoadGroupInfoTask method doInBackground.

@Override
protected Group doInBackground(OAuth... params) {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "Starting LoadGroupInfoTask");
    OAuth oauth = params[0];
    if (oauth != null) {
        if (BuildConfig.DEBUG)
            Log.d(TAG, "Authenticated call");
        OAuthToken token = oauth.getToken();
        Flickr f = FlickrHelper.getInstance().getFlickrAuthed(token.getOauthToken(), token.getOauthTokenSecret());
        try {
            return f.getGroupsInterface().getInfo(mGroupId);
        } catch (Exception e) {
            e.printStackTrace();
            mException = e;
        }
    } else {
        if (BuildConfig.DEBUG)
            Log.d(TAG, "Unauthenticated call");
        try {
            return FlickrHelper.getInstance().getGroupsInterface().getInfo(mGroupId);
        } catch (Exception e) {
            e.printStackTrace();
            mException = e;
        }
    }
    return null;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr) OAuth(com.googlecode.flickrjandroid.oauth.OAuth)

Aggregations

OAuthToken (com.googlecode.flickrjandroid.oauth.OAuthToken)21 Flickr (com.googlecode.flickrjandroid.Flickr)19 OAuth (com.googlecode.flickrjandroid.oauth.OAuth)13 FlickrException (com.googlecode.flickrjandroid.FlickrException)3 IOException (java.io.IOException)3 SharedPreferences (android.content.SharedPreferences)2 User (com.googlecode.flickrjandroid.people.User)2 JSONException (org.json.JSONException)2 RequestContext (com.googlecode.flickrjandroid.RequestContext)1 SearchParameters (com.googlecode.flickrjandroid.photos.SearchParameters)1 FileInputStream (java.io.FileInputStream)1 URL (java.net.URL)1 Date (java.util.Date)1