Example usage for android.os Bundle getParcelableArray

List of usage examples for android.os Bundle getParcelableArray

Introduction

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

Prototype

@Nullable
public Parcelable[] getParcelableArray(@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.vk.sdk.dialogs.VKShareDialog.java

@NonNull
@Override//from   www  .j a  va  2  s.c o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    View mInternalView = LayoutInflater.from(context).inflate(R.layout.vk_share_dialog, null);

    assert mInternalView != null;

    mSendButton = (Button) mInternalView.findViewById(R.id.sendButton);
    mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress);
    mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer);
    mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText);
    mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView);

    LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout);

    mSendButton.setOnClickListener(sendButtonPress);

    //Attachment text
    if (savedInstanceState != null) {
        mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY));
        mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY);
        mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY);
        mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY);
    } else if (mAttachmentText != null) {
        mShareTextField.setText(mAttachmentText);
    }

    //Attachment photos
    mPhotoLayout.removeAllViews();
    if (mAttachmentImages != null) {
        for (VKUploadImage mAttachmentImage : mAttachmentImages) {
            addBitmapToPreview(mAttachmentImage.mImageData);
        }
        mPhotoLayout.setVisibility(View.VISIBLE);
    }

    if (mExistingPhotos != null) {
        processExistingPhotos();
    }
    if (mExistingPhotos == null && mAttachmentImages == null) {
        mPhotoLayout.setVisibility(View.GONE);
    }

    //Attachment link
    if (mAttachmentLink != null) {
        TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle),
                linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost);

        linkTitle.setText(mAttachmentLink.linkTitle);
        linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl));
        mAttachmentLinkLayout.setVisibility(View.VISIBLE);
    } else {
        mAttachmentLinkLayout.setVisibility(View.GONE);
    }
    Dialog result = new Dialog(context);
    result.requestWindowFeature(Window.FEATURE_NO_TITLE);
    result.setContentView(mInternalView);
    result.setCancelable(true);
    result.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (mListener != null) {
                mListener.onVkShareCancel();
            }
            VKShareDialog.this.dismiss();
        }
    });
    return result;
}

From source file:li.barter.fragments.SelectPreferredLocationFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    init(container, savedInstanceState);
    setHasOptionsMenu(true);// w w w .  ja  v a  2s.co  m
    final View contentView = inflater.inflate(R.layout.fragment_select_location, container, false);

    mVenueListView = (ListView) contentView.findViewById(R.id.list_locations);
    mSelectLocationAdapter = new SelectLocationAdapter(getActivity(), null, true);
    mVenueListView.setAdapter(mSelectLocationAdapter);
    mVenueListView.setOnItemClickListener(this);

    mEnableLocationDialogFragment = (EnableLocationDialogFragment) getFragmentManager()
            .findFragmentByTag(FragmentTags.DIALOG_ENABLE_LOCATION);

    mEmptyView = contentView.findViewById(R.id.empty_view);
    mEmptyView.setVisibility(View.GONE);
    mEmptyView.findViewById(R.id.text_try_again).setOnClickListener(this);
    mEmptyView.findViewById(R.id.text_add_manually).setOnClickListener(this);

    //showInfiniteCrouton(R.string.crouton_prefferedlocation_message, AlertStyle.INFO);
    mFoursquareClientId = getString(R.string.foursquare_client_id);
    mFoursquareClientSecret = getString(R.string.foursquare_client_secret);

    if (savedInstanceState != null) {
        mVenues = (Venue[]) savedInstanceState.getParcelableArray(Keys.LOCATIONS);
        mIsOverlayShown = savedInstanceState.getBoolean(Keys.OVERLAY_VISIBLE);
    }

    if (mIsOverlayShown) {
        showOverlay();
    }
    if ((mVenues == null) || (mVenues.length == 0)) {
        fetchVenuesForLocation(DeviceInfo.INSTANCE.getLatestLocation(), SEARCH_RADIUS_IN_METERS);
    } else {
        mSelectLocationAdapter.setVenues(mVenues);
    }
    return contentView;
}

From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java

@Override
protected void onSceneResult(int requestCode, int resultCode, Bundle data) {
    switch (requestCode) {
    case REQUEST_CODE_COMMENT_GALLERY:
        if (resultCode != RESULT_OK || data == null) {
            break;
        }/*from  w w w  .  j a va  2s.  com*/
        Parcelable[] array = data.getParcelableArray(GalleryCommentsScene.KEY_COMMENTS);
        if (!(array instanceof GalleryComment[])) {
            break;
        }
        GalleryComment[] comments = (GalleryComment[]) array;
        if (mGalleryDetail == null) {
            break;
        }
        mGalleryDetail.comments = comments;
        bindComments(comments);
        break;
    default:
        super.onSceneResult(requestCode, resultCode, data);
    }
}

