Search in sources :

Example 1 with User

use of com.googlecode.flickrjandroid.people.User in project glimmr by brk3.

the class PhotosetViewerActivity method onRestoreInstanceState.

@Override
protected void onRestoreInstanceState(Bundle bundle) {
    super.onRestoreInstanceState(bundle);
    Gson gson = new Gson();
    if (mPhotoset == null) {
        String json = bundle.getString(KEY_PHOTOSET);
        if (json != null) {
            mPhotoset = gson.fromJson(json, Photoset.class);
        } else {
            Log.e(TAG, "No photoset found in savedInstanceState");
        }
    }
    if (mUser == null) {
        String json = bundle.getString(KEY_USER);
        if (json != null) {
            mUser = new Gson().fromJson(json, User.class);
        } else {
            Log.e(TAG, "No user found in savedInstanceState");
        }
    }
    mPhotoset.setOwner(mUser);
    initViewPager();
    updateBottomOverlay();
}
Also used : User(com.googlecode.flickrjandroid.people.User) Photoset(com.googlecode.flickrjandroid.photosets.Photoset) Gson(com.google.gson.Gson)

Example 2 with User

use of com.googlecode.flickrjandroid.people.User in project glimmr by brk3.

the class PhotosetGridFragment method onPhotosReady.

@Override
public void onPhotosReady(List<Photo> photos, Exception e) {
    super.onPhotosReady(photos, e);
    mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE);
    if (mPhotoset != null) {
        User owner = mPhotoset.getOwner();
        if (owner != null) {
            for (Photo p : photos) {
                p.setOwner(owner);
                p.setUrl(String.format("%s%s%s%s", "http://flickr.com/photos/", owner.getId(), "/", p.getId()));
            }
        }
        if (photos != null && photos.isEmpty()) {
            mMorePages = false;
        }
    }
}
Also used : User(com.googlecode.flickrjandroid.people.User) Photo(com.googlecode.flickrjandroid.photos.Photo)

Example 3 with User

use of com.googlecode.flickrjandroid.people.User in project glimmr by brk3.

the class ProfileViewerActivity method onRestoreInstanceState.

@Override
protected void onRestoreInstanceState(Bundle bundle) {
    super.onRestoreInstanceState(bundle);
    Gson gson = new Gson();
    if (mUser == null) {
        String json = bundle.getString(KEY_USER);
        if (json != null) {
            mUser = gson.fromJson(json, User.class);
            initViewPager();
            updateBottomOverlay();
        } else {
            Log.e(TAG, "No user found in savedInstanceState");
        }
    }
}
Also used : User(com.googlecode.flickrjandroid.people.User) Gson(com.google.gson.Gson)

Example 4 with User

use of com.googlecode.flickrjandroid.people.User in project glimmr by brk3.

the class LoginFragment method persistAccessToken.

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();
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) User(com.googlecode.flickrjandroid.people.User) SharedPreferences(android.content.SharedPreferences)

Example 5 with User

use of com.googlecode.flickrjandroid.people.User in project glimmr by brk3.

the class OAuthUtils method loadAccessToken.

public static OAuth loadAccessToken(Context context) {
    SharedPreferences prefs = context.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_PRIVATE);
    String oauthTokenString = prefs.getString(Constants.KEY_OAUTH_TOKEN, null);
    String tokenSecret = prefs.getString(Constants.KEY_TOKEN_SECRET, null);
    String userName = prefs.getString(Constants.KEY_ACCOUNT_USER_NAME, null);
    String userId = prefs.getString(Constants.KEY_ACCOUNT_USER_ID, null);
    OAuth oauth = null;
    if (oauthTokenString != null && tokenSecret != null && userName != null && userId != null) {
        oauth = new OAuth();
        OAuthToken oauthToken = new OAuthToken();
        oauth.setToken(oauthToken);
        oauthToken.setOauthToken(oauthTokenString);
        oauthToken.setOauthTokenSecret(tokenSecret);
        User user = new User();
        user.setUsername(userName);
        user.setId(userId);
        oauth.setUser(user);
    } else {
        Log.w(TAG, "No saved oauth token found");
        return null;
    }
    return oauth;
}
Also used : OAuthToken(com.googlecode.flickrjandroid.oauth.OAuthToken) User(com.googlecode.flickrjandroid.people.User) SharedPreferences(android.content.SharedPreferences) OAuth(com.googlecode.flickrjandroid.oauth.OAuth)

Aggregations

User (com.googlecode.flickrjandroid.people.User)5 SharedPreferences (android.content.SharedPreferences)2 Gson (com.google.gson.Gson)2 OAuthToken (com.googlecode.flickrjandroid.oauth.OAuthToken)2 OAuth (com.googlecode.flickrjandroid.oauth.OAuth)1 Photo (com.googlecode.flickrjandroid.photos.Photo)1 Photoset (com.googlecode.flickrjandroid.photosets.Photoset)1