List of usage examples for android.os Bundle getParcelableArray
@Nullable
public Parcelable[] getParcelableArray(@Nullable String key)
From source file:com.customdatepicker.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); mOkColor = savedInstanceState.getInt(KEY_OK_COLOR); mCancelResid = savedInstanceState.getInt(KEY_CANCEL_RESID); mCancelString = savedInstanceState.getString(KEY_CANCEL_STRING); mCancelColor = savedInstanceState.getInt(KEY_CANCEL_COLOR); mVersion = (Version) savedInstanceState.getSerializable(KEY_VERSION); }/* w w w. j ava 2 s . c o m*/ }
From source file:androidx.media.MediaSession2StubImplBase.java
@Override public void onCommand(String command, final Bundle extras, final ResultReceiver cb) { switch (command) { case CONTROLLER_COMMAND_CONNECT: connect(extras, cb);/* ww w .ja v a 2s.c o m*/ break; case CONTROLLER_COMMAND_DISCONNECT: disconnect(extras); break; case CONTROLLER_COMMAND_BY_COMMAND_CODE: { final int commandCode = extras.getInt(ARGUMENT_COMMAND_CODE); IMediaControllerCallback caller = (IMediaControllerCallback) extras .getBinder(ARGUMENT_ICONTROLLER_CALLBACK); if (caller == null) { return; } onCommand2(caller.asBinder(), commandCode, new Session2Runnable() { @Override public void run(ControllerInfo controller) { switch (commandCode) { case COMMAND_CODE_PLAYBACK_PLAY: mSession.play(); break; case COMMAND_CODE_PLAYBACK_PAUSE: mSession.pause(); break; case COMMAND_CODE_PLAYBACK_RESET: mSession.reset(); break; case COMMAND_CODE_PLAYBACK_PREPARE: mSession.prepare(); break; case COMMAND_CODE_PLAYBACK_SEEK_TO: { long seekPos = extras.getLong(ARGUMENT_SEEK_POSITION); mSession.seekTo(seekPos); break; } case COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE: { int repeatMode = extras.getInt(ARGUMENT_REPEAT_MODE); mSession.setRepeatMode(repeatMode); break; } case COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE: { int shuffleMode = extras.getInt(ARGUMENT_SHUFFLE_MODE); mSession.setShuffleMode(shuffleMode); break; } case COMMAND_CODE_PLAYLIST_SET_LIST: { List<MediaItem2> list = MediaUtils2 .fromMediaItem2ParcelableArray(extras.getParcelableArray(ARGUMENT_PLAYLIST)); MediaMetadata2 metadata = MediaMetadata2 .fromBundle(extras.getBundle(ARGUMENT_PLAYLIST_METADATA)); mSession.setPlaylist(list, metadata); break; } case COMMAND_CODE_PLAYLIST_SET_LIST_METADATA: { MediaMetadata2 metadata = MediaMetadata2 .fromBundle(extras.getBundle(ARGUMENT_PLAYLIST_METADATA)); mSession.updatePlaylistMetadata(metadata); break; } case COMMAND_CODE_PLAYLIST_ADD_ITEM: { int index = extras.getInt(ARGUMENT_PLAYLIST_INDEX); MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.addPlaylistItem(index, item); break; } case COMMAND_CODE_PLAYLIST_REMOVE_ITEM: { MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.removePlaylistItem(item); break; } case COMMAND_CODE_PLAYLIST_REPLACE_ITEM: { int index = extras.getInt(ARGUMENT_PLAYLIST_INDEX); MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.replacePlaylistItem(index, item); break; } case COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM: { mSession.skipToNextItem(); break; } case COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM: { mSession.skipToPreviousItem(); break; } case COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM: { MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.skipToPlaylistItem(item); break; } case COMMAND_CODE_VOLUME_SET_VOLUME: { int value = extras.getInt(ARGUMENT_VOLUME); int flags = extras.getInt(ARGUMENT_VOLUME_FLAGS); VolumeProviderCompat vp = mSession.getVolumeProvider(); if (vp == null) { // TODO: Revisit } else { vp.onSetVolumeTo(value); } break; } case COMMAND_CODE_VOLUME_ADJUST_VOLUME: { int direction = extras.getInt(ARGUMENT_VOLUME_DIRECTION); int flags = extras.getInt(ARGUMENT_VOLUME_FLAGS); VolumeProviderCompat vp = mSession.getVolumeProvider(); if (vp == null) { // TODO: Revisit } else { vp.onAdjustVolume(direction); } break; } case COMMAND_CODE_SESSION_REWIND: { mSession.getCallback().onRewind(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_FAST_FORWARD: { mSession.getCallback().onFastForward(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID: { String mediaId = extras.getString(ARGUMENT_MEDIA_ID); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPlayFromMediaId(mSession.getInstance(), controller, mediaId, extra); break; } case COMMAND_CODE_SESSION_PLAY_FROM_SEARCH: { String query = extras.getString(ARGUMENT_QUERY); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPlayFromSearch(mSession.getInstance(), controller, query, extra); break; } case COMMAND_CODE_SESSION_PLAY_FROM_URI: { Uri uri = extras.getParcelable(ARGUMENT_URI); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPlayFromUri(mSession.getInstance(), controller, uri, extra); break; } case COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID: { String mediaId = extras.getString(ARGUMENT_MEDIA_ID); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPrepareFromMediaId(mSession.getInstance(), controller, mediaId, extra); break; } case COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH: { String query = extras.getString(ARGUMENT_QUERY); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPrepareFromSearch(mSession.getInstance(), controller, query, extra); break; } case COMMAND_CODE_SESSION_PREPARE_FROM_URI: { Uri uri = extras.getParcelable(ARGUMENT_URI); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPrepareFromUri(mSession.getInstance(), controller, uri, extra); break; } case COMMAND_CODE_SESSION_SET_RATING: { String mediaId = extras.getString(ARGUMENT_MEDIA_ID); Rating2 rating = Rating2.fromBundle(extras.getBundle(ARGUMENT_RATING)); mSession.getCallback().onSetRating(mSession.getInstance(), controller, mediaId, rating); break; } case COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO: { mSession.getCallback().onSubscribeRoutesInfo(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO: { mSession.getCallback().onUnsubscribeRoutesInfo(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_SELECT_ROUTE: { Bundle route = extras.getBundle(ARGUMENT_ROUTE_BUNDLE); mSession.getCallback().onSelectRoute(mSession.getInstance(), controller, route); break; } case COMMAND_CODE_PLAYBACK_SET_SPEED: { float speed = extras.getFloat(ARGUMENT_PLAYBACK_SPEED); mSession.setPlaybackSpeed(speed); break; } } } }); break; } case CONTROLLER_COMMAND_BY_CUSTOM_COMMAND: { final SessionCommand2 customCommand = SessionCommand2 .fromBundle(extras.getBundle(ARGUMENT_CUSTOM_COMMAND)); IMediaControllerCallback caller = (IMediaControllerCallback) extras .getBinder(ARGUMENT_ICONTROLLER_CALLBACK); if (caller == null || customCommand == null) { return; } final Bundle args = extras.getBundle(ARGUMENT_ARGUMENTS); onCommand2(caller.asBinder(), customCommand, new Session2Runnable() { @Override public void run(ControllerInfo controller) throws RemoteException { mSession.getCallback().onCustomCommand(mSession.getInstance(), controller, customCommand, args, cb); } }); break; } } }
From source file:info.icefilms.icestream.browse.BrowseFragment.java
@SuppressWarnings("unchecked") @Override/*from w w w . j a va 2 s . c o m*/ public void onActivityCreated(Bundle savedInstanceState) { // Call base class method super.onActivityCreated(savedInstanceState); // Save the views mHeadingLayout[0] = (LinearLayout) getActivity().findViewById(R.id.heading1_layout); mHeading[0] = (HorizontalListView) getActivity().findViewById(R.id.heading1); mHeadingLayout[1] = (LinearLayout) getActivity().findViewById(R.id.heading2_layout); mHeading[1] = (HorizontalListView) getActivity().findViewById(R.id.heading2); mHeadingLayout[2] = (LinearLayout) getActivity().findViewById(R.id.heading3_layout); mHeading[2] = (HorizontalListView) getActivity().findViewById(R.id.heading3); mDivider = (ImageView) getActivity().findViewById(R.id.divider); mList = (ListView) getActivity().findViewById(R.id.list); mRetryLayout = (LinearLayout) getActivity().findViewById(R.id.retry_layout); mRetryButton = (Button) getActivity().findViewById(R.id.retry_button); // Create the array adapters mHeadingAdapter = new ItemArrayAdapter[3]; for (int i = 0; i < mHeadingAdapter.length; ++i) mHeadingAdapter[i] = new ItemArrayAdapter(getActivity(), 0, mHeadingItems[i]); mListAdapter = new ItemArrayAdapter(getActivity(), 0, mListItems); // Set the list adapters for (int i = 0; i < mHeading.length; ++i) mHeading[i].setAdapter(mHeadingAdapter[i]); mList.setAdapter(mListAdapter); // Set the heading click listeners for (int i = 0; i < mHeading.length; ++i) mHeading[i].setOnItemClickListener(mHeadingListener); mList.setOnItemClickListener(mListListener); // Create or load certain items if (savedInstanceState == null && mStopParcel == null) { // Set the initial connection boolean and create the current location and // list scroll position lists mInitialConnection = true; mCurrentState = new LinkedList<State>(); Log.d("Ice Stream", "New current state list created."); } else if (savedInstanceState != null) { // Get the initial connection boolean and the current location list mInitialConnection = savedInstanceState.getBoolean("InitialConnection"); mCurrentState = new LinkedList<State>((Collection<? extends State>) Arrays .asList(savedInstanceState.getParcelableArray("CurrentState"))); Log.d("Ice Stream", "Loaded current state list from saved instance state bundle."); Log.d("Ice Stream", "Current state list contains " + mCurrentState.size() + " state(s)."); // Get the heading items lists for (int i = 0; i < mHeadingItems.length; ++i) { mHeadingItems[i].addAll((Collection<? extends Item>) savedInstanceState .getParcelableArrayList("Heading" + (i + 1) + "Items")); Log.d("Ice Stream", "Loaded " + mHeadingItems[i].size() + " heading items " + "from saved instance state bundle into heading " + (i + 1) + " items list."); mHeadingAdapter[i].notifyDataSetChanged(); } // Get the list items list mListItems.addAll((Collection<? extends Item>) savedInstanceState.getParcelableArrayList("ListItems")); Log.d("Ice Stream", "Loaded " + mListItems.size() + " list items from saved instance " + "state bundle into list items list."); mListAdapter.notifyDataSetChanged(); // Get the stop parcel from the saved instance state bundle mStopParcel = savedInstanceState.getParcelable("StopParcel"); } // Get the current state State state; if (mCurrentState.isEmpty()) { // Create a new location based on the passed URL URL url = (URL) getArguments().get("URL"); state = new State(Location.CreateLocationForItem(new HeadingItem(url))); } else { state = mCurrentState.getLast(); } // Load the state StartLoadStateTask(state); // Set the retry button click listener final State retryState = state; mRetryButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { StartLoadStateTask(retryState); } }); }