Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

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

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

/**
 * Restores the latest status of this activity.
 * //from ww  w  . j  a va 2s. c  om
 * @param savedInstanceState
 *            The instance which has the latest status.
 */
private void restoreSavedInstanceState(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        return;
    }
    if (savedInstanceState.containsKey("MapState")) {
        MapState mapState = (MapState) savedInstanceState.getParcelable("MapState");
        if (mapState != null) {
            this.restoreMapState(mapState.id, mapState.lon, mapState.lat, mapState.z);
        }
    }
}

From source file:org.klnusbaum.udj.EventListFragment.java

public void onActivityCreated(Bundle icicle) {
    super.onActivityCreated(icicle);
    am = AccountManager.get(getActivity());
    Account[] udjAccounts = am.getAccountsByType(Constants.ACCOUNT_TYPE);
    Log.d(TAG, "Accounts length was " + udjAccounts.length);
    if (udjAccounts.length < 1) {
        Intent getAccountIntent = new Intent(getActivity(), AuthActivity.class);
        startActivityForResult(getAccountIntent, ACCOUNT_CREATION);
        return;/*  ww w . j a  v  a2 s.c o m*/
    } else if (udjAccounts.length == 1) {
        account = udjAccounts[0];
    } else {
        account = udjAccounts[0];
        //TODO implement if there are more than 1 account
    }
    if (icicle != null) {
        if (icicle.containsKey(LOCATION_STATE_EXTRA)) {
            lastKnown = (Location) icicle.getParcelable(LOCATION_STATE_EXTRA);
        }
        if (icicle.containsKey(LAST_SEARCH_TYPE_EXTRA)) {
            restoreLastSearch(icicle);
        }
    }
    setEmptyText(getActivity().getString(R.string.no_event_items));
    eventAdapter = new EventListAdapter(getActivity());
    setListAdapter(eventAdapter);
    setListShown(false);
}

From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle state = (savedInstanceState != null) ? savedInstanceState : getArguments();
    mTitle = state.getString(EXTRA_CONTENT_TITLE);
    mBreadcrumb = state.getString(EXTRA_CONTENT_BREADCRUMB);
    mDescription = state.getString(EXTRA_CONTENT_DESCRIPTION);
    //mIcon = state.getParcelable(EXTRA_CONTENT_ICON_RESOURCE_ID, 0);
    mIconUri = state.getParcelable(EXTRA_CONTENT_ICON_URI);
    mIconBitmap = state.getParcelable(EXTRA_CONTENT_ICON_BITMAP);
    mIconBackgroundColor = state.getInt(EXTRA_CONTENT_ICON_BACKGROUND, Color.TRANSPARENT);
    mName = state.getString(EXTRA_ACTION_NAME);
    mSelectedIndex = state.getInt(EXTRA_ACTION_SELECTED_INDEX, -1);
    mEntryTransitionPerformed = state.getBoolean(EXTRA_ENTRY_TRANSITION_PERFORMED, false);
}

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

