Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

In this page you can find the example usage for android.os Bundle putParcelable.

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

Inserts a Parcelable value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    try {/*from  w  ww. j a va  2  s .c  om*/
        outState.putString("Title", Title.getText().toString());
        outState.putString("Component", Component.getText().toString());
        outState.putString("EventClass", EventClass.getText().toString());
        outState.putString("Summary", Summary.getText().toString());
        outState.putString("FirstTime", FirstTime.getText().toString());
        outState.putString("LastTime", LastTime.getText().toString());
        outState.putString("EventCount", EventCount.getText().toString());
        outState.putString("agent", agent.getText().toString());
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventFragmentUpdate", "onSaveInstanceState", e);
    }

    outState.putStringArray("LogEntries", LogEntries);

    try {
        if (isAcknowledged) {
            outState.putBoolean("eventStateAcknowledged", true);
        } else {
            outState.putBoolean("eventStateAcknowledged", false);
        }
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "onsaveinstance", e);
    }

    try {
        if (img.getDrawable() instanceof android.graphics.drawable.BitmapDrawable) {
            outState.putParcelable("img", ((BitmapDrawable) img.getDrawable()).getBitmap());
        }
    } catch (ClassCastException cce) {
        //Don't care
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "onsaveinstance", e);
    }
}

From source file:android.support.v7.preference.Preference.java

/**
 * Called by {@link #saveHierarchyState} to store the instance for this Preference and its children.
 * May be overridden to modify how the save happens for children. For example, some
 * Preference objects may want to not store an instance for their children.
 *
 * @param container The Bundle in which to save the instance of this Preference.
 *
 * @see #saveHierarchyState/*from  w  w  w. java  2  s . c  om*/
 * @see #onSaveInstanceState
 */
void dispatchSaveInstanceState(Bundle container) {
    if (hasKey()) {
        mBaseMethodCalled = false;
        Parcelable state = onSaveInstanceState();
        if (!mBaseMethodCalled) {
            throw new IllegalStateException("Derived class did not call super.onSaveInstanceState()");
        }
        if (state != null) {
            container.putParcelable(mKey, state);
        }
    }
}

From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    state.putString(Constants.SUBREDDIT_KEY, mSubreddit);
    state.putString(Constants.ThreadsSort.SORT_BY_KEY, mSortByUrl);
    state.putString(Constants.JUMP_TO_THREAD_ID_KEY, mJumpToThreadId);
    state.putString(Constants.AFTER_KEY, mAfter);
    state.putString(Constants.BEFORE_KEY, mBefore);
    state.putInt(Constants.THREAD_COUNT_KEY, mCount);
    state.putString(Constants.LAST_AFTER_KEY, mLastAfter);
    state.putString(Constants.LAST_BEFORE_KEY, mLastBefore);
    state.putInt(Constants.THREAD_LAST_COUNT_KEY, mLastCount);
    state.putParcelable(Constants.VOTE_TARGET_THING_INFO_KEY, mVoteTargetThing);
}

From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    Log.d(TAG, "onSaveInstanceState");
    // Save opened framents into state retaining fragment (I love Google! :-)
    Log.d(TAG, String.format("Saving %d fragments", pagerAdapter.getFragmentList().size()));
    Log.d(TAG, String.format("Saving current page = %d", pager.getCurrentItem()));
    stateFragment.setFragmentList(pagerAdapter.getFragmentList());
    stateFragment.setCurrentPage(pager.getCurrentItem());
    // Save UI state changes to the savedInstanceState.
    // This bundle will be passed to onCreate if the process is
    // killed and restarted.
    savedInstanceState.putString("openHABBaseUrl", openHABBaseUrl);
    savedInstanceState.putString("sitemapRootUrl", sitemapRootUrl);
    savedInstanceState.putInt("currentFragment", pager.getCurrentItem());
    savedInstanceState.putParcelable("startedWithNetworkConnectivityInfo", mStartedWithNetworkConnectivityInfo);
    savedInstanceState.putInt("openHABVersion", mOpenHABVersion);
    savedInstanceState.putParcelableArrayList("sitemapList", mSitemapList);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java

private void startBuildingPublishActivity(String addresses) {
    requestPendingForBuilding = false;/*w  w  w . j av a2  s .c om*/
    if (connected) {
        Bundle args = new Bundle();
        args.putParcelable("CurrentLocation", currentLocation);
        Intent i = new Intent(this, BuildingPublishActivity.class);
        i.putExtra("Address", addresses);
        i.putExtra("Bundle", args);
        startActivity(i);
    }
}

