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