From source file:tv.ouya.sample.IapSampleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ouyaFacade = OuyaFacade.getInstance();
    ouyaFacade.init(this, DEVELOPER_ID);

    // Uncomment this line to test against the server using "fake" credits.
    // This will also switch over to a separate "test" purchase history.
    //ouyaFacade.setTestMode();

    setContentView(R.layout.sample_app);

    receiptListView = (ListView) findViewById(R.id.receipts);
    receiptListView.setFocusable(false);

    /*/*from  w  ww .  j a  v a 2 s. c o m*/
     * In order to avoid "application not responding" popups, Android demands that long-running operations
     * happen on a background thread. Listener objects provide a way for you to specify what ought to happen
     * at the end of the long-running operation. Examples of this pattern in Android include
     * android.os.AsyncTask.
     */
    findViewById(R.id.gamer_uuid_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fetchGamerUUID();
        }
    });

    // Attempt to restore the product and receipt list from the savedInstanceState Bundle
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) {
            Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY);
            mProductList = new ArrayList<Product>(products.length);
            for (Parcelable product : products) {
                mProductList.add((Product) product);
            }
            addProducts();
        }
        if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) {
            Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY);
            mReceiptList = new ArrayList<Receipt>(receipts.length);
            for (Parcelable receipt : receipts) {
                mReceiptList.add((Receipt) receipt);
            }
            addReceipts();
        }
    }

    // Request the product list if it could not be restored from the savedInstanceState Bundle
    if (mProductList == null) {
        requestProducts();
    }

    // Make sure the receipt ListView starts empty if the receipt list could not be restored
    // from the savedInstanceState Bundle.
    if (mReceiptList == null) {
        receiptListView.setAdapter(new ReceiptAdapter(this, new Receipt[0]));
    }

    // Create a PublicKey object from the key data downloaded from the developer portal.
    try {
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(APPLICATION_KEY);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        mPublicKey = keyFactory.generatePublic(keySpec);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Unable to create encryption key", e);
    }
}

From source file:com.guillaumesoft.escapehellprison.PurchaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mOuyaFacade = OuyaFacade.getInstance();
    Bundle developerInfo = new Bundle();
    developerInfo.putString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID);
    developerInfo.putByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, loadApplicationKey());
    mOuyaFacade = OuyaFacade.getInstance();
    mOuyaFacade.init(this, developerInfo);

    // Uncomment this line to test against the server using "fake" credits.
    // This will also switch over to a separate "test" purchase history.
    //ouyaFacade.setTestMode();

    setContentView(R.layout.sample_app);

    receiptListView = (ListView) findViewById(R.id.receipts);
    receiptListView.setFocusable(false);

    /*//from  w  w w .  j a  v  a 2s.  com
     * In order to avoid "application not responding" popups, Android demands that long-running operations
     * happen on a background thread. Listener objects provide a way for you to specify what ought to happen
     * at the end of the long-running operation. Examples of this pattern in Android include
     * android.os.AsyncTask.
     */
    findViewById(R.id.gamer_uuid_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fetchGamerInfo();
        }
    });

    // Attempt to restore the product and receipt list from the savedInstanceState Bundle
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) {
            Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY);
            mProductList = new ArrayList<Product>(products.length);

            for (Parcelable product : products) {
                mProductList.add((Product) product);
            }
            addProducts();
        }

        if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) {
            Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY);
            mReceiptList = new ArrayList<Receipt>(receipts.length);

            for (Parcelable receipt : receipts) {
                mReceiptList.add((Receipt) receipt);
            }
            addReceipts();
        }
    }

    // Request the product list if it could not be restored from the savedInstanceState Bundle
    if (mProductList == null) {
        requestProducts();
    }

    // Make sure the receipt ListView starts empty if the receipt list could not be restored
    // from the savedInstanceState Bundle.
    if (mReceiptList == null) {
        receiptListView.setAdapter(new ReceiptAdapter(this, new Receipt[0]));
    }

    // Create a PublicKey object from the key data downloaded from the developer portal.
    try {
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(loadApplicationKey());
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        mPublicKey = keyFactory.generatePublic(keySpec);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Unable to create encryption key", e);
    }
}

From source file:com.borax12.materialdaterangepicker.single.time.TimePickerDialog.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_INITIAL_TIME)
            && savedInstanceState.containsKey(KEY_IS_24_HOUR_VIEW)) {
        mInitialTime = savedInstanceState.getParcelable(KEY_INITIAL_TIME);
        mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
        mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mSelectableTimes = (Timepoint[]) savedInstanceState.getParcelableArray(KEY_SELECTABLE_TIMES);
        mMinTime = savedInstanceState.getParcelable(KEY_MIN_TIME);
        mMaxTime = savedInstanceState.getParcelable(KEY_MAX_TIME);
        mEnableSeconds = savedInstanceState.getBoolean(KEY_ENABLE_SECONDS);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }/* ww w. ja va2s . c om*/
}

