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:com.cerema.cloud2.ui.activity.FileActivity.java

/**
 * {@inheritDoc}/*from  w ww .j a  va 2s .c  om*/
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
    outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
    outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
    if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) {
        // Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST
        // since it doesn't have a title then
        outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString());
    }
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (imagePage != null) {
        outState.putParcelable(STATE_IMAGE_PAGE, imagePage);
    }/*from  w w  w .  j  a v  a2 s.com*/
    super.onSaveInstanceState(outState);
}

From source file:eu.alefzero.owncloud.ui.fragment.FileDetailFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    Log.i(getClass().toString(), "onSaveInstanceState() start");
    super.onSaveInstanceState(outState);
    outState.putParcelable(FileDetailFragment.EXTRA_FILE, mFile);
    outState.putParcelable(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
    Log.i(getClass().toString(), "onSaveInstanceState() end");
}

From source file:com.androidquery.simplefeed.activity.PostActivity.java

@Override
public void onSaveInstanceState(Bundle bundle) {

    bundle.putSerializable("photo", photo);
    bundle.putString("message", getMessage());
    bundle.putParcelable("location", location);
    bundle.putSerializable("place", place);
    bundle.putSerializable("tags", (Serializable) tags);
}

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

@Override
protected void onSaveInstanceState(Bundle outState) {
    Log_OC.d(TAG, "onSaveInstanceState() start");
    super.onSaveInstanceState(outState);
    outState.putSerializable(KEY_PARENTS, mParents);
    //outState.putParcelable(KEY_ACCOUNT, mAccount);
    outState.putParcelable(KEY_FILE, mFile);
    outState.putBoolean(KEY_ACCOUNT_SELECTED, mAccountSelected);
    outState.putBoolean(KEY_ACCOUNT_SELECTION_SHOWING, mAccountSelectionShowing);
    outState.putInt(KEY_NUM_CACHE_FILE, mNumCacheFile);
    outState.putStringArrayList(KEY_REMOTE_CACHE_DATA, mRemoteCacheData);
    outState.putParcelable(FileActivity.EXTRA_ACCOUNT, getAccount());

    Log_OC.d(TAG, "onSaveInstanceState() end");
}

From source file:androidx.media.MediaSession2StubImplBase.java

public void sendCustomCommand(ControllerInfo controller, final SessionCommand2 command, final Bundle args,
        final ResultReceiver receiver) {
    if (receiver != null && controller == null) {
        throw new IllegalArgumentException("Controller shouldn't be null if result receiver is" + " specified");
    }//  w  w  w  .  j a v  a  2s. c om
    if (command == null) {
        throw new IllegalArgumentException("command shouldn't be null");
    }
    notifyInternal(controller, new Session2Runnable() {
        @Override
        public void run(ControllerInfo controller) throws RemoteException {
            // TODO: Send this event through MediaSessionCompat.XXX()
            Bundle bundle = new Bundle();
            bundle.putBundle(ARGUMENT_CUSTOM_COMMAND, command.toBundle());
            bundle.putBundle(ARGUMENT_ARGUMENTS, args);
            bundle.putParcelable(ARGUMENT_RESULT_RECEIVER, receiver);
            controller.getControllerBinder().onEvent(SESSION_EVENT_SEND_CUSTOM_COMMAND, bundle);
        }
    });
}

From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java

private void editBookmark(BrowserBookmarksAdapter adapter, int position) {
    Intent intent = new Intent(this, AddBookmarkPage.class);
    Cursor cursor = adapter.getItem(position);
    Bundle item = new Bundle();
    item.putString(BrowserContract.Bookmarks.TITLE, cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE));
    item.putString(BrowserContract.Bookmarks.URL, cursor.getString(BookmarksLoader.COLUMN_INDEX_URL));
    byte[] data = cursor.getBlob(BookmarksLoader.COLUMN_INDEX_FAVICON);
    if (data != null) {
        item.putParcelable(BrowserContract.Bookmarks.FAVICON,
                BitmapFactory.decodeByteArray(data, 0, data.length));
    }//from w w  w .  ja v  a 2 s .c om
    item.putLong(BrowserContract.Bookmarks._ID, cursor.getLong(BookmarksLoader.COLUMN_INDEX_ID));
    item.putLong(BrowserContract.Bookmarks.PARENT, cursor.getLong(BookmarksLoader.COLUMN_INDEX_PARENT));
    intent.putExtra(AddBookmarkPage.EXTRA_EDIT_BOOKMARK, item);
    intent.putExtra(AddBookmarkPage.EXTRA_IS_FOLDER,
            cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) == 1);
    startActivity(intent);
}

From source file:com.buddi.client.dfu.DfuActivity.java

@Override
protected void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putInt(DATA_FILE_TYPE, mFileType);
    outState.putInt(DATA_FILE_TYPE_TMP, mFileTypeTmp);
    outState.putString(DATA_FILE_PATH, mFilePath);
    outState.putParcelable(DATA_FILE_STREAM, mFileStreamUri);
    outState.putParcelable(DATA_DEVICE, mSelectedDevice);
    outState.putBoolean(DATA_STATUS, mStatusOk);
}

From source file:com.android.camera.ActivityBase.java

