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:br.com.bioscada.apps.biotracks.TrackDetailActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(CURRENT_TAB_TAG_KEY, tabHost.getCurrentTabTag());
    if (photoUri != null) {
        outState.putParcelable(PHOTO_URI_KEY, photoUri);
    }//from www .  j  a va2  s. c  o m
    outState.putBoolean(HAS_PHOTO_KEY, hasPhoto);
}

From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java

/**
 * Menu actions// w  ww.ja v  a 2s  .co  m
 * @param menuItem
 */
@Override
public boolean onOptionsItemSelected(final MenuItem menuItem) {

    switch (menuItem.getItemId()) {

    case MENU_ITEM_REFRESH:
        mShowDialog = true;
        new GetNextTramTimes().execute();
        return true;

    case MENU_ITEM_FAVOURITE:
        mStarButton = (CompoundButton) findViewById(R.id.stopStar);
        Favourite favourite = new Favourite(mStop, mRoute);
        boolean isFavourite = mFavouriteList.isFavourite(favourite);
        mFavouriteList.toggleFavourite(favourite);
        mStarButton.setChecked(!isFavourite);
        return true;

    case MENU_ITEM_MAP:
        // Map view
        Bundle bundle = new Bundle();
        StopsList mStopList = new StopsList();
        mStopList.add(mStop);
        bundle.putParcelable("stopslist", mStopList);
        Intent intent = new Intent(StopDetailsActivity.this, StopMapActivity.class);
        intent.putExtras(bundle);
        startActivityForResult(intent, 1);
        return true;
    }

    return false;
}

From source file:android.support.car.ui.CarNavExtender.java

@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
    Bundle b = new Bundle();
    b.putBoolean(EXTRA_IS_EXTENDED, true);
    b.putSerializable(EXTRA_CONTENT_ID, mContentId);
    b.putInt(EXTRA_TYPE, mType);/*from w ww  . j a v a  2  s  . c  o m*/
    b.putCharSequence(Notification.EXTRA_TITLE, mContentTitle);
    b.putCharSequence(Notification.EXTRA_TEXT, mContentText);
    b.putCharSequence(EXTRA_SUB_TEXT, mSubText);
    b.putParcelable(Notification.EXTRA_LARGE_ICON, mLargeIcon);
    b.putInt(EXTRA_ACTION_ICON, mActionIcon);
    b.putParcelable(EXTRA_CONTENT_INTENT, mContentIntent);
    b.putInt(EXTRA_COLOR, mColor);
    b.putInt(EXTRA_NIGHT_COLOR, mNightColor);
    b.putBoolean(EXTRA_STREAM_VISIBILITY, mShowInStream);
    b.putBoolean(EXTRA_HEADS_UP_VISIBILITY, mShowAsHeadsUp);
    b.putBoolean(EXTRA_IGNORE_IN_STREAM, mIgnoreInStream);
    builder.getExtras().putBundle(EXTRA_CAR_EXTENDER, b);
    return builder;
}

From source file:com.avapira.bobroreader.BoardFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    Log.d(TAG, "SIS");
    super.onSaveInstanceState(outState);
    outState.putString(ARG_KEY, boardKey);
    outState.putInt(ARG_PAGE, page);/*from ww  w.j  av a 2  s. c o  m*/
    outState.putParcelable(ARG_RECYCLER_LAYOUT, recyclerLayoutManager.onSaveInstanceState());
}

From source file:com.achep.base.ui.activities.SettingsActivity.java

@Override
public Intent getIntent() {
    Intent superIntent = super.getIntent();
    String startingFragment = getStartingFragmentClass(superIntent);
    // This is called from super.onCreate, isMultiPane() is not yet reliable
    // Do not use onIsHidingHeaders either, which relies itself on this method
    if (startingFragment != null) {
        Intent modIntent = new Intent(superIntent);
        modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
        Bundle args = superIntent.getExtras();
        if (args != null) {
            args = new Bundle(args);
        } else {//  w w w .  j a va2  s.c  om
            args = new Bundle();
        }
        args.putParcelable("intent", superIntent);
        modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
        return modIntent;
    }
    return superIntent;
}

From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString("ACTION", mAction);
    outState.putParcelable("LIST", mDetails);
    super.onSaveInstanceState(outState);
}