From source file:com.goodhustle.ouyaunitybridge.OuyaUnityActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    OuyaController.init(this);

    // Initialize ouyaFacade
    ouyaFacade = OuyaFacade.getInstance();
    ouyaFacade.init(this, DEVELOPER_ID);
    userManager = UserManager.getInstance(this);
    playerStates = new ControllerState[OuyaController.MAX_CONTROLLERS];
    for (int i = 0; i < OuyaController.MAX_CONTROLLERS; i++) {
        playerStates[i] = new ControllerState();
    }/*  w  w  w  . j  a  va2  s . com*/

    // Create the UnityPlayer
    mUnityPlayer = new UnityPlayer(this);
    int glesMode = mUnityPlayer.getSettings().getInt("gles_mode", 1);
    boolean trueColor8888 = false;
    mUnityPlayer.init(glesMode, trueColor8888);
    setContentView(R.layout.main);

    // Add the Unity view
    FrameLayout layout = (FrameLayout) findViewById(R.id.unityLayout);
    LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    layout.addView(mUnityPlayer.getView(), 0, lp);

    // Set the focus
    RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.mainLayout);
    mainLayout.setFocusableInTouchMode(true);

    // Attempt to restore the product and receipt list from the savedInstanceState Bundle
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) {
            Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY);
            mProductList = new ArrayList<Product>(products.length);
            for (Parcelable product : products) {
                mProductList.add((Product) product);
            }
            addProducts();
        }
        if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) {
            Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY);
            mReceiptList = new ArrayList<Receipt>(receipts.length);
            for (Parcelable receipt : receipts) {
                mReceiptList.add((Receipt) receipt);
            }
            addReceipts();
        }
    }

    // Request the product list if it could not be restored from the savedInstanceState Bundle
    if (mProductList == null) {
        requestProducts();
    }

    // Create a PublicKey object from the key data downloaded from the developer portal.
    try {
        X509EncodedKeySpec keySpec = new X509EncodedKeySpec(APPLICATION_KEY);
        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        mPublicKey = keyFactory.generatePublic(keySpec);
    } catch (Exception e) {
        Log.e(LOG_TAG, "Unable to create encryption key", e);
    }
}

From source file:androidx.media.MediaController2.java

void onConnectedNotLocked(Bundle data) {
    // is enough or should we pass it while connecting?
    final SessionCommandGroup2 allowedCommands = SessionCommandGroup2
            .fromBundle(data.getBundle(ARGUMENT_ALLOWED_COMMANDS));
    final int playerState = data.getInt(ARGUMENT_PLAYER_STATE);
    final int bufferingState = data.getInt(ARGUMENT_BUFFERING_STATE);
    final PlaybackStateCompat playbackStateCompat = data.getParcelable(ARGUMENT_PLAYBACK_STATE_COMPAT);
    final int repeatMode = data.getInt(ARGUMENT_REPEAT_MODE);
    final int shuffleMode = data.getInt(ARGUMENT_SHUFFLE_MODE);
    final List<MediaItem2> playlist = MediaUtils2
            .fromMediaItem2ParcelableArray(data.getParcelableArray(ARGUMENT_PLAYLIST));
    final MediaItem2 currentMediaItem = MediaItem2.fromBundle(data.getBundle(ARGUMENT_MEDIA_ITEM));
    final PlaybackInfo playbackInfo = PlaybackInfo.fromBundle(data.getBundle(ARGUMENT_PLAYBACK_INFO));
    final MediaMetadata2 metadata = MediaMetadata2.fromBundle(data.getBundle(ARGUMENT_PLAYLIST_METADATA));
    if (DEBUG) {/*from w  w  w. ja  v a 2s .co m*/
        Log.d(TAG, "onConnectedNotLocked sessionCompatToken=" + mToken.getSessionCompatToken()
                + ", allowedCommands=" + allowedCommands);
    }
    boolean close = false;
    try {
        synchronized (mLock) {
            if (mIsReleased) {
                return;
            }
            if (mConnected) {
                Log.e(TAG, "Cannot be notified about the connection result many times."
                        + " Probably a bug or malicious app.");
                close = true;
                return;
            }
            mAllowedCommands = allowedCommands;
            mPlayerState = playerState;
            mBufferingState = bufferingState;
            mPlaybackStateCompat = playbackStateCompat;
            mRepeatMode = repeatMode;
            mShuffleMode = shuffleMode;
            mPlaylist = playlist;
            mCurrentMediaItem = currentMediaItem;
            mPlaylistMetadata = metadata;
            mConnected = true;
            mPlaybackInfo = playbackInfo;
        }
        mCallbackExecutor.execute(new Runnable() {
            @Override
            public void run() {
                // Note: We may trigger ControllerCallbacks with the initial values
                // But it's hard to define the order of the controller callbacks
                // Only notify about the
                mCallback.onConnected(MediaController2.this, allowedCommands);
            }
        });
    } finally {
        if (close) {
            // Trick to call release() without holding the lock, to prevent potential deadlock
            // with the developer's custom lock within the ControllerCallback.onDisconnected().
            close();
        }
    }
}

