/** * Get selected labels from result bundle * * @param arguments * @return selected labels */ @SuppressWarnings("unchecked") public static ArrayList<Label> getSelected(Bundle arguments) { return arguments.getParcelableArrayList(ARG_SELECTED); }
void onRestoreInstanceState(Bundle state) { buffers=state.getParcelableArrayList(STATE_BUFFERS); }
@Override public <T extends List<? extends Parcelable>> T get(String key, Bundle bundle) { return (T) bundle.getParcelableArrayList(key); } }
Bundle extras = getIntent().getExtras(); ArrayList<ObjectName> arraylist = extras.getParcelableArrayList("arraylist"); ObjectName object1 = arrayList[0];
public void onCreate(Bundle bundle) { if (bundle == null) { mItems = new LinkedHashSet<>(); } else { List<Item> saved = bundle.getParcelableArrayList(STATE_SELECTION); mItems = new LinkedHashSet<>(saved); mCollectionType = bundle.getInt(STATE_COLLECTION_TYPE, COLLECTION_UNDEFINED); } }
@SuppressWarnings("unchecked") private ArrayList<GitReference> getChoices() { return getArguments().getParcelableArrayList(ARG_CHOICES); }
@SuppressWarnings("unchecked") private ArrayList<Label> getChoices() { return getArguments().getParcelableArrayList(ARG_CHOICES); }
@SuppressWarnings("unchecked") private ArrayList<User> getChoices() { return getArguments().getParcelableArrayList(ARG_CHOICES); }
/** * Gets an array of photo values out of the object. * @param key The key for the value. * @return The photo values. */ @Nullable public ArrayList<SharePhoto> getPhotoArrayList(final String key) { final ArrayList<Parcelable> items = this.bundle.getParcelableArrayList(key); if (items == null) { return null; } final ArrayList<SharePhoto> list = new ArrayList<SharePhoto>(); for (Parcelable item : items) { if (item instanceof SharePhoto) { list.add((SharePhoto)item); } } return list; }
void restoreInstanceState(@NonNull Bundle savedInstanceState) { ArrayList<Bundle> entryBundles = savedInstanceState.getParcelableArrayList(KEY_ENTRIES); if (entryBundles != null) { Collections.reverse(entryBundles); for (Bundle transactionBundle : entryBundles) { backstack.push(new RouterTransaction(transactionBundle)); } } } }
@Override protected void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; currentItem = bundle.getInt("current_item"); notifications = bundle.getParcelableArrayList("notifications"); state = bundle.getParcelable("superState"); } super.onRestoreInstanceState(state); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { StringSparseArrayParceler permissionParcel = savedInstanceState.getParcelable(KEY_PERMISSION_REQUEST_CODES); permissionRequestMap = permissionParcel != null ? permissionParcel.getStringSparseArray() : new SparseArray<String>(); StringSparseArrayParceler activityParcel = savedInstanceState.getParcelable(KEY_ACTIVITY_REQUEST_CODES); activityRequestMap = activityParcel != null ? activityParcel.getStringSparseArray() : new SparseArray<String>(); ArrayList<PendingPermissionRequest> pendingRequests = savedInstanceState.getParcelableArrayList(KEY_PENDING_PERMISSION_REQUESTS); pendingPermissionRequests = pendingRequests != null ? pendingRequests : new ArrayList<PendingPermissionRequest>(); } }
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.recylerview, container, false); if (getArguments() != null) { songInfos = getArguments().getParcelableArrayList("searchMusic"); } recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview); layoutManager = new LinearLayoutManager(mContext); recyclerView.setLayoutManager(layoutManager); mAdapter = new MusicAdapter(songInfos); recyclerView.setAdapter(mAdapter); recyclerView.setHasFixedSize(true); recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST)); return view; }
public void onRestoreInstanceState(Bundle savedInstanceState) { actionToPerformAfterWaiting = WaitingAction.valueOf( savedInstanceState.getString(STATE_KEY_WAITING_FOR_ATTACHMENTS)); nextLoaderId = savedInstanceState.getInt(STATE_KEY_NEXT_LOADER_ID); ArrayList<Attachment> attachmentList = savedInstanceState.getParcelableArrayList(STATE_KEY_ATTACHMENTS); // noinspection ConstantConditions, we know this is set in onSaveInstanceState for (Attachment attachment : attachmentList) { attachments.put(attachment.uri, attachment); attachmentMvpView.addAttachmentView(attachment); if (attachment.state == LoadingState.URI_ONLY) { initAttachmentInfoLoader(attachment); } else if (attachment.state == LoadingState.METADATA) { initAttachmentContentLoader(attachment); } } }
private void loadArtists() { if (getArguments() != null) { artistInfos = getArguments().getParcelableArrayList("searchArtist"); } mAdapter = new ArtistAdapter(artistInfos); recyclerView.setAdapter(mAdapter); setItemDecoration(); }
private void loadAlbums() { if (mContext == null) { return; } if (getArguments() != null) { mAlbumList = getArguments().getParcelableArrayList("searchAlbum"); mAdapter = new AlbumAdapter(mAlbumList); recyclerView.setAdapter(mAdapter); setItemDecoration(); } }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ArrayList<PermissionInfo> perms= getArguments().getParcelableArrayList(ARG_PERMS); if (perms!=null && perms.size()>0) { Collections.sort(perms, new Comparator<PermissionInfo>() { @Override public int compare(PermissionInfo one, PermissionInfo two) { return (one.name.compareTo(two.name)); } }); setListAdapter(new PermissionAdapter(perms)); } else { setListAdapter(new PermissionAdapter(new ArrayList<PermissionInfo>())); setEmptyText(getActivity().getString(R.string.msg_no_perms)); } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!SelectionSpec.getInstance().hasInited) { setResult(RESULT_CANCELED); finish(); return; } Bundle bundle = getIntent().getBundleExtra(EXTRA_DEFAULT_BUNDLE); List<Item> selected = bundle.getParcelableArrayList(SelectedItemCollection.STATE_SELECTION); mAdapter.addAll(selected); mAdapter.notifyDataSetChanged(); if (mSpec.countable) { mCheckView.setCheckedNum(1); } else { mCheckView.setChecked(true); } mPreviousPos = 0; updateSize(selected.get(0)); }
@Test public void testParcelableArrayListExtra() { Intent intent = new Intent(); Parcelable parcel1 = new TestParcelable(22); Parcelable parcel2 = new TestParcelable(23); ArrayList<Parcelable> parcels = new ArrayList<>(); parcels.add(parcel1); parcels.add(parcel2); assertSame(intent, intent.putParcelableArrayListExtra("foo", parcels)); assertSame(parcels, intent.getParcelableArrayListExtra("foo")); assertSame(parcel1, intent.getParcelableArrayListExtra("foo").get(0)); assertSame(parcel2, intent.getParcelableArrayListExtra("foo").get(1)); assertSame(parcels, intent.getExtras().getParcelableArrayList("foo")); }
@Test public void getWrongType() { bundle.putFloat("foo", 5f); assertThat(bundle.getCharArray("foo")).isNull(); assertThat(bundle.getInt("foo")).isEqualTo(0); assertThat(bundle.getIntArray("foo")).isNull(); assertThat(bundle.getIntegerArrayList("foo")).isNull(); assertThat(bundle.getShort("foo")).isEqualTo((short) 0); assertThat(bundle.getShortArray("foo")).isNull(); assertThat(bundle.getBoolean("foo")).isFalse(); assertThat(bundle.getBooleanArray("foo")).isNull(); assertThat(bundle.getLong("foo")).isEqualTo(0); assertThat(bundle.getLongArray("foo")).isNull(); assertThat(bundle.getFloatArray("foo")).isNull(); assertThat(bundle.getDouble("foo")).isEqualTo(0.0); assertThat(bundle.getDoubleArray("foo")).isNull(); assertThat(bundle.getString("foo")).isNull(); assertThat(bundle.getStringArray("foo")).isNull(); assertThat(bundle.getStringArrayList("foo")).isNull(); assertThat(bundle.getBundle("foo")).isNull(); assertThat((Parcelable) bundle.getParcelable("foo")).isNull(); assertThat(bundle.getParcelableArray("foo")).isNull(); assertThat(bundle.getParcelableArrayList("foo")).isNull(); bundle.putInt("foo", 1); assertThat(bundle.getFloat("foo")).isEqualTo(0.0f); }