From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java

private void startSensorPublishActivity(String addresses) {
    requestPendingForSensor = false;//  w w  w.jav  a  2  s . c om
    if (connected) {
        Bundle args = new Bundle();
        args.putParcelable("CurrentLocation", currentLocation);
        Intent i = new Intent(this, SensorPublishActivity.class);
        i.putExtra("Address", addresses);
        i.putExtra("Bundle", args);
        startActivity(i);
    }
}

From source file:it.feio.android.omninotes.DetailFragment.java

private void takeSketch(Attachment attachment) {

    File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_SKETCH_EXT);
    if (f == null) {
        mainActivity.showMessage(R.string.error, ONStyle.ALERT);
        return;/*from  ww  w . j a  v  a 2  s .c o m*/
    }
    attachmentUri = Uri.fromFile(f);

    // Forces portrait orientation to this fragment only
    mainActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Fragments replacing
    FragmentTransaction transaction = mainActivity.getSupportFragmentManager().beginTransaction();
    mainActivity.animateTransition(transaction, mainActivity.TRANSITION_HORIZONTAL);
    SketchFragment mSketchFragment = new SketchFragment();
    Bundle b = new Bundle();
    b.putParcelable(MediaStore.EXTRA_OUTPUT, attachmentUri);
    if (attachment != null) {
        b.putParcelable("base", attachment.getUri());
    }
    mSketchFragment.setArguments(b);
    transaction.replace(R.id.fragment_container, mSketchFragment, mainActivity.FRAGMENT_SKETCH_TAG)
            .addToBackStack(mainActivity.FRAGMENT_DETAIL_TAG).commit();
}

From source file:com.androzic.MapActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.e(TAG, "onSaveInstanceState()");
    outState.putParcelable("lastKnownLocation", lastKnownLocation);
    outState.putLong("lastRenderTime", lastRenderTime);
    outState.putLong("lastMagnetic", lastMagnetic);
    outState.putLong("lastDim", lastDim);
    outState.putBoolean("lastGeoid", lastGeoid);

    outState.putInt("waypointSelected", waypointSelected);
    outState.putInt("routeSelected", routeSelected);
    outState.putLong("mapObjectSelected", mapObjectSelected);

    if (application.distanceOverlay != null) {
        outState.putDoubleArray("distAncor", application.distanceOverlay.getAncor());
    }/*from w  w w. j  a  va 2  s .  co  m*/
}

From source file:it.feio.android.omninotes.DetailFragment.java

@SuppressLint("NewApi")
@Override//from  ww  w . java 2s .c om
public boolean onTouch(View v, MotionEvent event) {
    int x = (int) event.getX();
    int y = (int) event.getY();

    switch (event.getAction()) {

    case MotionEvent.ACTION_DOWN:
        Log.v(Constants.TAG, "MotionEvent.ACTION_DOWN");
        int w;

        Point displaySize = Display.getUsableSize(mainActivity);
        w = displaySize.x;

        if (x < Constants.SWIPE_MARGIN || x > w - Constants.SWIPE_MARGIN) {
            swiping = true;
            startSwipeX = x;
        }

        break;

    case MotionEvent.ACTION_UP:
        Log.v(Constants.TAG, "MotionEvent.ACTION_UP");
        if (swiping)
            swiping = false;
        break;

    case MotionEvent.ACTION_MOVE:
        if (swiping) {
            Log.v(Constants.TAG, "MotionEvent.ACTION_MOVE at position " + x + ", " + y);
            if (Math.abs(x - startSwipeX) > Constants.SWIPE_OFFSET) {
                swiping = false;
                FragmentTransaction transaction = mainActivity.getSupportFragmentManager().beginTransaction();
                mainActivity.animateTransition(transaction, mainActivity.TRANSITION_VERTICAL);
                DetailFragment mDetailFragment = new DetailFragment();
                Bundle b = new Bundle();
                b.putParcelable(Constants.INTENT_NOTE, new Note());
                mDetailFragment.setArguments(b);
                transaction.replace(R.id.fragment_container, mDetailFragment, mainActivity.FRAGMENT_DETAIL_TAG)
                        .addToBackStack(mainActivity.FRAGMENT_DETAIL_TAG).commit();
            }
        }
        break;
    }

    return true;
}