Search in sources :

Example 6 with GsonHelper

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);
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper)

Example 7 with GsonHelper

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);
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper) Bundle(android.os.Bundle) Intent(android.content.Intent)

Example 8 with GsonHelper

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);
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper)

Example 9 with GsonHelper

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));
    }
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper) SharedPreferences(android.content.SharedPreferences)

Example 10 with GsonHelper

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;
}
Also used : Item(com.googlecode.flickrjandroid.activity.Item) GsonHelper(com.bourke.glimmr.common.GsonHelper) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) Collection(java.util.Collection) Gson(com.google.gson.Gson)

Aggregations

GsonHelper (com.bourke.glimmr.common.GsonHelper)17 Gson (com.google.gson.Gson)3 Type (java.lang.reflect.Type)3 Intent (android.content.Intent)2 Collection (java.util.Collection)2 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 LoadPhotoInfoTask (com.bourke.glimmr.tasks.LoadPhotoInfoTask)1 TypeToken (com.google.gson.reflect.TypeToken)1 Item (com.googlecode.flickrjandroid.activity.Item)1 Photo (com.googlecode.flickrjandroid.photos.Photo)1 ArrayList (java.util.ArrayList)1