Search in sources :

Example 11 with GsonHelper

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

Example 12 with GsonHelper

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

Example 13 with GsonHelper

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());
    }
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper) Type(java.lang.reflect.Type) TypeToken(com.google.gson.reflect.TypeToken) Gson(com.google.gson.Gson) Photo(com.googlecode.flickrjandroid.photos.Photo) LoadPhotoInfoTask(com.bourke.glimmr.tasks.LoadPhotoInfoTask)

Example 14 with GsonHelper

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

Example 15 with GsonHelper

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);
}
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