@Override
public void onActivityCreated(Bundle bundle) {
    try {/*  w  w  w .  j  a  v a2 s  .co  m*/
        deviceTitle.setText(getArguments().getString(ARG_HOSTNAME));
    } catch (Exception e) {
        BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
    }

    //Check if we have a bundle
    if (null != bundle) {
        if (bundle.containsKey("json")) {
            try {
                deviceJSON = new JSONObject(bundle.getString("json"));
                ProcessJSON();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

        if (bundle.containsKey("cpuimg")) {
            try {
                CPUGraphView.setImageBitmap((Bitmap) bundle.getParcelable("img"));
                CPUGraphView.invalidate();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

        if (bundle.containsKey("loadavgimg")) {
            try {
                loadAverageGraphView.setImageBitmap((Bitmap) bundle.getParcelable("cpuimg"));
                loadAverageGraphView.invalidate();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

        if (bundle.containsKey("memimg")) {
            try {
                MemoryGraphView.setImageBitmap((Bitmap) bundle.getParcelable("memimg"));
                MemoryGraphView.invalidate();
            } catch (Exception e) {
                BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
            }
        }

    } else {
        (new Thread() {
            public void run() {
                ZenossAPI API;

                if (PreferenceManager.getDefaultSharedPreferences(getActivity())
                        .getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) {
                    API = new ZenossAPIZaas();
                } else {
                    API = new ZenossAPICore();
                }

                try {
                    credentials = new ZenossCredentials(getActivity());
                    API.Login(credentials);
                    deviceJSON = API.GetDevice(getArguments().getString(ARG_UID));

                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            ProcessJSON();
                        }
                    });

                } catch (Exception e) {
                    BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "onActivityCreated", e);
                }
            }
        }).start();
    }

    getGraphs();

    super.onActivityCreated(bundle);
}

From source file:com.cerema.cloud2.ui.activity.FileActivity.java

/**
 * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
 * the {@link FileActivity}./*from ww  w  .  j  a  v  a  2s . com*/
 *
 * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user
 * is requested to create a new one.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHandler = new Handler();
    mFileOperationsHelper = new FileOperationsHelper(this);
    Account account = null;
    if (savedInstanceState != null) {
        mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
        mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
        mFileOperationsHelper
                .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE));
        if (getSupportActionBar() != null) {
            getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
        }
    } else {
        account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
        mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false);
    }

    AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager
                                             // or database

    setAccount(account, savedInstanceState != null);

    mOperationsServiceConnection = new OperationsServiceConnection();
    bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
            Context.BIND_AUTO_CREATE);

    mDownloadServiceConnection = newTransferenceServiceConnection();
    if (mDownloadServiceConnection != null) {
        bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection,
                Context.BIND_AUTO_CREATE);
    }
    mUploadServiceConnection = newTransferenceServiceConnection();
    if (mUploadServiceConnection != null) {
        bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE);
    }

}

From source file:com.bushstar.kobocoin_android_wallet.ui.SendCoinsFragment.java

private void restoreInstanceState(final Bundle savedInstanceState) {
    paymentIntent = savedInstanceState.getParcelable("payment_intent");

    state = (State) savedInstanceState.getSerializable("state");

    validatedAddress = savedInstanceState.getParcelable("validated_address");

    if (savedInstanceState.containsKey("sent_transaction_hash")) {
        sentTransaction = wallet/* w w w.  j  a  v a 2  s. co m*/
                .getTransaction((Sha256Hash) savedInstanceState.getSerializable("sent_transaction_hash"));
        sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener);
    }

    if (savedInstanceState.containsKey("direct_payment_ack"))
        directPaymentAck = savedInstanceState.getBoolean("direct_payment_ack");
}

From source file:cc.mintcoin.wallet.ui.SendCoinsFragment.java

private void initStateFromIntentExtras(@Nonnull final Bundle extras) {
    final PaymentIntent paymentIntent = extras.getParcelable(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT);

    updateStateFrom(paymentIntent);/*from   w  w w .  j ava2 s  .c  o m*/
}

From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    if (bundle.containsKey("gallery"))
        inGallery = bundle.getBoolean("gallery");
    imageData = bundle.getParcelable("imageData");
    setHasOptionsMenu(true);//from  w w  w.  jav a 2 s .  c  o m
}

From source file:com.oscarsalguero.solartracker.MainActivity.java

private void updateValuesFromBundle(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        // Update the value of mRequestingLocationUpdates from the Bundle, and
        // make sure that the Start Updates and Stop Updates buttons are
        // correctly enabled or disabled.
        if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) {
            mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY);
        }/* ww w . j  av  a 2  s. c  o  m*/

        // Update the value of mCurrentLocation from the Bundle and update the
        // UI to show the correct latitude and longitude.
        if (savedInstanceState.keySet().contains(LOCATION_KEY)) {
            // Since LOCATION_KEY was found in the Bundle, we can be sure that
            // mCurrentLocationis not null.
            mLastLocation = savedInstanceState.getParcelable(LOCATION_KEY);
        }

        // Update the value of mLastUpdateTime from the Bundle and update the UI.
        if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) {
            mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY);
        }
    }
}