android.os.Bundle#getParcelableArrayList ( )源码实例Demo

下面列出了android.os.Bundle#getParcelableArrayList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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);
        }
    }
}
 
源代码2 项目: VCL-Android   文件: BaseBrowserFragment.java
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);
    }
}
 
源代码3 项目: UpdogFarmer   文件: GamesFragment.java
@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);
}
 
@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);
}
 
源代码5 项目: sdl_java_suite   文件: TransportBroker.java
/**
 * 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;
}
 
@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>();
	}
}
 
源代码7 项目: SuperToasts   文件: SuperActivityToast.java
/**
 * 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;
    }
}
 
源代码8 项目: scene   文件: GroupSceneManager.java
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);
    }
}
 
源代码9 项目: fridge   文件: OfflineContestsFragment.java
@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();
        }
    }
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState == null || !savedInstanceState.containsKey("videoList")) {
        videoList = new ArrayList<>();
    } else {
        videoList = savedInstanceState.getParcelableArrayList("videoList");
    }
}
 
源代码11 项目: android-RecipeAssistant   文件: Recipe.java
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;
}
 
源代码12 项目: postman   文件: ArrayListBundler.java
@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;
}
 
源代码13 项目: EmoticonGIFKeyboard   文件: GifFragment.java
@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);
}
 
源代码14 项目: ToGoZip   文件: IntentParser.java
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));
    }

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

    if (savedInstanceState == null) {
        new FragmentLoader(this).execute();
    } else {
        mFragments = savedInstanceState.getParcelableArrayList("fragments");
        init(savedInstanceState);
    }
}
 
源代码16 项目: edslite   文件: LocationsManagerBase.java
@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;
}
 
源代码17 项目: scene   文件: SaveAndRestoreTests.java
@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()));
}
 
源代码18 项目: watchlist   文件: ReviewFragment.java
@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;
}
 
源代码19 项目: Movie-Check   文件: SearchActivity.java
@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);
            }
        }
    }
}
 
@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);
    }
}