Search in sources :

Example 1 with OAuthToken

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

the class LoadFlickrActivityTask method doInBackground.

@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;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr) OAuth(com.googlecode.flickrjandroid.oauth.OAuth)

Example 2 with OAuthToken

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

the class LoadPhotosetPhotosTask method doInBackground.

@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());
        if (BuildConfig.DEBUG)
            Log.d(TAG, "Fetching page " + mPage);
        try {
            return f.getPhotosetsInterface().getPhotos("" + mPhotoset.getId(), Constants.EXTRAS, Flickr.PRIVACY_LEVEL_NO_FILTER, Constants.FETCH_PER_PAGE, mPage).getPhotoList();
        } 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().getPhotosetsInterface().getPhotos("" + mPhotoset.getId(), Constants.EXTRAS, Flickr.PRIVACY_LEVEL_NO_FILTER, Constants.FETCH_PER_PAGE, mPage).getPhotoList();
        } 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)

Example 3 with OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr) OAuth(com.googlecode.flickrjandroid.oauth.OAuth)

Example 4 with OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) Flickr(com.googlecode.flickrjandroid.Flickr) OAuth(com.googlecode.flickrjandroid.oauth.OAuth)

Example 5 with OAuthToken

use of com.googlecode.flickrjandroid.oauth.OAuthToken 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;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) SearchParameters(com.googlecode.flickrjandroid.photos.SearchParameters) 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