From source file:com.android.mail.ui.ConversationViewFragment.java

/**
 * Creates a new instance of {@link ConversationViewFragment}, initialized
 * to display a conversation with other parameters inherited/copied from an existing bundle,
 * typically one created using {@link #makeBasicArgs}.
 *//*w  ww  . j  a  v  a  2  s  . c  om*/
public static ConversationViewFragment newInstance(Bundle existingArgs, Conversation conversation) {
    ConversationViewFragment f = new ConversationViewFragment();
    Bundle args = new Bundle(existingArgs);
    args.putParcelable(ARG_CONVERSATION, conversation);
    f.setArguments(args);
    return f;
}

From source file:at.alladin.rmbt.android.adapter.result.RMBTResultPagerAdapter.java

@Override
public Parcelable saveState() {
    Log.d("RMBT SAVE STATE", "Saving state in ResultPagerAdapter");
    Bundle bundle = new Bundle();
    bundle.putParcelable("instanceState", super.saveState());
    if (testResult != null) {
        bundle.putString("test_result", testResult.toString());
    }//  w  ww.j a  v  a2s . com
    if (testResultDetails != null) {
        bundle.putString("test_result_details", testResultDetails.toString());
    }
    if (testGraphResult != null) {
        bundle.putString("test_result_graph", testGraphResult.toString());
    }
    if (testResultQoSDetails != null) {
        bundle.putString("test_result_qos", testResultQoSDetails.getTestResultArray().toString());
    }
    return bundle;
}

From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java

@Override
public boolean onMenuItemClick(final MenuItem item) {
    final ParcelableStatus status = mSelectedStatus;
    if (status == null)
        return false;
    final long account_id = getDefaultAccountId(mApplication);
    switch (item.getItemId()) {
    case MENU_VIEW: {
        openStatus(getActivity(), status);
        break;//ww w .j  a  v  a 2 s.c  o  m
    }
    case MENU_SHARE: {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, "@" + status.screen_name + ": " + status.text_plain);
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
        break;
    }
    case MENU_TRANSLATE: {
        translate(status);
        break;
    }
    case MENU_RETWEET: {
        if (isMyRetweet(status)) {
            mService.destroyStatus(status.account_id, status.status_id);
        } else {
            final long id_to_retweet = mSelectedStatus.is_retweet && mSelectedStatus.retweet_id > 0
                    ? mSelectedStatus.retweet_id
                    : mSelectedStatus.status_id;
            mService.retweetStatus(status.account_id, id_to_retweet);
        }
        break;
    }
    case MENU_QUOTE: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putBoolean(INTENT_KEY_IS_QUOTE, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_QUOTE_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name);
        bundle.putBoolean(INTENT_KEY_IS_QUOTE, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_ADD_TO_BUFFER: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putBoolean(INTENT_KEY_IS_BUFFER, true);
        bundle.putString(INTENT_KEY_TEXT, getQuoteStatus(getActivity(), status.screen_name, status.text_plain));
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_REPLY: {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        final List<String> mentions = new Extractor().extractMentionedScreennames(status.text_plain);
        mentions.remove(status.screen_name);
        mentions.add(0, status.screen_name);
        bundle.putStringArray(INTENT_KEY_MENTIONS, mentions.toArray(new String[mentions.size()]));
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, status.account_id);
        bundle.putLong(INTENT_KEY_IN_REPLY_TO_ID, status.status_id);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_TWEET, status.text_plain);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, status.screen_name);
        bundle.putString(INTENT_KEY_IN_REPLY_TO_NAME, status.name);
        intent.putExtras(bundle);
        startActivity(intent);
        break;
    }
    case MENU_FAV: {
        if (mSelectedStatus.is_favorite) {
            mService.destroyFavorite(status.account_id, status.status_id);
        } else {
            mService.createFavorite(status.account_id, status.status_id);
        }
        break;
    }
    case MENU_CONVERSATION: {
        openConversation(getActivity(), status.account_id, status.status_id);
        break;
    }
    case MENU_DELETE: {
        mService.destroyStatus(status.account_id, status.status_id);
        break;
    }
    case MENU_EXTENSIONS: {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_STATUS, status);
        intent.putExtras(extras);
        startActivity(Intent.createChooser(intent, getString(R.string.open_with_extensions)));
        break;
    }
    case MENU_MULTI_SELECT: {
        if (!mApplication.isMultiSelectActive()) {
            mApplication.startMultiSelect();
        }
        final NoDuplicatesLinkedList<Object> list = mApplication.getSelectedItems();
        if (!list.contains(status)) {
            list.add(status);
        }
        break;
    }
    case MENU_BLOCK: {
        mService.createBlock(account_id, status.user_id);
        break;
    }
    case MENU_REPORT_SPAM: {
        mService.reportSpam(account_id, status.user_id);
        break;
    }
    case MENU_MUTE_USER: {
        final String screen_name = status.screen_name;
        final Uri uri = Filters.Users.CONTENT_URI;
        final ContentValues values = new ContentValues();
        final SharedPreferences.Editor editor = getSharedPreferences(SHARED_PREFERENCES_NAME,
                Context.MODE_PRIVATE).edit();
        final ContentResolver resolver = getContentResolver();
        values.put(Filters.Users.TEXT, screen_name);
        resolver.delete(uri, Filters.Users.TEXT + " = '" + screen_name + "'", null);
        resolver.insert(uri, values);
        editor.putBoolean(PREFERENCE_KEY_ENABLE_FILTER, true).commit();
        Toast.makeText(getActivity(), R.string.user_muted, Toast.LENGTH_SHORT).show();
        break;
    }
    case MENU_MAKE_GAP: {
        Uri uri = Statuses.CONTENT_URI;
        final Uri query_uri = buildQueryUri(uri, false);
        ContentResolver mResolver = getContentResolver();
        final ContentValues values = new ContentValues();
        values.put(Statuses.IS_GAP, 1);
        final StringBuilder where = new StringBuilder();
        where.append(Statuses.ACCOUNT_ID + "=" + account_id);
        where.append(" AND " + Statuses.STATUS_ID + "=" + status.status_id);
        mResolver.update(query_uri, values, where.toString(), null);
        getActivity().sendBroadcast(new Intent(BROADCAST_FILTERS_UPDATED).putExtra(INTENT_KEY_SUCCEED, true));
        break;
    }
    case MENU_COPY: {
        final CharSequence text = Html.fromHtml(status.text_html);
        if (ClipboardUtils.setText(getActivity(), text)) {
            Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show();
        }
        break;
    }
    }
    return true;
}

