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);
}
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);
}
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();
}
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;
}
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;
}
Aggregations