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:cc.mintcoin.wallet.ui.SendCoinsFragment.java

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

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

    validatedAddress = savedInstanceState.getParcelable("validated_address");

    if (savedInstanceState.containsKey("sent_transaction_hash")) {
        sentTransaction = wallet//from   w ww .java 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:com.chute.android.photopickerplus.ui.activity.ServicesActivity.java

private void retrieveValuesFromBundle(Bundle savedInstanceState) {
    accountItemPositions = savedInstanceState != null
            ? savedInstanceState.getIntegerArrayList(Constants.KEY_SELECTED_ACCOUNTS_ITEMS)
            : null;/*from  ww  w.ja v a2s.c o m*/

    imageItemPositions = savedInstanceState != null
            ? savedInstanceState.getIntegerArrayList(Constants.KEY_SELECTED_IMAGES_ITEMS)
            : null;

    videoItemPositions = savedInstanceState != null
            ? savedInstanceState.getIntegerArrayList(Constants.KEY_SELECTED_VIDEOS_ITEMS)
            : null;

    folderId = savedInstanceState != null ? savedInstanceState.getString(Constants.KEY_FOLDER_ID) : null;

    account = (AccountModel) (savedInstanceState != null
            ? savedInstanceState.getParcelable(Constants.KEY_ACCOUNT)
            : null);

    photoFilterType = savedInstanceState != null ? savedInstanceState.getInt(Constants.KEY_PHOTO_FILTER_TYPE)
            : 0;

}

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

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    final TweetingsApplication application = getApplication();
    mService = application.getServiceInterface();
    mLazyImageLoader = application.getImageLoaderWrapper();
    mImagesPreviewFragment = (ImagesPreviewFragment) Fragment.instantiate(getActivity(),
            ImagesPreviewFragment.class.getName());
    super.onActivityCreated(savedInstanceState);
    setRetainInstance(true);/*  w w  w  .  j av a2  s.  co m*/
    mLoadMoreAutomatically = mPreferences.getBoolean(PREFERENCE_KEY_LOAD_MORE_AUTOMATICALLY, true);
    final Bundle bundle = getArguments();
    if (bundle != null) {
        mAccountId = bundle.getLong(INTENT_KEY_ACCOUNT_ID);
        mStatusId = bundle.getLong(INTENT_KEY_STATUS_ID);
        bundle.setClassLoader(ParcelableStatus.class.getClassLoader());
        mStatus = bundle.getParcelable(INTENT_KEY_STATUS);
        mImagesPreviewFragment.setStatus(mStatus);
    }
    mInReplyToView.setOnClickListener(this);
    mFollowButton.setOnClickListener(this);
    mProfileView.setOnClickListener(this);
    mLocationView.setOnClickListener(this);
    mRetweetedStatusView.setOnClickListener(this);
    mMenuBar.setOnMenuItemClickListener(this);
    final FragmentManager fm = getFragmentManager();
    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.images_preview, mImagesPreviewFragment);
    ft.commit();
    //if (mStatus != null) {
    //displayStatus(mStatus);
    //} else {
    //getStatus(false);
    //}

}

From source file:cn.njmeter.njmeter.widget.spinner.NiceSpinner.java

@Override
public void onRestoreInstanceState(Parcelable savedState) {
    if (savedState instanceof Bundle) {
        Bundle bundle = (Bundle) savedState;
        selectedIndex = bundle.getInt(SELECTED_INDEX);

        if (adapter != null) {
            setTextInternal(adapter.getItemInDataset(selectedIndex).toString());
            adapter.setSelectedIndex(selectedIndex);
        }/*from  w  ww  .  ja v  a  2  s . c  om*/

        if (bundle.getBoolean(IS_POPUP_SHOWING)) {
            if (popupWindow != null) {
                // Post the show request into the looper to avoid bad token exception
                post(new Runnable() {
                    @Override
                    public void run() {
                        showDropDown();
                    }
                });
            }
        }

        isArrowHidden = bundle.getBoolean(IS_ARROW_HIDDEN, false);
        arrowDrawableResId = bundle.getInt(ARROW_DRAWABLE_RES_ID);
        savedState = bundle.getParcelable(INSTANCE_STATE);
    }
    super.onRestoreInstanceState(savedState);
}

From source file:ca.ualberta.cmput301w14t08.geochan.fragments.PostFragment.java

/**
 * Resumes the fragment, updating the location and textview states accordingly.
 *//* w  w w.ja v a 2s .com*/
@Override
public void onResume() {
    super.onResume();
    Bundle args = getArguments();
    if (args != null) {
        if (args.containsKey("LATITUDE") && args.containsKey("LONGITUDE")) {
            Button locButton = (Button) getActivity().findViewById(R.id.location_button);
            if (args.getString("LocationType") == "CURRENT_LOCATION") {
                locButton.setText("Location: Set");
            } else {
                Double lat = args.getDouble("LATITUDE");
                Double lon = args.getDouble("LONGITUDE");
                geoLocation = new GeoLocation(lat, lon);

                String locationDescription = args.getString("locationDescription");
                geoLocation.setLocationDescription(locationDescription);

                locButton.setText("Location: Set");
            }
        }
        if (args.containsKey("IMAGE_THUMB") && args.containsKey("IMAGE_FULL")) {
            imageThumb = args.getParcelable("IMAGE_THUMB");
            image = args.getParcelable("IMAGE_FULL");
        }
    }
}