From source file:com.example.suspectedBug.myapplication.IapSampleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle developerInfo = new Bundle();
    developerInfo.putString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID);
    developerInfo.putByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, APPLICATION_KEY);

    ouyaFacade = OuyaFacade.getInstance();
    ouyaFacade.init(this, developerInfo);

    // Uncomment this line to test against the server using "fake" credits.
    // This will also switch over to a separate "test" purchase history.
    //ouyaFacade.setTestMode();

    setContentView(R.layout.sample_app);

    receiptListView = (ListView) findViewById(R.id.receipts);
    receiptListView.setFocusable(false);

    /*//w  w  w .j  a v  a  2 s. c  o m
     * In order to avoid "application not responding" popups, Android demands that long-running operations
     * happen on a background thread. Listener objects provide a way for you to specify what ought to happen
     * at the end of the long-running operation. Examples of this pattern in Android include
     * android.os.AsyncTask.
     */
    /*findViewById(R.id.gamer_uuid_button).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        fetchGamerInfo();
    }
    });*/

    findViewById(R.id.openOtherActivity).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent openOtherActivityIntent = new Intent(IapSampleActivity.this, MainActivity.class);
            startActivity(openOtherActivityIntent);
        }
    });

    // Attempt to restore the product and receipt list from the savedInstanceState Bundle
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) {
            Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY);
            mProductList = new ArrayList<Product>(products.length);
            for (Parcelable product : products) {
                mProductList.add((Product) product);
            }
            addProducts();
        }
        if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) {
            Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY);
            mReceiptList = new ArrayList<Receipt>(receipts.length);
            for (Parcelable receipt : receipts) {
                mReceiptList.add((Receipt) receipt);
            }
            addReceipts();
        }
    }

    // Request the product list if it could not be restored from the savedInstanceState Bundle
    if (mProductList == null) {
        requestProducts();
    }

    // Make sure the receipt ListView starts empty if the receipt list could not be restored
    // from the savedInstanceState Bundle.
    if (mReceiptList == null) {
        receiptListView.setAdapter(new ReceiptAdapter(this, new Receipt[0]));
    }
}

From source file:com.jarklee.materialdatetimepicker.time.TimePickerDialog.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_INITIAL_TIME)
            && savedInstanceState.containsKey(KEY_IS_24_HOUR_VIEW)) {
        mInitialTime = savedInstanceState.getParcelable(KEY_INITIAL_TIME);
        mIs24HourMode = savedInstanceState.getBoolean(KEY_IS_24_HOUR_VIEW);
        mInKbMode = savedInstanceState.getBoolean(KEY_IN_KB_MODE);
        mTitle = savedInstanceState.getString(KEY_TITLE);
        mThemeDark = savedInstanceState.getBoolean(KEY_THEME_DARK);
        mThemeDarkChanged = savedInstanceState.getBoolean(KEY_THEME_DARK_CHANGED);
        mAccentColor = savedInstanceState.getInt(KEY_ACCENT);
        mVibrate = savedInstanceState.getBoolean(KEY_VIBRATE);
        mDismissOnPause = savedInstanceState.getBoolean(KEY_DISMISS);
        mSelectableTimes = (Timepoint[]) savedInstanceState.getParcelableArray(KEY_SELECTABLE_TIMES);
        mMinTime = savedInstanceState.getParcelable(KEY_MIN_TIME);
        mMaxTime = savedInstanceState.getParcelable(KEY_MAX_TIME);
        mEnableSeconds = savedInstanceState.getBoolean(KEY_ENABLE_SECONDS);
        mEnableMinutes = savedInstanceState.getBoolean(KEY_ENABLE_MINUTES);
        mOkResid = savedInstanceState.getInt(KEY_OK_RESID);
        mOkString = savedInstanceState.getString(KEY_OK_STRING);
        mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID);
        mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING);
    }//ww w. java 2  s.  c  o m
}