use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class PhotoUploadFragment method onSaveInstanceState.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
new GsonHelper(mActivity).marshallObject(mPhoto, outState, KEY_PHOTO);
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class PhotoViewerActivity method startPhotoViewer.
/**
* Start PhotoViewerActivity to view a list of photos, starting at a specific index.
*/
public static void startPhotoViewer(Context context, List<Photo> photos, int index) {
if (new GsonHelper(context).marshallObject(photos, PHOTO_LIST_FILE)) {
Intent photoViewer = new Intent(context, PhotoViewerActivity.class);
photoViewer.setAction(ACTION_VIEW_PHOTOLIST);
photoViewer.putExtra(KEY_START_INDEX, index);
photoViewer.putExtra(KEY_PHOTO_LIST_FILE, PHOTO_LIST_FILE);
context.startActivity(photoViewer);
} else {
Log.e(TAG, "Error marshalling photo list, cannot start viewer");
}
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class PhotoViewerActivity method handleIntent.
private void handleIntent(Intent intent) {
if (intent.getBooleanExtra(KEY_INTENT_CONSUMED, false)) {
/* prevent the intent getting executed twice on rotate */
if (BuildConfig.DEBUG)
Log.d(TAG, "KEY_INTENT_CONSUMED true");
return;
}
final int startIndex = intent.getIntExtra(KEY_START_INDEX, 0);
if (intent.getAction().equals(ACTION_VIEW_PHOTO_BY_ID)) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Received ACTION_VIEW_PHOTO_BY_ID intent");
intent.putExtra(KEY_INTENT_CONSUMED, true);
String photoId = intent.getStringExtra(KEY_PHOTO_ID);
new LoadPhotoInfoTask(this, photoId).execute(mOAuth);
} else if (intent.getAction().equals(ACTION_VIEW_PHOTOLIST)) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Received ACTION_VIEW_PHOTOLIST intent");
intent.putExtra(KEY_INTENT_CONSUMED, true);
String photoListFile = intent.getStringExtra(KEY_PHOTO_LIST_FILE);
GsonHelper gsonHelper = new GsonHelper(this);
String json = gsonHelper.loadJson(photoListFile);
if (json.length() > 0) {
Type collectionType = new TypeToken<Collection<Photo>>() {
}.getType();
mPhotos = new Gson().fromJson(json, collectionType);
initViewPager(startIndex, true);
} else {
Log.e(TAG, String.format("Error reading '%s'", photoListFile));
}
} else {
Log.e(TAG, "Unknown intent action: " + intent.getAction());
}
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class PhotosetViewerActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
GsonHelper gson = new GsonHelper(this);
gson.marshallObject(mPhotoset, bundle, KEY_PHOTOSET);
gson.marshallObject(mPhotoset, bundle, KEY_USER);
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class ProfileViewerActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
new GsonHelper(this).marshallObject(mUser, bundle, KEY_USER);
}
Aggregations