Java Code Examples for android.os.bundle#getParcelableArrayList()
The following examples show how to use
android.os.bundle#getParcelableArrayList() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransportBroker.java From sdl_java_suite with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Handle a potential connection event. This will adapt legacy router service implementaions * into the new multiple transport scheme. * @param bundle the received bundle from the router service * @param broker reference to the transport broker that this handler exists * @return if a connection event was triggered in the supplied broker */ private boolean handleConnectionEvent(Bundle bundle, TransportBroker broker){ if (broker.routerServiceVersion < RS_MULTI_TRANSPORT_SUPPORT) { //Previous versions of the router service only supports a single //transport, so this will be the only extra received if (bundle.containsKey(TransportConstants.HARDWARE_CONNECTED)) { // Only bluetooth was a supported transport on previous versions of the router // service so the constant legacy bluetooth transport record will be used. broker.onHardwareConnected(Collections.singletonList(LEGACY_TRANSPORT_RECORD)); return true; } } else{ //Router service supports multiple transport if (bundle.containsKey(TransportConstants.CURRENT_HARDWARE_CONNECTED)) { ArrayList<TransportRecord> transports = bundle.getParcelableArrayList(TransportConstants.CURRENT_HARDWARE_CONNECTED); broker.onHardwareConnected(transports); return true; } } return false; }
Example 2
Source File: AlbumPreviewActivity.java From AlbumCameraRecorder with MIT License | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCollection.onCreate(this, this); Album album = getIntent().getParcelableExtra(EXTRA_ALBUM); if (album != null) { mCollection.load(album); } else { Bundle bundle = getIntent().getBundleExtra(EXTRA_DEFAULT_BUNDLE); ArrayList<MultiMedia> items = bundle.getParcelableArrayList(SelectedItemCollection.STATE_SELECTION); initItems(items); } MultiMedia item = getIntent().getParcelableExtra(EXTRA_ITEM); if (mAlbumSpec.countable) { mViewHolder.check_view.setCheckedNum(mSelectedCollection.checkedNumOf(item)); } else { mViewHolder.check_view.setChecked(mSelectedCollection.isSelected(item)); } updateSize(item); }
Example 3
Source File: GamesFragment.java From UpdogFarmer with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); steamId = getArguments().getLong(STEAM_ID); viewModel = ViewModelProviders.of(this).get(GamesViewModel.class); viewModel.init(SteamWebHandler.getInstance(), steamId); if (savedInstanceState != null) { currentGames = savedInstanceState.getParcelableArrayList(CURRENT_GAMES); currentTab = savedInstanceState.getInt(CURRENT_TAB); } else { currentGames = getArguments().getParcelableArrayList(CURRENT_GAMES); currentTab = getArguments().getInt(CURRENT_TAB); if (steamId == 0) { Toast.makeText(getActivity(), R.string.error_not_logged_in, Toast.LENGTH_LONG).show(); } } setHasOptionsMenu(true); }
Example 4
Source File: ListNowPlayingMoviesActivity.java From Movie-Check with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_listnowplayingmovies); ButterKnife.bind(this); ((MovieCheckApplication) getApplication()).getObjectGraph().plus(new ListNowPlayingMoviesViewModule(this)).inject(this); setSupportActionBar(toolbar); getSupportActionBar().setTitle(R.string.nowplayingmoviesactivity_title); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { presenter.loadMovies(page); } else { List<Movie> movieList = savedInstanceState.getParcelableArrayList(BUNDLE_KEY_MOVIELIST); if (movieList == null) { presenter.loadMovies(page); } else if (movieList.size() == 0) { warnAnyMovieFounded(); } else { page = savedInstanceState.getInt(BUNDLE_KEY_PAGE); showMovies(movieList); } } }
Example 5
Source File: BaseBrowserFragment.java From VCL-Android with Apache License 2.0 | 6 votes |
public void onCreate(Bundle bundle){ super.onCreate(bundle); if (bundle == null) bundle = getArguments(); if (bundle != null){ mediaList = bundle.getParcelableArrayList(KEY_MEDIA_LIST); if (mediaList != null) mAdapter.addAll(mediaList); mCurrentMedia = bundle.getParcelable(KEY_MEDIA); if (mCurrentMedia != null) mMrl = mCurrentMedia.getLocation(); else mMrl = bundle.getString(KEY_MRL); mSavedPosition = bundle.getInt(KEY_POSITION); } else if (getActivity().getIntent() != null){ mMrl = getActivity().getIntent().getDataString(); getActivity().setIntent(null); } }
Example 6
Source File: GifFragment.java From EmoticonGIFKeyboard with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState == null) { mGifs = new ArrayList<>(); } else { mGifs = savedInstanceState.getParcelableArrayList(OUT_STATE_GIFS); } // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_gif, container, false); }
Example 7
Source File: LocationsManagerBase.java From edslite with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("WeakerAccess") public static ArrayList<Location> getLocationsFromBundle(LocationsManagerBase lm, Bundle b) throws Exception { ArrayList<Location> res = new ArrayList<>(); if(b!=null) { ArrayList<Uri> uris = b.getParcelableArrayList(PARAM_LOCATION_URIS); if (uris != null) for (Uri uri : uris) res.add(lm.getLocation(uri)); } return res; }
Example 8
Source File: NavigationActivity.java From SmartPack-Kernel-Manager with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { new FragmentLoader(this).execute(); } else { mFragments = savedInstanceState.getParcelableArrayList("fragments"); init(savedInstanceState); } }
Example 9
Source File: IntentParser.java From ToGoZip with GNU General Public License v3.0 | 5 votes |
private void parse() { if ((resultFiles != null) && (resultText != null)) { return; } resultFiles = new ArrayList<CompressItem>(); resultText = new StringBuffer(); Object extra = null; try { Bundle extras = (intent != null) ? intent.getExtras() : null; String mimeType = (intent != null) ? intent.getType() : null; extra = (extras != null) ? extras.get(Intent.EXTRA_STREAM) : null; if (extra != null) { if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) { ArrayList<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); if (uris != null) { for (Uri item : uris) { addResult("Extras[Stream][] uris", item, extra, mimeType); } } // else unknown format. } else { addResult("Extras[Stream] uri", (Uri) extras.getParcelable(Intent.EXTRA_STREAM), extra, mimeType); } extra = null; } final Uri data = (intent == null) ? null : intent.getData(); addResult("getData uri ", data, null, mimeType); getTextToBeAdded(resultText); if ((android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) && (resultFiles.size() == 0) && (resultText.length() == 0)) { addClipUris(); } } catch (Exception ex) { zipLog.addError("error : " + ex.getMessage() + "\nlast extra = " + getLogMessageString(extra)); } }
Example 10
Source File: RequestActivity.java From android-open-project-demo with Apache License 2.0 | 5 votes |
@Override public void initAllMembers(Bundle savedInstanceState) { mContextDestroyed = false; mRequestManager = RequestManagerImpl.from(this); if (savedInstanceState != null) { mRequestList = savedInstanceState .getParcelableArrayList(SAVED_STATE_REQUEST_LIST); } if (mRequestList == null) { mRequestList = new ArrayList<Request>(); } }
Example 11
Source File: ArrayListBundler.java From postman with MIT License | 5 votes |
@Override public ArrayList<Object> readFromBundle(Bundle bundle, String key) { ArrayList<Parcelable> wrapped = bundle.getParcelableArrayList(key); if (wrapped == null) { return null; } ArrayList<Object> unwrapped = new ArrayList<>(wrapped.size()); for (Parcelable parcelable : wrapped) { unwrapped.add(ParcelableAdapters.unwrapParcelable(parcelable)); } return unwrapped; }
Example 12
Source File: Recipe.java From android-RecipeAssistant with Apache License 2.0 | 5 votes |
public static Recipe fromBundle(Bundle bundle) { Recipe recipe = new Recipe(); recipe.titleText = bundle.getString(Constants.RECIPE_FIELD_TITLE); recipe.summaryText = bundle.getString(Constants.RECIPE_FIELD_SUMMARY); recipe.recipeImage = bundle.getString(Constants.RECIPE_FIELD_IMAGE); recipe.ingredientsText = bundle.getString(Constants.RECIPE_FIELD_INGREDIENTS); ArrayList<Parcelable> stepBundles = bundle.getParcelableArrayList(Constants.RECIPE_FIELD_STEPS); if (stepBundles != null) { for (Parcelable stepBundle : stepBundles) { recipe.recipeSteps.add(RecipeStep.fromBundle((Bundle) stepBundle)); } } return recipe; }
Example 13
Source File: MainActivityFragment.java From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null || !savedInstanceState.containsKey("videoList")) { videoList = new ArrayList<>(); } else { videoList = savedInstanceState.getParcelableArrayList("videoList"); } }
Example 14
Source File: OfflineContestsFragment.java From fridge with MIT License | 5 votes |
@Override public void onViewStateRestored(@Nullable Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); if (savedInstanceState != null && savedInstanceState.containsKey("contests")) { contests = savedInstanceState.getParcelableArrayList("contests"); contestsListAdapter = new ContestsListAdapter(contests, getActivity()); recyclerView.swapAdapter(contestsListAdapter, false); contestsListAdapter.setFilter(filter); if (savedInstanceState.containsKey("pos") && savedInstanceState.containsKey("top")) { positionIndex = savedInstanceState.getInt("pos"); topView = savedInstanceState.getInt("top"); setScrollPosition(); } } }
Example 15
Source File: GroupSceneManager.java From scene with Apache License 2.0 | 5 votes |
public void restoreFromBundle(@NonNull Context context, @NonNull Bundle bundle) { if (this.mSceneList != null && this.mSceneList.size() > 0) { throw new IllegalStateException("mSceneList size is not zero, Scene is added before restore"); } this.mSceneList = new ArrayList<>(bundle.<GroupRecord>getParcelableArrayList(KEY_TAG)); for (GroupRecord record : this.mSceneList) { record.scene = SceneInstanceUtility.getInstanceFromClassName(context, record.sceneClassName, null); this.mSceneMap.put(record.scene, record); this.mTagMap.put(record.tag, record); } }
Example 16
Source File: SuperActivityToast.java From SuperToasts with Apache License 2.0 | 5 votes |
/** * Restores the state of all SuperToasts that were showing and/or pending. * * This should be called in the {@link android.app.Activity#onCreate(android.os.Bundle)} * method of your Activity. * * @param context The Activity Context * @param bundle The Bundle provided in onCreate() */ public static void onRestoreState(Context context, Bundle bundle) { // The Bundle will be null sometimes if (bundle == null) return; // Get the List created in onSaveState() final ArrayList<Style> styleList = bundle.getParcelableArrayList(BUNDLE_KEY); if (styleList == null) { Log.e(SuperActivityToast.class.getName(), "Cannot recreate " + "SuperActivityToasts onRestoreState(). Was onSaveState() called?"); return; } // Create a flag that knows if the SuperActivityToast is first in the List or not boolean firstInList = true; for (Style style : styleList) { if (!style.isSuperActivityToast) new SuperToast(context, style).show(); else { // This SuperActivityToast was most likely showing before the orientation change so ignore the show animation if (firstInList) new SuperActivityToast(context, style).fromOrientationChange().show(); else new SuperActivityToast(context, style).show(); } firstInList = false; } }
Example 17
Source File: ReviewFragment.java From watchlist with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_review,container,false); unbinder = ButterKnife.bind(this, v); // Initialize variables movieId = getArguments().getString(WatchlistApp.MOVIE_ID); movieName = getArguments().getString(WatchlistApp.MOVIE_NAME); // Setup toolbar toolbar.setTitle(""); toolbarTitle.setText(R.string.reviews_title); toolbarSubtitle.setText(movieName); toolbar.setNavigationIcon(ContextCompat.getDrawable(getActivity(), R.drawable.action_home)); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getActivity().finish(); } }); // Setup RecyclerView adapter = new ReviewAdapter(new ArrayList<Review>(), this); layoutManager = new LinearLayoutManager(getContext()); reviewList.setHasFixedSize(true); reviewList.setLayoutManager(layoutManager); reviewList.setAdapter(adapter); reviewList.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); // Load more data if reached the end of the list if (layoutManager.findLastVisibleItemPosition() == adapter.reviewList.size() - 1 && !isLoadingLocked && !isLoading) { if (pageToDownload < totalPages) { loadingMore.setVisibility(View.VISIBLE); downloadMovieReviews(); } } } }); // Download reviews if (savedInstanceState == null || !savedInstanceState.containsKey(WatchlistApp.REVIEW_LIST)) { downloadMovieReviews(); } else { adapter.reviewList = savedInstanceState.getParcelableArrayList(WatchlistApp.REVIEW_LIST); totalPages = savedInstanceState.getInt(WatchlistApp.TOTAL_PAGES); pageToDownload = savedInstanceState.getInt(WatchlistApp.PAGE_TO_DOWNLOAD); isLoadingLocked = savedInstanceState.getBoolean(WatchlistApp.IS_LOCKED); isLoading = savedInstanceState.getBoolean(WatchlistApp.IS_LOADING); // If download stopped, download again, else display list if (isLoading) { if (pageToDownload > 1) { progressCircle.setVisibility(View.GONE); reviewList.setVisibility(View.VISIBLE); loadingMore.setVisibility(View.VISIBLE); } downloadMovieReviews(); } else { onDownloadSuccessful(); } } return v; }
Example 18
Source File: SaveAndRestoreTests.java From scene with Apache License 2.0 | 4 votes |
@Test public void testParentSceneViewStateBundleShouldNotSaveChildSceneViewState() { SceneLifecycleManager<NavigationScene> sceneLifecycleManager = new SceneLifecycleManager<>(); NavigationScene navigationScene = new NavigationScene(); ActivityController<NavigationSourceUtility.TestActivity> controller = Robolectric.buildActivity(NavigationSourceUtility.TestActivity.class).create().start().resume(); NavigationSourceUtility.TestActivity testActivity = controller.get(); NavigationSceneOptions options = new NavigationSceneOptions(TestFixIdGroupScene.class); navigationScene.setArguments(options.toBundle()); Scope.RootScopeFactory rootScopeFactory = new Scope.RootScopeFactory() { @Override public Scope getRootScope() { return Scope.DEFAULT_ROOT_SCOPE_FACTORY.getRootScope(); } }; navigationScene.setDefaultNavigationAnimationExecutor(null); sceneLifecycleManager.onActivityCreated(testActivity, testActivity.mFrameLayout, navigationScene, rootScopeFactory, true, null); sceneLifecycleManager.onStart(); sceneLifecycleManager.onResume(); TestFixIdGroupScene parentGroupScene = (TestFixIdGroupScene) navigationScene.getCurrentScene(); TestScene childScene = new TestScene(); parentGroupScene.add(parentGroupScene.id, childScene, "TAG"); childScene.setValue("Test"); childScene.getCheckBox().setChecked(true); Bundle bundle = new Bundle(); sceneLifecycleManager.onSaveInstanceState(bundle); ArrayList<Bundle> navigationSceneChildrenSceneBundleList = bundle.getParcelableArrayList(ParcelConstants.KEY_NAVIGATION_SCENE_MANAGER_TAG); Bundle groupSceneBundle = navigationSceneChildrenSceneBundleList.get(0); SparseArray<Parcelable> groupSceneViewStateArray = groupSceneBundle.getSparseParcelableArray(ParcelConstants.KEY_SCENE_VIEWS_TAG); //Parent Scene's view state bundle should not have child Scene's view state, child Scene' view state is saved to child Scene's bundle. assertNull(groupSceneViewStateArray.get(childScene.requireView().getId())); ArrayList<Bundle> groupSceneChildrenSceneBundleList = groupSceneBundle.getParcelableArrayList(ParcelConstants.KEY_GROUP_SCENE_MANAGER_TAG); Bundle groupChildSceneBundle = groupSceneChildrenSceneBundleList.get(0); SparseArray<Parcelable> childSceneViewStateArray = groupChildSceneBundle.getSparseParcelableArray(ParcelConstants.KEY_SCENE_VIEWS_TAG); //Child Scene's view state should be saved in this SparseArray assertNotNull(childSceneViewStateArray.get(childScene.requireView().getId())); }
Example 19
Source File: SearchActivity.java From Movie-Check with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ((MovieCheckApplication) getApplication()).getObjectGraph().plus(new SearchViewModule(this)).inject(this); ButterKnife.bind(this); defaultTracker = ((MovieCheckApplication) getApplication()).getDefaultTracker(); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if(getIntent().getStringExtra(SearchManager.QUERY) != null) { query = getIntent().getStringExtra(SearchManager.QUERY); } else { query = getIntent().getStringExtra(KEY_QUERY); } if(query == null) { getSupportActionBar().setTitle(getString(R.string.searchactivity_search)); } else { getSupportActionBar().setTitle(query); defaultTracker.send(new HitBuilders.EventBuilder() .setCategory("Search") .setAction(query) .build()); } if (savedInstanceState == null) { if (query != null) { presenter.searchMovies(query); presenter.searchPerson(query); } } else { personList = savedInstanceState.getParcelableArrayList(KEY_PERSONLIST); movieList = savedInstanceState.getParcelableArrayList(KEY_MOVIELIST); if (movieList == null) { if (query != null) { presenter.searchMovies(query); } } else { if (movieList.size() == 0) { warnAnyMovieFounded(); } else { showMovies(movieList); } } if (personList == null) { if (query != null) { presenter.searchPerson(query); } } else { if (personList.size() == 0) { warnAnyPersonFounded(); } else { showPerson(personList); } } } }
Example 20
Source File: OpenSalesDetailActivity.java From stockita-point-of-sale with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_open_sales_detail); ButterKnife.bind(this); // Initialize the toolbar setSupportActionBar(toolbar); // Show the back button on the top left if (toolbar != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); } // When user press the back arrow on the toolbar it will hit the back button if (toolbar != null) { toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); } // Get the data from the intent if (savedInstanceState == null) { // Get the data from the intent/bundle Intent i = getIntent(); Bundle bundle = i.getExtras(); mUserUID = bundle.getString(KEY_FOUR); mHeaderKey = bundle.getString(KEY_FIVE); // Instantiate the fragment fragment = OpenSalesDetailFragmentUI.newInstance(mUserUID, mHeaderKey); // Pass the fragment into the container getFragmentManager().beginTransaction() .replace(R.id.container, fragment) .commit(); } if (savedInstanceState != null) { // Restore the fragment instance state fragment = (OpenSalesDetailFragmentUI) getFragmentManager().getFragment(savedInstanceState, KEY_ONE); mUserUID = savedInstanceState.getString(KEY_TWO); mHeaderKey = savedInstanceState.getString(KEY_THREE); qqOldHeaderKey = savedInstanceState.getString(KEY_MM_ONE); qqUserUid = savedInstanceState.getString(KEY_MM_TWO); qqSalesHeaderModel = savedInstanceState.getParcelable(KEY_MM_THREE); qqSalesDetailModelList = savedInstanceState.getParcelableArrayList(KEY_MM_FOUR); qqCashPaid = savedInstanceState.getString(KEY_MM_FIVE); qqChangeCash = savedInstanceState.getString(KEY_MM_SIX); } }