List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:at.tm.android.fitacity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* w ww.ja va 2 s .c om*/ final ActionBar ab = getSupportActionBar(); ab.setHomeAsUpIndicator(R.drawable.ic_menu); ab.setDisplayHomeAsUpEnabled(true); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mNavigationView = (NavigationView) findViewById(R.id.nav_view); if (mNavigationView != null) { mNavigationView.setNavigationItemSelectedListener(this); } AdView mAdView = (AdView) findViewById(R.id.adView); // Create an ad request. Check logcat output for the hashed device ID to // get test ads on a physical device. e.g. // "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device." AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build(); mAdView.loadAd(adRequest); // Setup the recycler view with it's adapter RecyclerView rv = (RecyclerView) findViewById(R.id.recyclerview); rv.setLayoutManager(new LinearLayoutManager(rv.getContext())); mEmptyRecyclerView = (TextView) findViewById(R.id.tvEmptyRecylcerView); if ((savedInstanceState != null) && (savedInstanceState.containsKey(EXERCISE_LIST_KEY)) && (savedInstanceState.containsKey(SELECTED_CATEGORY_ID_KEY)) && (savedInstanceState.containsKey(SELECTED_CATEGORY_ID_KEY))) { // Set the selected category id mSelectedCategoryId = savedInstanceState.getInt(SELECTED_CATEGORY_ID_KEY); // If there is a previous category list stored, update the menu items List<Category> previousCategoryList = savedInstanceState.getParcelableArrayList(CATEGORY_LIST_KEY); setCategoriesMenu(previousCategoryList); System.out.println("Saved exercises"); // Set the stored exercise list to the recycler view adapter mExerciseRecyclerViewAdapter = new ExerciseRecyclerViewAdapter(); if (mSelectedCategoryId == FAVORITE_CATEGORY_ID) { // Set the favorite exercises evertime the favorite category is selected getSupportLoaderManager().initLoader(FAVORITE_CATEGORY_ID, null, this); } else { // If there is a previous exercise list stored, update the exercise list adapter List<Exercise> previousExerciseList = savedInstanceState.getParcelableArrayList(EXERCISE_LIST_KEY); setExerciseData(previousExerciseList); } } else { // Set the default category id to the favorite category mSelectedCategoryId = FAVORITE_CATEGORY_ID; // Fetch the category data when no categories stored new FetchCategoryDataTask().execute(); // load the favorite exercises and put it into the recycler view adapter mExerciseRecyclerViewAdapter = new ExerciseRecyclerViewAdapter(); getSupportLoaderManager().initLoader(FAVORITE_CATEGORY_ID, null, this); } // Set the adapter to the recycler view rv.setAdapter(mExerciseRecyclerViewAdapter); }
From source file:com.amaze.filemanager.fragments.MainFragment.java
void onSavedInstanceState(final Bundle savedInstanceState) { Bundle b = new Bundle(); String cur = savedInstanceState.getString("CURRENT_PATH"); if (cur != null) { b.putInt("index", savedInstanceState.getInt("index")); b.putInt("top", savedInstanceState.getInt("top")); scrolls.put(cur, b);/*from ww w . ja v a2 s . c om*/ openMode = OpenMode.getOpenMode(savedInstanceState.getInt("openMode", 0)); if (openMode == OpenMode.SMB) smbPath = savedInstanceState.getString("SmbPath"); LIST_ELEMENTS = savedInstanceState.getParcelableArrayList("list"); CURRENT_PATH = cur; folder_count = savedInstanceState.getInt("folder_count", 0); file_count = savedInstanceState.getInt("file_count", 0); results = savedInstanceState.getBoolean("results"); getMainActivity().getAppbar().getBottomBar().updatePath(CURRENT_PATH, results, MainActivityHelper.SEARCH_TEXT, openMode, folder_count, file_count, this); reloadListElements(true, results, !IS_LIST); if (savedInstanceState.getBoolean("selection")) { for (Integer index : savedInstanceState.getIntegerArrayList("position")) { adapter.toggleChecked(index, null); } } } }
From source file:android.support.mediacompat.service.ServiceBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); if (ACTION_CALL_MEDIA_BROWSER_SERVICE_METHOD.equals(intent.getAction()) && extras != null) { StubMediaBrowserServiceCompat service = StubMediaBrowserServiceCompat.sInstance; int method = extras.getInt(KEY_METHOD_ID, 0); switch (method) { case NOTIFY_CHILDREN_CHANGED: service.notifyChildrenChanged(extras.getString(KEY_ARGUMENT)); break; case SEND_DELAYED_NOTIFY_CHILDREN_CHANGED: service.sendDelayedNotifyChildrenChanged(); break; case SEND_DELAYED_ITEM_LOADED: service.sendDelayedItemLoaded(); break; case CUSTOM_ACTION_SEND_PROGRESS_UPDATE: service.mCustomActionResult.sendProgressUpdate(extras.getBundle(KEY_ARGUMENT)); break; case CUSTOM_ACTION_SEND_ERROR: service.mCustomActionResult.sendError(extras.getBundle(KEY_ARGUMENT)); break; case CUSTOM_ACTION_SEND_RESULT: service.mCustomActionResult.sendResult(extras.getBundle(KEY_ARGUMENT)); break; case SET_SESSION_TOKEN: StubMediaBrowserServiceCompatWithDelayedMediaSession.sInstance.callSetSessionToken(); break; }/*from w w w .ja v a 2 s . c o m*/ } else if (ACTION_CALL_MEDIA_SESSION_METHOD.equals(intent.getAction()) && extras != null) { MediaSessionCompat session = StubMediaBrowserServiceCompat.sSession; int method = extras.getInt(KEY_METHOD_ID, 0); switch (method) { case SET_EXTRAS: session.setExtras(extras.getBundle(KEY_ARGUMENT)); break; case SET_FLAGS: session.setFlags(extras.getInt(KEY_ARGUMENT)); break; case SET_METADATA: session.setMetadata((MediaMetadataCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_PLAYBACK_STATE: session.setPlaybackState((PlaybackStateCompat) extras.getParcelable(KEY_ARGUMENT)); break; case SET_QUEUE: List<QueueItem> items = extras.getParcelableArrayList(KEY_ARGUMENT); session.setQueue(items); break; case SET_QUEUE_TITLE: session.setQueueTitle(extras.getCharSequence(KEY_ARGUMENT)); break; case SET_SESSION_ACTIVITY: session.setSessionActivity((PendingIntent) extras.getParcelable(KEY_ARGUMENT)); break; case SET_CAPTIONING_ENABLED: session.setCaptioningEnabled(extras.getBoolean(KEY_ARGUMENT)); break; case SET_REPEAT_MODE: session.setRepeatMode(extras.getInt(KEY_ARGUMENT)); break; case SET_SHUFFLE_MODE: session.setShuffleMode(extras.getInt(KEY_ARGUMENT)); break; case SEND_SESSION_EVENT: Bundle arguments = extras.getBundle(KEY_ARGUMENT); session.sendSessionEvent(arguments.getString("event"), arguments.getBundle("extras")); break; case SET_ACTIVE: session.setActive(extras.getBoolean(KEY_ARGUMENT)); break; case RELEASE: session.release(); break; case SET_PLAYBACK_TO_LOCAL: session.setPlaybackToLocal(extras.getInt(KEY_ARGUMENT)); break; case SET_PLAYBACK_TO_REMOTE: ParcelableVolumeInfo volumeInfo = extras.getParcelable(KEY_ARGUMENT); session.setPlaybackToRemote(new VolumeProviderCompat(volumeInfo.controlType, volumeInfo.maxVolume, volumeInfo.currentVolume) { }); break; case SET_RATING_TYPE: session.setRatingType(RatingCompat.RATING_5_STARS); break; } } }
From source file:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java
protected void onCreateChatComponents(Bundle savedInstanceState) { chatConfig = onLoadChatConfig();//from w w w. ja va 2 s . c o m resolveChatRoom(savedInstanceState); resolveStartingMessage(); resolveShareFile(); onApplyChatConfig(); swipeRefreshLayout.setOnRefreshListener(this); animation = onLoadAnimation(); onClearNotification(); qiscusAccount = Qiscus.getQiscusAccount(); chatAdapter = onCreateChatAdapter(); chatAdapter.setOnItemClickListener( (view, position) -> onItemCommentClick((QiscusComment) chatAdapter.getData().get(position))); chatAdapter.setOnLongItemClickListener( (view, position) -> onItemCommentLongClick((QiscusComment) chatAdapter.getData().get(position))); chatAdapter.setChatButtonClickListener(this); messageRecyclerView.setUpAsBottomList(); chatLayoutManager = (LinearLayoutManager) messageRecyclerView.getLayoutManager(); messageRecyclerView.setAdapter(chatAdapter); messageRecyclerView.addOnScrollListener(new QiscusChatScrollListener(chatLayoutManager, this)); setupEmojiPopup(); qiscusChatPresenter = new QiscusChatPresenter(this, qiscusChatRoom); if (savedInstanceState == null) { qiscusChatPresenter.loadComments(20); } else { ArrayList<QiscusComment> comments = savedInstanceState.getParcelableArrayList(COMMENTS_DATA); if (comments == null) { qiscusChatPresenter.loadComments(20); } else { showComments(comments); } } if (commentSelectedListener != null) { commentSelectedListener.onCommentSelected(chatAdapter.getSelectedComments()); } if (startingMessage != null && !startingMessage.isEmpty()) { sendMessage(startingMessage); } if (shareFile != null) { sendFile(shareFile); } }
From source file:com.example.mahendran.moviecritic.DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_detail, container, false); ButterKnife.bind(this, rootView); ImageView login;//from w w w. j a v a2 s.c o m getLoaderManager().initLoader(CURSOR_LOADER_ID, null, this); if (!isFavorite()) { favoritetext.setText(" Click To Favorite"); } else { favoritetext.setText(" Click To Un-Favorite"); } login = (ImageView) rootView.findViewById(R.id.poster_imageview); login.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { makeAsFavorite(); } }); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); mRecyclerTrailers.setLayoutManager(layoutManager); mTrailerAdapter = new TrailerAdapter(new ArrayList<Trailer>(), this); mRecyclerTrailers.setAdapter(mTrailerAdapter); mRecyclerTrailers.setNestedScrollingEnabled(false); LinearLayoutManager reviewLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); mRecyclerReviews.setLayoutManager(reviewLayoutManager); mReviewAdapter = new ReviewAdapter(new ArrayList<Review>(), this); mRecyclerReviews.setAdapter(mReviewAdapter); mCollapsingToolbar.setTitle(mMovie.getTitle()); mMovieRelease.setText("Release Date: " + mMovie.getReleaseDate()); mMovieRated.setText("Rating: " + mMovie.getRating()); mMovieOverview.setText(mMovie.getOverview()); Picasso.with(getContext()).load(mMovie.getPoster()).placeholder(R.drawable.temp_poster) // before load an image .error(R.drawable.temp_poster).into(mMoviePoster); Picasso.with(getContext()).load(mMovie.getBackdrop()).placeholder(R.drawable.temp_poster) // before load an image .error(R.drawable.temp_poster).into(mMovieBackdrop); if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_TRAILERS)) { List<Trailer> trailers = savedInstanceState.getParcelableArrayList(EXTRA_TRAILERS); mTrailerAdapter.add(trailers); } else { fetchTrailers(); } if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_REVIEWS)) { List<Review> reviews = savedInstanceState.getParcelableArrayList(EXTRA_REVIEWS); mReviewAdapter.add(reviews); } else { fetchReviews(); } return rootView; }
From source file:com.gbozza.android.popularmovies.fragments.MovieGridFragment.java
@Nullable @Override/*w ww .ja v a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Boolean errorShown = false; if (null != savedInstanceState) { errorShown = savedInstanceState.getBoolean(BUNDLE_ERROR_KEY); } View rootView = inflater.inflate(R.layout.movie_grid, container, false); ButterKnife.bind(this, rootView); mContext = getContext(); setupSharedPreferences(); if (null != savedInstanceState && !errorShown) { mPage = savedInstanceState.getInt(BUNDLE_PAGE_KEY); mSorting = savedInstanceState.getInt(BUNDLE_SORTING_KEY); } else { mPage = 1; } final int columns = getResources().getInteger(R.integer.grid_columns); GridLayoutManager gridLayoutManager = new GridLayoutManager(mContext, columns, GridLayoutManager.VERTICAL, false); mRecyclerView.setLayoutManager(gridLayoutManager); mRecyclerView.setHasFixedSize(true); mMoviesAdapter = new MoviesAdapter(); mRecyclerView.setAdapter(mMoviesAdapter); if (mSorting != SORTING_FAVOURITES) { mScrollListener = new BottomRecyclerViewScrollListener(gridLayoutManager, mPage) { @Override public void onLoadMore(int page, int totalItemsCount, RecyclerView view) { mPage = page; loadCards(); } }; mRecyclerView.addOnScrollListener(mScrollListener); } mSwipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mErrorMessageDisplay.setVisibility(View.INVISIBLE); clearGridView(); loadCards(); } }); mSwipeContainer.setColorSchemeResources(R.color.colorAccent); mMenuMultipleActionsUp = (FloatingActionsMenu) rootView.findViewById(R.id.multiple_actions_up); mFabPopular.setOnClickListener(this); mFabRated.setOnClickListener(this); mFabFavourites.setOnClickListener(this); if (null != savedInstanceState && !errorShown) { ArrayList<Movie> movieList = savedInstanceState.getParcelableArrayList(BUNDLE_MOVIES_KEY); mMoviesAdapter.setMoviesData(movieList); } else { loadCards(); } return rootView; }
From source file:io.demiseq.jetreader.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); db = new JumpDatabaseHelper(MainActivity.this); initToolbar();/*from w ww.ja va 2 s .c om*/ setupDrawerLayout(); progressBar.getIndeterminateDrawable().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_ATOP); categories = db.getAllCategories(); prefs = PreferenceManager.getDefaultSharedPreferences(this); searchBox.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { toggleSearch(true); int position = temp.indexOf(adapter.getItem(i)); Intent intent = new Intent(MainActivity.this, DetailActivity.class); intent.putExtra("manga", temp.get(position)); startActivity(intent); } }); searchBox.setOnClearListener(new CustomAutoCompleteTextView.OnClearListener() { @Override public void onClear() { toggleSearch(true); } }); boolean isOpenFromNotification = getIntent().getBooleanExtra("favorite", false); if (savedInstanceState == null && !isOpenFromNotification) { GetHotMangas(); new getAllMangas().execute(); } else if (isOpenFromNotification) { GetSubscription(); new getAllMangas().execute(); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); Menu menu = view.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == R.id.drawer_feeds) { savedMenuId = item.getItemId(); item.setChecked(true); } } } else { setTitle(savedInstanceState.getString("title")); mangas = savedInstanceState.getParcelableArrayList("list"); if (mangas != null) temp = new ArrayList<>(mangas); adapter = new SearchAdapter(getApplicationContext(), R.layout.search_dropdown_item, mangas); searchBox.setAdapter(adapter); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); Menu menu = view.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == savedInstanceState.getInt("menu")) { savedMenuId = savedInstanceState.getInt("menu"); item.setChecked(true); } } } }
From source file:org.xbmc.kore.ui.MediaFileListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle args = getArguments();/*from ww w. jav a 2s .c om*/ if (args != null) { mediaType = args.getString(MEDIA_TYPE, Files.Media.MUSIC); if (mediaType.equalsIgnoreCase(Files.Media.VIDEO)) { playlistId = PlaylistType.VIDEO_PLAYLISTID; } else if (mediaType.equalsIgnoreCase(Files.Media.PICTURES)) { playlistId = PlaylistType.PICTURE_PLAYLISTID; } } ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_generic_media_list, container, false); ButterKnife.inject(this, root); hostManager = HostManager.getInstance(getActivity()); swipeRefreshLayout.setEnabled(false); emptyView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { browseSources(); } }); folderGridView.setEmptyView(emptyView); folderGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { handleFileSelect(adapter.getItem(position)); } }); if (adapter == null) { adapter = new MediaFileListAdapter(getActivity(), R.layout.grid_item_file); } folderGridView.setAdapter(adapter); if (savedInstanceState != null) { mediaType = savedInstanceState.getString(MEDIA_TYPE); //currentPath = savedInstanceState.getString(CURRENT_PATH); if (mediaType.equalsIgnoreCase(Files.Media.VIDEO)) { playlistId = PlaylistType.VIDEO_PLAYLISTID; } else if (mediaType.equalsIgnoreCase(Files.Media.PICTURES)) { playlistId = PlaylistType.PICTURE_PLAYLISTID; } ArrayList<FileLocation> list = savedInstanceState.getParcelableArrayList(PATH_CONTENTS); rootFileLocation = savedInstanceState.getParcelableArrayList(ROOT_PATH_CONTENTS); browseRootAlready = savedInstanceState.getBoolean(ROOT_VISITED); adapter.setFilelistItems(list); } else { browseSources(); } return root; }
From source file:com.gbozza.android.popularmovies.fragments.MovieDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContext = getActivity().getApplicationContext(); mMovie = null;// w w w . java 2 s. com if (getArguments().containsKey(PARCELABLE_MOVIE_KEY)) { mMovie = getArguments().getParcelable(PARCELABLE_MOVIE_KEY); } if (null != mMovie) { View rootView = inflater.inflate(R.layout.movie_detail, container, false); ButterKnife.bind(this, rootView); mMovieCollapsingToolbarLayout.setTitle(mMovie.getOriginalTitle()); ((AppCompatActivity) getActivity()).setSupportActionBar(mMovieToolbar); if (((AppCompatActivity) getActivity()).getSupportActionBar() != null) { setHasOptionsMenu(true); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } Picasso.with(mContext).load(mMovie.buildBackdropPath(mContext)).into(mMovieBackdropImageView); mMovieVoteAverageTextView.append(SpannableUtilities.makeBold(mDetailVoteAvgLabel)); mMovieVoteAverageTextView.append(mMovie.getVoteAverage()); mMovieReleaseDateTextView.append(SpannableUtilities.makeBold(mDetailReleaseDateLabel)); mMovieReleaseDateTextView.append(mMovie.getReleaseDate()); mMovieOverviewTextView.append(SpannableUtilities.makeBold(mDetailOverviewLabel)); mMovieOverviewTextView.append(mMovie.getOverview()); LinearLayoutManager videosLinearLayoutManager = new LinearLayoutManager(mContext); videosLinearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); mVideosRecyclerView.setLayoutManager(videosLinearLayoutManager); mVideosRecyclerView.setHasFixedSize(true); mVideosAdapter = new VideosAdapter(); mVideosRecyclerView.setAdapter(mVideosAdapter); LinearLayoutManager reviewsLinearLayoutManager = new LinearLayoutManager(mContext); mReviewsRecyclerView.setLayoutManager(reviewsLinearLayoutManager); mReviewsRecyclerView.setHasFixedSize(true); mReviewsAdapter = new ReviewsAdapter(); mReviewsRecyclerView.setAdapter(mReviewsAdapter); if (null != savedInstanceState) { ArrayList<Video> videoList = savedInstanceState.getParcelableArrayList(BUNDLE_VIDEOS_KEY); mVideosAdapter.setVideosData(videoList); ArrayList<Review> reviewList = savedInstanceState.getParcelableArrayList(BUNDLE_REVIEWS_KEY); mReviewsAdapter.setReviewsData(reviewList); } else { loadElements(DETAIL_ELEMENT_VIDEOS, mMovie.getId()); loadElements(DETAIL_ELEMENT_REVIEWS, mMovie.getId()); } return rootView; } return super.onCreateView(inflater, container, savedInstanceState); }