From source file:com.app.uafeed.fragment.EntryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_entry, container, false);

    mCancelFullscreenBtn = rootView.findViewById(R.id.cancelFullscreenBtn);
    mCancelFullscreenBtn.setOnClickListener(new View.OnClickListener() {
        @Override//from   w ww  .jav  a 2s.co  m
        public void onClick(View view) {
            toggleFullScreen();
        }
    });

    mEntryPager = (ViewPager) rootView.findViewById(R.id.pager);
    //mEntryPager.setPageTransformer(true, new DepthPageTransformer());
    mEntryPager.setAdapter(mEntryPagerAdapter);

    if (savedInstanceState != null) {
        mBaseUri = savedInstanceState.getParcelable(STATE_BASE_URI);
        mEntriesIds = savedInstanceState.getLongArray(STATE_ENTRIES_IDS);
        mInitialEntryId = savedInstanceState.getLong(STATE_INITIAL_ENTRY_ID);
        mCurrentPagerPos = savedInstanceState.getInt(STATE_CURRENT_PAGER_POS);
        mEntryPager.getAdapter().notifyDataSetChanged();
        mEntryPager.setCurrentItem(mCurrentPagerPos);
        mEntryPagerAdapter.setScrollPercentage(savedInstanceState.getFloat(STATE_SCROLL_PERCENTAGE));
    }

    mEntryPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i2) {
        }

        @Override
        public void onPageSelected(int i) {
            mCurrentPagerPos = i;
            mEntryPagerAdapter.onPause(); // pause all webviews
            mEntryPagerAdapter.onResume(); // resume the current webview

            refreshUI(mEntryPagerAdapter.getCursor(i));
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });

    return rootView;
}

From source file:ir.aarani.bazaar.billing.BillingProcessor.java

private boolean purchase(Activity activity, List<String> oldProductIds, String productId, String purchaseType,
        String developerPayload) {
    if (!isInitialized() || TextUtils.isEmpty(productId) || TextUtils.isEmpty(purchaseType))
        return false;
    try {//from   w  w  w  .  j  a  v a2  s  .com
        String purchasePayload = purchaseType + ":" + productId;
        if (!purchaseType.equals(Constants.PRODUCT_TYPE_SUBSCRIPTION)) {
            purchasePayload += ":" + UUID.randomUUID().toString();
        }
        if (developerPayload != null) {
            purchasePayload += ":" + developerPayload;
        }
        savePurchasePayload(purchasePayload);
        Bundle bundle;
        if (oldProductIds != null && purchaseType.equals(Constants.PRODUCT_TYPE_SUBSCRIPTION))
            bundle = billingService.getBuyIntentToReplaceSkus(Constants.GOOGLE_API_SUBSCRIPTION_CHANGE_VERSION,
                    contextPackageName, oldProductIds, productId, purchaseType, purchasePayload);
        else
            bundle = billingService.getBuyIntent(Constants.GOOGLE_API_VERSION, contextPackageName, productId,
                    purchaseType, purchasePayload);

        if (bundle != null) {
            int response = bundle.getInt(Constants.RESPONSE_CODE);
            if (response == Constants.BILLING_RESPONSE_RESULT_OK) {
                PendingIntent pendingIntent = bundle.getParcelable(Constants.BUY_INTENT);
                if (activity != null && pendingIntent != null)
                    activity.startIntentSenderForResult(pendingIntent.getIntentSender(),
                            PURCHASE_FLOW_REQUEST_CODE, new Intent(), 0, 0, 0);
                else if (eventHandler != null)
                    eventHandler.onBillingError(Constants.BILLING_ERROR_LOST_CONTEXT, null);
            } else if (response == Constants.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
                if (!isPurchased(productId) && !isSubscribed(productId))
                    loadOwnedPurchasesFromGoogle();
                TransactionDetails details = getPurchaseTransactionDetails(productId);
                if (!checkMerchant(details)) {
                    Log.i(LOG_TAG, "Invalid or tampered merchant id!");
                    if (eventHandler != null)
                        eventHandler.onBillingError(Constants.BILLING_ERROR_INVALID_MERCHANT_ID, null);
                    return false;
                }
                if (eventHandler != null) {
                    if (details == null)
                        details = getSubscriptionTransactionDetails(productId);
                    eventHandler.onProductPurchased(productId, details);
                }
            } else if (eventHandler != null)
                eventHandler.onBillingError(Constants.BILLING_ERROR_FAILED_TO_INITIALIZE_PURCHASE, null);
        }
        return true;
    } catch (Exception e) {
        Log.e(LOG_TAG, "Error in purchase", e);
        if (eventHandler != null)
            eventHandler.onBillingError(Constants.BILLING_ERROR_OTHER_ERROR, e);
    }
    return false;
}

From source file:com.markupartist.sthlmtraveling.PlannerFragment.java

private void restoreState(Bundle state) {
    mStartPoint = new Site();
    mEndPoint = new Site();
    mViaPoint = new Site();
    if (state != null) {
        Site startPoint = state.getParcelable("startPoint");
        Site endPoint = state.getParcelable("endPoint");
        Site viaPoint = state.getParcelable("viaPoint");
        if (startPoint != null)
            mStartPoint.fromSite(startPoint);
        if (endPoint != null)
            mEndPoint.fromSite(endPoint);
        if (viaPoint != null)
            mViaPoint.fromSite(viaPoint);
    }/*from   w ww.jav a2 s .  co  m*/
}

From source file:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java

protected void resolveChatRoom(Bundle savedInstanceState) {
    qiscusChatRoom = getArguments().getParcelable(CHAT_ROOM_DATA);
    if (qiscusChatRoom == null && savedInstanceState != null) {
        qiscusChatRoom = savedInstanceState.getParcelable(CHAT_ROOM_DATA);
    }/*ww  w.j a v a 2s  . c o m*/

    if (qiscusChatRoom == null) {
        getActivity().finish();
        return;
    }
}