com.googlecode.flickrjandroid.oauth.OAuth Java Examples
The following examples show how to use
com.googlecode.flickrjandroid.oauth.OAuth.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginFragment.java From glimmr with Apache License 2.0 | 6 votes |
@Override public void onAccessTokenReady(OAuth accessToken) { if (accessToken == null) { LoginErrorDialog.show(mActivity); return; } persistAccessToken(accessToken); if (BuildConfig.DEBUG) { Log.d(TAG, "Got token, saved to disk, good to start MainActivity"); } Toast.makeText(mActivity, getString(R.string.logged_in), Toast.LENGTH_SHORT).show(); /* Prevent the user pressing back to get to the unauthed activity */ Intent intent = new Intent(mActivity, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); mActivity.finish(); mActivity.startActivity(intent); }
Example #2
Source File: GetAccessTokenTask.java From glimmr with Apache License 2.0 | 6 votes |
@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; }
Example #3
Source File: AddCommentTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected String doInBackground(OAuth... params) { OAuth oauth = params[0]; if (oauth != null) { OAuthToken token = oauth.getToken(); try { Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); return f.getCommentsInterface().addComment(mPhoto.getId(), mCommentText); } catch (Exception e) { e.printStackTrace(); mException = e; } } else { Log.e(TAG, "AddCommentTask requires authentication"); } return null; }
Example #4
Source File: LoadContactsPhotosTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected List<Photo> doInBackground(OAuth... params) { OAuth oauth = params[0]; if (oauth != null) { OAuthToken token = oauth.getToken(); Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); try { return f.getPhotosInterface().getContactsPhotos( Constants.FETCH_PER_PAGE, Constants.EXTRAS, false, false, false, mPage, Constants.FETCH_PER_PAGE); } catch (Exception e) { e.printStackTrace(); mException = e; } } else { Log.e(TAG, "LoadContactsPhotosTask requires authentication"); } return null; }
Example #5
Source File: LoadGroupsTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected Collection<Group> doInBackground(OAuth... params) { OAuth oauth = params[0]; if (oauth != null) { OAuthToken token = oauth.getToken(); Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); try { return f.getPoolsInterface().getGroups(); } catch (Exception e) { e.printStackTrace(); mException = e; } } else { Log.e(TAG, "LoadGroupsTask requires authentication"); } return null; }
Example #6
Source File: SetFavoriteTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected Exception doInBackground(OAuth... params) { OAuth oauth = params[0]; if (oauth != null) { OAuthToken token = oauth.getToken(); Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); try { if (mPhoto.isFavorite()) { f.getFavoritesInterface().remove(mPhoto.getId()); } else { f.getFavoritesInterface().add(mPhoto.getId()); } } catch (Exception e) { e.printStackTrace(); return e; } } else { Log.e(TAG, "SetFavoriteTask requires authentication"); } return null; }
Example #7
Source File: LoadFlickrActivityTask.java From glimmr with Apache License 2.0 | 6 votes |
@Override protected List<Item> doInBackground(OAuth... params) { OAuth oauth = params[0]; if (oauth != null) { OAuthToken token = oauth.getToken(); try { Flickr f = FlickrHelper.getInstance().getFlickrAuthed( token.getOauthToken(), token.getOauthTokenSecret()); String timeFrame = "100d"; int page = 1; return f.getActivityInterface().userPhotos( Constants.FETCH_PER_PAGE, page, timeFrame); } catch (Exception e) { e.printStackTrace(); mException = e; } } else { Log.e(TAG, "LoadFlickrActivityTask requires authentication"); } return null; }
Example #8
Source File: LoginFragment.java From glimmr with Apache License 2.0 | 5 votes |
private void persistAccessToken(OAuth oauth) { SharedPreferences sp = mActivity.getSharedPreferences( Constants.PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); OAuthToken token = oauth.getToken(); User user = oauth.getUser(); editor.putString(Constants.KEY_OAUTH_TOKEN, token.getOauthToken()); editor.putString(Constants.KEY_TOKEN_SECRET, token .getOauthTokenSecret()); editor.putString(Constants.KEY_ACCOUNT_USER_NAME, user.getUsername()); editor.putString(Constants.KEY_ACCOUNT_USER_ID, user.getId()); editor.commit(); }
Example #9
Source File: FlickrApi.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
private static void updateOauth() { String accessToken = Utils.getStringProperty(STR.accessToken); String accessTokenSecret = Utils.getStringProperty(STR.accessTokenSecret); authentified = ToolString.isNotBlank(accessToken) && ToolString.isNotBlank(accessTokenSecret); auth = new OAuth(); auth.setToken(new OAuthToken(accessToken, accessTokenSecret)); }
Example #10
Source File: OAuthActivity.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
private void verifyPin(String pin) { if (mOAuthToken == null) { return; } new AsyncTask<String, Void, Boolean>() { protected Boolean doInBackground(String[] params) { try { OAuthInterface oauthApi = mFlickr.getOAuthInterface(); OAuth oauth = oauthApi.getAccessToken( mOAuthToken.getOauthToken(), mOAuthToken.getOauthTokenSecret(), params[0]); saveOAuthToken(oauth.getUser().getUsername(), oauth .getUser().getId(), oauth.getToken() .getOauthToken(), oauth.getToken() .getOauthTokenSecret()); return true; } catch (Exception e) { e.printStackTrace(); } return false; }; @Override protected void onPostExecute(Boolean result) { if (result) { String userName = getUserName(); Toast.makeText(This(), "OAuth OK!:" + userName, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(This(), "OAuth Failed!", Toast.LENGTH_SHORT) .show(); } } }.execute(pin); }
Example #11
Source File: FlickrHelper.java From glimmr with Apache License 2.0 | 5 votes |
public Flickr getFlickrAuthed(String token, String secret) { Flickr f = getFlickr(); RequestContext requestContext = RequestContext.getRequestContext(); OAuth auth = new OAuth(); auth.setToken(new OAuthToken(token, secret)); requestContext.setOAuth(auth); return f; }
Example #12
Source File: AppService.java From glimmr with Apache License 2.0 | 5 votes |
/** * Essentially like a crontab entry, what gets executed periodically. */ @Override protected void doWakefulWork(Intent intent) { if (BuildConfig.DEBUG) Log.d(TAG, "doWakefulWork"); /* Fetch the oauth token from storage */ OAuth oauth = OAuthUtils.loadAccessToken(this); if (oauth == null) { if (BuildConfig.DEBUG) { Log.d(TAG, "doWakefulWork: no stored oauth token found, " + "doing nothing"); } return; } /* Important: add each handler to be run here */ List<GlimmrNotificationHandler> handlers = new ArrayList<GlimmrNotificationHandler>(); handlers.add(new ContactsPhotosNotificationHandler(this)); handlers.add(new ActivityNotificationHandler(this)); /* Start each handler */ for (GlimmrNotificationHandler handler : handlers) { if (handler.enabledInPreferences()) { handler.startTask(oauth); } } }
Example #13
Source File: LoadPhotosetTask.java From glimmr with Apache License 2.0 | 5 votes |
@Override protected Photoset doInBackground(OAuth... params) { try { return FlickrHelper.getInstance().getPhotosetsInterface() .getInfo(mId); } catch (Exception e) { e.printStackTrace(); mException = e; } return null; }
Example #14
Source File: ActivityNotificationHandler.java From glimmr with Apache License 2.0 | 4 votes |
@Override public void startTask(OAuth oauth) { mOAuth = oauth; new LoadFlickrActivityTask(this).execute(oauth); }
Example #15
Source File: AddItemToGroupTask.java From glimmr with Apache License 2.0 | 4 votes |
public AddItemToGroupTask(String groupId, String itemId, OAuth oauth) { mGroupId = groupId; mItemId = itemId; mOAuth = oauth; }
Example #16
Source File: ContactsPhotosNotificationHandler.java From glimmr with Apache License 2.0 | 4 votes |
@Override public void startTask(OAuth oauth) { new LoadContactsPhotosTask(this, PAGE_TO_FETCH).execute(oauth); }
Example #17
Source File: AddItemToPhotosetTask.java From glimmr with Apache License 2.0 | 4 votes |
public AddItemToPhotosetTask(String photosetId, String itemId, OAuth oauth) { mPhotosetId = photosetId; mItemId = itemId; mOAuth = oauth; }
Example #18
Source File: UploadPhotoTask.java From glimmr with Apache License 2.0 | 4 votes |
public UploadPhotoTask(OAuth oauth, LocalPhotosGridFragment.LocalPhoto photo) { mOAuth = oauth; mPhoto = photo; mMetadata = photo.getMetadata(); }
Example #19
Source File: GetAccessTokenTask.java From glimmr with Apache License 2.0 | 4 votes |
@Override protected void onPostExecute(OAuth result) { mListener.onAccessTokenReady(result); }
Example #20
Source File: GlimmrNotificationHandler.java From glimmr with Apache License 2.0 | votes |
public void startTask(OAuth oauth);
Example #21
Source File: Events.java From glimmr with Apache License 2.0 | votes |
void onAccessTokenReady(OAuth oauth);