use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class FavoritesGridFragment method onSaveInstanceState.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
new GsonHelper(mActivity).marshallObject(mUserToView, outState, KEY_USER);
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class PhotoUploadActivity method startPhotoUploadActivity.
/**
* Start the PhotoUploadActivity with a list of image uris to process.
*/
public static void startPhotoUploadActivity(Context context, ArrayList<LocalPhotosGridFragment.LocalPhoto> uris) {
Intent photoUploadActivity = new Intent(context, PhotoUploadActivity.class);
Bundle extras = new Bundle();
new GsonHelper(context).marshallObject(uris, extras, KEY_PHOTO_LIST);
photoUploadActivity.putExtras(extras);
context.startActivity(photoUploadActivity);
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class GroupViewerActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
GsonHelper gson = new GsonHelper(this);
gson.marshallObject(mGroup, bundle, KEY_GROUP);
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class ActivityNotificationHandler method storeItemList.
public static void storeItemList(Context context, List<Item> items) {
if (items == null) {
Log.e(TAG, "storeItemList: items are null");
return;
}
GsonHelper gson = new GsonHelper(context);
boolean itemListStoreResult = gson.marshallObject(items, ACTIVITY_ITEMLIST_FILE);
if (!itemListStoreResult) {
Log.e(TAG, "Error marshalling itemlist");
return;
}
/* Store the current time so the menudrawer can check if it's fresh */
SharedPreferences prefs = context.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor prefsEditor = prefs.edit();
prefsEditor.putLong(KEY_TIME_ACTIVITY_ITEMS_LAST_UPDATED, (System.currentTimeMillis() / 1000L));
prefsEditor.commit();
if (BuildConfig.DEBUG) {
Log.d(TAG, String.format("Sucessfully wrote %d items to %s", items.size(), ACTIVITY_ITEMLIST_FILE));
}
}
use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.
the class ActivityNotificationHandler method loadItemList.
public static List<Item> loadItemList(Context context) {
List<Item> ret = new ArrayList<Item>();
GsonHelper gson = new GsonHelper(context);
String json = gson.loadJson(ACTIVITY_ITEMLIST_FILE);
if (json.length() == 0) {
Log.e(TAG, String.format("Error reading %s", ACTIVITY_ITEMLIST_FILE));
return ret;
}
Type collectionType = new TypeToken<Collection<Item>>() {
}.getType();
ret = new Gson().fromJson(json, collectionType);
if (BuildConfig.DEBUG) {
Log.d(TAG, String.format("Sucessfully read %d items from %s", ret.size(), ACTIVITY_ITEMLIST_FILE));
}
return ret;
}
Aggregations