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:in.shick.diode.threads.ThreadsListActivity.java

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    state.putString(Constants.SUBREDDIT_KEY, mSubreddit);
    state.putString(Constants.QUERY_KEY, mSearchQuery);
    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:cgeo.geocaching.CacheListActivity.java

@Override
public void onSaveInstanceState(final Bundle savedInstanceState) {
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);

    // Save the current Filter
    savedInstanceState.putParcelable(STATE_FILTER, currentFilter);
    savedInstanceState.putBoolean(STATE_INVERSE_SORT, adapter.getInverseSort());
    savedInstanceState.putInt(STATE_LIST_TYPE, type.ordinal());
    savedInstanceState.putInt(STATE_LIST_ID, listId);
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openImage(final Context context, final Uri uri, final boolean is_possibly_sensitive) {
    if (context == null || uri == null)
        return;/*  w ww .j  a va2 s . c  o  m*/
    final Intent intent = new Intent(INTENT_ACTION_VIEW_IMAGE);
    intent.setDataAndType(uri, "image/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) {
        intent.setClass(context, ImageViewerGLActivity.class);
    } else {
        intent.setClass(context, ImageViewerActivity.class);
    }
    final SharedPreferences prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    if (context instanceof FragmentActivity && is_possibly_sensitive
            && !prefs.getBoolean(PREFERENCE_KEY_DISPLAY_SENSITIVE_CONTENTS, false)) {
        final FragmentActivity activity = (FragmentActivity) context;
        final FragmentManager fm = activity.getSupportFragmentManager();
        final DialogFragment fragment = new SensitiveContentWarningDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(INTENT_KEY_URI, uri);
        fragment.setArguments(args);
        fragment.show(fm, "sensitive_content_warning");
    } else {
        context.startActivity(intent);
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openStatus(final Activity activity, final ParcelableStatus status) {
    if (activity == null || status == null)
        return;/*from  www.j  a  v  a  2 s. com*/
    final long account_id = status.account_id, status_id = status.status_id;
    final Bundle bundle = new Bundle();
    bundle.putParcelable(INTENT_KEY_STATUS, status);
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment details_fragment = dual_pane_activity.getDetailsFragment();
        if (details_fragment instanceof StatusFragment && details_fragment.isAdded()) {
            ((StatusFragment) details_fragment).displayStatus(status);
            dual_pane_activity.bringRightPaneToFront();
        } else {
            final Fragment fragment = new StatusFragment();
            final Bundle args = new Bundle(bundle);
            args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
            args.putLong(INTENT_KEY_STATUS_ID, status_id);
            fragment.setArguments(args);
            dual_pane_activity.showAtPane(DualPaneActivity.PANE_RIGHT, fragment, true);
        }
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_STATUS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id));
        final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());

        intent.putExtras(bundle);
        activity.startActivity(intent);
    }
}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void takeSketch(Attachment attachment) {

    File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_SKETCH_EXT);
    if (f == null) {
        Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
        //mainActivity.showMessage(R.string.error, ONStyle.ALERT);
        return;//from   ww w . j a v  a2  s  .c  om
    }
    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.dycody.android.idealnote.DetailFragment.java

@SuppressLint("NewApi")
@Override//from   w  ww .  j  a  v a  2  s .c  o  m
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;

    default:
        Log.e(Constants.TAG, "Wrong element choosen: " + event.getAction());
    }

    return true;
}

From source file:com.dwdesign.tweetings.activity.ComposeActivity.java

@Override
public void onSaveInstanceState(final Bundle outState) {
    mText = parseString(mEditText.getText());
    outState.putLongArray(INTENT_KEY_IDS, mAccountIds);
    outState.putString(INTENT_KEY_TEXT, mText);
    outState.putLong(INTENT_KEY_IN_REPLY_TO_ID, mInReplyToStatusId);
    outState.putString(INTENT_KEY_IN_REPLY_TO_NAME, mInReplyToName);
    outState.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, mInReplyToScreenName);
    outState.putBoolean(INTENT_KEY_IS_QUOTE, mIsQuote);
    outState.putBoolean(INTENT_KEY_IS_IMAGE_ATTACHED, mIsImageAttached);
    outState.putBoolean(INTENT_KEY_IS_PHOTO_ATTACHED, mIsPhotoAttached);
    outState.putParcelable(INTENT_KEY_IMAGE_URI, mImageUri);
    outState.putBoolean(INTENT_KEY_CONTENT_MODIFIED, mContentModified);
    outState.putBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE, mIsPossiblySensitive);
    super.onSaveInstanceState(outState);
}

From source file:com.dycody.android.idealnote.DetailFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (noteTmp != null) {
        noteTmp.setTitle(getNoteTitle());
        noteTmp.setContent(getNoteContent());
        outState.putParcelable("noteTmp", noteTmp);
        outState.putParcelable("note", note);
        outState.putParcelable("noteOriginal", noteOriginal);
        outState.putParcelable("attachmentUri", attachmentUri);
        outState.putBoolean("orientationChanged", orientationChanged);
    }/*from w ww . j av  a 2 s .c  o m*/
    super.onSaveInstanceState(outState);
}

From source file:android.app.FragmentState.java

void performSaveInstanceState(Bundle outState) {
    onSaveInstanceState(outState);/*from   ww w . j  a  v a  2  s.  c  o  m*/
    if (mChildFragmentManager != null) {
        Parcelable p = mChildFragmentManager.saveAllState();
        if (p != null) {
            outState.putParcelable(Activity.FRAGMENTS_TAG, p);
        }
    }
}

From source file:com.skubit.android.billing.BillingServiceBinder.java

@Override
public Bundle getBuyIntent(int apiVersion, String userId, String packageName, String sku, String type,
        String developerPayload) throws RemoteException {

    Bundle bundle = new Bundle();
    if (TextUtils.isEmpty(packageName) || TextUtils.isEmpty(sku) || TextUtils.isEmpty(type)) {
        Log.d(TAG, "Missing required parameter");
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR);
        return bundle;
    }//from   w  w  w  . j  a v a  2  s.co m

    if (apiVersion != 1) {
        Log.d(TAG, "Unsupported API: " + apiVersion);
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE);
        return bundle;
    }

    if (!isValidType(type)) {
        Log.d(TAG, "Incorrect billing type: " + type);
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_BILLING_UNAVAILABLE);
        return bundle;
    }

    int packValidate = validatePackageIsOwnedByCaller(packageName);
    if (packValidate != BillingResponseCodes.RESULT_OK) {
        Log.d(TAG, "Package is not owned by caller");
        bundle.putInt("RESPONSE_CODE", packValidate);
        return bundle;
    }

    if (!hasAccess(userId, packageName)) {
        Log.d(TAG, "User account not configured");
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_USER_ACCESS);
        return bundle;
    }
    /**
     * DO we already own this product? method: userId, packageName,
     * productId bundle.putInt("RESPONSE_CODE",
     * BillingResponseCodes.RESULT_ITEM_ALREADY_OWNED)
     */
    Intent purchaseIntent = null;
    if ("inapp".equals(type)) {
        purchaseIntent = makePurchaseIntent(apiVersion, userId, packageName, sku, developerPayload, type);
    }

    if (purchaseIntent == null) {
        bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_DEVELOPER_ERROR);
        return bundle;
    }
    Utils.changeAccount(mContext, userId);

    PendingIntent pending = PendingIntent.getActivity(mContext, (sku + userId).hashCode(), purchaseIntent, 0);
    bundle.putParcelable("BUY_INTENT", pending);

    bundle.putInt("RESPONSE_CODE", BillingResponseCodes.RESULT_OK);
    return bundle;
}