protected void createCameraScreenNail(boolean getPictures) {
    mCameraAppView = findViewById(R.id.camera_app_root);
    Bundle data = new Bundle();
    String path = "/local/all/";
    // Intent mode does not show camera roll. Use 0 as a work around for
    // invalid bucket id.
    // TODO: add support of empty media set in gallery.
    path += (getPictures ? MediaSetUtils.CAMERA_BUCKET_ID : "0");
    data.putString(PhotoPage.KEY_MEDIA_SET_PATH, path);
    data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, path);

    // Send an AppBridge to gallery to enable the camera preview.
    mAppBridge = new MyAppBridge();
    data.putParcelable(PhotoPage.KEY_APP_BRIDGE, mAppBridge);
    getStateManager().startState(PhotoPage.class, data);
    mCameraScreenNail = mAppBridge.getCameraScreenNail();
}

From source file:com.groundupworks.wings.facebook.FacebookEndpoint.java

@Override
public Set<ShareNotification> processShareRequests() {
    Set<ShareNotification> notifications = new HashSet<ShareNotification>();

    // Get params associated with the linked account.
    FacebookSettings settings = fetchSettings();
    if (settings != null) {
        // Get share requests for Facebook.
        int destinationId = settings.getDestinationId();
        Destination destination = new Destination(destinationId, ENDPOINT_ID);
        List<ShareRequest> shareRequests = mDatabase.checkoutShareRequests(destination);
        int shared = 0;
        String intentUri = null;//www  .  j av a2  s . co m

        if (!shareRequests.isEmpty()) {
            // Try open session with cached access token.
            Session session = Session.openActiveSessionFromCache(mContext);
            if (session != null && session.isOpened()) {
                // Process share requests.
                for (ShareRequest shareRequest : shareRequests) {
                    File file = new File(shareRequest.getFilePath());
                    ParcelFileDescriptor fileDescriptor = null;
                    try {
                        // Construct graph params.
                        fileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
                        Bundle params = new Bundle();
                        params.putParcelable(SHARE_KEY_PICTURE, fileDescriptor);

                        String pageAccessToken = settings.optPageAccessToken();
                        if (DestinationId.PAGE == destinationId && !TextUtils.isEmpty(pageAccessToken)) {
                            params.putString(SHARE_KEY_PAGE_ACCESS_TOKEN, pageAccessToken);
                        }

                        String photoPrivacy = settings.optPhotoPrivacy();
                        if (!TextUtils.isEmpty(photoPrivacy)) {
                            params.putString(SHARE_KEY_PHOTO_PRIVACY, photoPrivacy);
                        }

                        // Execute upload request synchronously. Need to use RequestBatch to set connection timeout.
                        Request request = new Request(session, settings.getAlbumGraphPath(), params,
                                HttpMethod.POST, null);
                        RequestBatch requestBatch = new RequestBatch(request);
                        requestBatch.setTimeout(HTTP_REQUEST_TIMEOUT);
                        List<Response> responses = requestBatch.executeAndWait();
                        if (responses != null && !responses.isEmpty()) {
                            // Process response.
                            Response response = responses.get(0);
                            if (response != null) {
                                FacebookRequestError error = response.getError();
                                if (error == null) {
                                    // Mark as successfully processed.
                                    mDatabase.markSuccessful(shareRequest.getId());

                                    // Parse photo id to construct notification intent uri.
                                    if (intentUri == null) {
                                        String photoId = parsePhotoId(response.getGraphObject());
                                        if (photoId != null && photoId.length() > 0) {
                                            intentUri = SHARE_NOTIFICATION_INTENT_BASE_URI + photoId;
                                        }
                                    }

                                    shared++;
                                } else {
                                    mDatabase.markFailed(shareRequest.getId());

                                    Category category = error.getCategory();
                                    if (Category.AUTHENTICATION_RETRY.equals(category)
                                            || Category.PERMISSION.equals(category)) {
                                        // Update account linking state to unlinked.
                                        unlink();
                                    }
                                }
                            } else {
                                mDatabase.markFailed(shareRequest.getId());
                            }
                        } else {
                            mDatabase.markFailed(shareRequest.getId());
                        }
                    } catch (FacebookException e) {
                        mDatabase.markFailed(shareRequest.getId());
                    } catch (IllegalArgumentException e) {
                        mDatabase.markFailed(shareRequest.getId());
                    } catch (FileNotFoundException e) {
                        mDatabase.markFailed(shareRequest.getId());
                    } catch (Exception e) {
                        // Safety.
                        mDatabase.markFailed(shareRequest.getId());
                    } finally {
                        if (fileDescriptor != null) {
                            try {
                                fileDescriptor.close();
                            } catch (IOException e) {
                                // Do nothing.
                            }
                        }
                    }
                }
            } else {
                // Mark all share requests as failed to process since we failed to open an active session.
                for (ShareRequest shareRequest : shareRequests) {
                    mDatabase.markFailed(shareRequest.getId());
                }
            }
        }

        // Construct and add notification representing share results.
        if (shared > 0) {
            notifications.add(new FacebookShareNotification(mContext, destination.getHash(),
                    settings.getAlbumName(), shared, intentUri));
        }
    }

    return notifications;
}