Search in sources :

Example 16 with GsonHelper

use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.

the class PhotoViewerActivity method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (mPhotos.isEmpty()) {
        String json = new GsonHelper(this).loadJson(PHOTO_LIST_FILE);
        if (json.length() == 0) {
            Log.e(TAG, String.format("Error reading '%s'", PHOTO_LIST_FILE));
        } else {
            Type collectionType = new TypeToken<Collection<Photo>>() {
            }.getType();
            mPhotos = new Gson().fromJson(json, collectionType);
        }
    }
    boolean overlayOn = savedInstanceState.getBoolean(KEY_ACTIONBAR_SHOW, true);
    if (overlayOn) {
        mActionBar.show();
    } else {
        mActionBar.hide();
    }
    int pagerIndex = savedInstanceState.getInt(KEY_CURRENT_INDEX, 0);
    initViewPager(pagerIndex, false);
    if (savedInstanceState.getBoolean(KEY_SLIDESHOW_RUNNING, false)) {
        startSlideshow();
    }
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper) Type(java.lang.reflect.Type) Collection(java.util.Collection) Gson(com.google.gson.Gson)

Example 17 with GsonHelper

use of com.bourke.glimmr.common.GsonHelper in project glimmr by brk3.

the class PhotosetGridFragment method onSaveInstanceState.

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    new GsonHelper(mActivity).marshallObject(mPhotoset, outState, KEY_PHOTOSET);
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper)

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