From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (resultCode != RESULT_OK)
        return;/*from  w  w w.  j  a  v a 2s.  c  o  m*/

    switch (requestCode) {
    case SELECT_FILE_REQ:
        // clear previous data
        mFilePath = null;
        mFileStreamUri = null;

        // and read new one
        final Uri uri = data.getData();
        /*
         * The URI returned from application may be in 'file' or 'content' schema.
         * 'File' schema allows us to create a File object and read details from if directly.
         * 
         * Data from 'Content' schema must be read by Content Provider. To do that we are using a Loader.
         */
        if (uri.getScheme().equals("file")) {
            // the direct path to the file has been returned
            final String path = uri.getPath();
            final File file = new File(path);
            mFilePath = path;

            mFileNameView.setText(file.getName());
            mFileSizeView.setText(getString(R.string.dfu_file_size_text, file.length()));
            final boolean isHexFile = mStatusOk = MimeTypeMap.getFileExtensionFromUrl(path)
                    .equalsIgnoreCase("HEX");
            mFileStatusView.setText(isHexFile ? R.string.dfu_file_status_ok : R.string.dfu_file_status_invalid);
            mUploadButton.setEnabled(mSelectedDevice != null && isHexFile);
        } else if (uri.getScheme().equals("content")) {
            // an Uri has been returned
            mFileStreamUri = uri;
            // if application returned Uri for streaming, let's us it. Does it works?
            // FIXME both Uris works with Google Drive app. Why both? What's the difference? How about other apps like DropBox?
            final Bundle extras = data.getExtras();
            if (extras != null && extras.containsKey(Intent.EXTRA_STREAM))
                mFileStreamUri = extras.getParcelable(Intent.EXTRA_STREAM);

            // file name and size must be obtained from Content Provider
            final Bundle bundle = new Bundle();
            bundle.putParcelable(EXTRA_URI, uri);
            getSupportLoaderManager().restartLoader(0, bundle, this);
        }
        break;
    default:
        break;
    }
}