use of com.googlecode.flickrjandroid.oauth.OAuth in project glimmr by brk3.
the class LoadPhotosetsTask method doInBackground.
@Override
protected Photosets doInBackground(OAuth... params) {
OAuth oauth = params[0];
if (oauth != null) {
OAuthToken token = oauth.getToken();
Flickr f = FlickrHelper.getInstance().getFlickrAuthed(token.getOauthToken(), token.getOauthTokenSecret());
/* "Currently all sets are returned, but this behaviour may change
* in future."
* (http://flickr.com/services/api/flickr.photosets.getList.html)
*/
try {
return f.getPhotosetsInterface().getList(mUser.getId());
} catch (Exception e) {
e.printStackTrace();
mException = e;
}
} else {
if (BuildConfig.DEBUG)
Log.d(TAG, "Making unauthenticated call");
try {
return FlickrHelper.getInstance().getPhotosetsInterface().getList(mUser.getId());
} catch (Exception e) {
e.printStackTrace();
mException = e;
}
}
return null;
}
use of com.googlecode.flickrjandroid.oauth.OAuth in project glimmr by brk3.
the class SearchPhotosTask method doInBackground.
@Override
protected List<Photo> doInBackground(OAuth... params) {
OAuth oauth = params[0];
SearchParameters sp = new SearchParameters();
sp.setExtras(Constants.EXTRAS);
sp.setText(mSearchTerm);
if (mUserId != null) {
sp.setUserId(mUserId);
}
switch(mSortType) {
case AbstractPhotoSearchGridFragment.SORT_TYPE_RECENT:
if (BuildConfig.DEBUG)
Log.d(TAG, "Search type:RECENT");
sp.setSort(SearchParameters.DATE_POSTED_DESC);
break;
case AbstractPhotoSearchGridFragment.SORT_TYPE_INTERESTING:
if (BuildConfig.DEBUG)
Log.d(TAG, "Search type:INTERESTINGNESS");
sp.setSort(SearchParameters.INTERESTINGNESS_DESC);
break;
case AbstractPhotoSearchGridFragment.SORT_TYPE_RELAVANCE:
if (BuildConfig.DEBUG)
Log.d(TAG, "Search type:RELAVANCE");
sp.setSort(SearchParameters.RELEVANCE);
break;
default:
Log.e(TAG, "Unknown sort type, defaulting to RELAVANCE");
sp.setSort(SearchParameters.RELEVANCE);
}
if (oauth != null) {
OAuthToken token = oauth.getToken();
Flickr f = FlickrHelper.getInstance().getFlickrAuthed(token.getOauthToken(), token.getOauthTokenSecret());
if (BuildConfig.DEBUG)
Log.d(TAG, "Fetching page " + mPage);
try {
return f.getPhotosInterface().search(sp, Constants.FETCH_PER_PAGE, mPage);
} catch (Exception e) {
e.printStackTrace();
mException = e;
}
} else {
if (BuildConfig.DEBUG)
Log.d(TAG, "Making unauthenticated call");
if (BuildConfig.DEBUG)
Log.d(TAG, "Fetching page " + mPage);
try {
return FlickrHelper.getInstance().getPhotosInterface().search(sp, Constants.FETCH_PER_PAGE, mPage);
} catch (Exception e) {
e.printStackTrace();
mException = e;
}
}
return null;
}
use of com.googlecode.flickrjandroid.oauth.OAuth in project glimmr by brk3.
the class SetFavoriteTask method doInBackground.
@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;
}
use of com.googlecode.flickrjandroid.oauth.OAuth in project glimmr by brk3.
the class OAuthUtils method isLoggedIn.
public static boolean isLoggedIn(Context context) {
OAuth oauth = loadAccessToken(context);
boolean isLoggedIn = (oauth != null && oauth.getUser() != null);
if (BuildConfig.DEBUG)
Log.d(TAG, "isLoggedIn: " + isLoggedIn);
return isLoggedIn;
}
use of com.googlecode.flickrjandroid.oauth.OAuth in project glimmr by brk3.
the class AppService method doWakefulWork.
/**
* 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);
}
}
}
Aggregations