List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:com.baruckis.nanodegree.spotifystreamer.fragments.ArtistTracksListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // if view is restored... if (savedInstanceState == null) return;//from w ww .j a v a2 s . co m if (savedInstanceState.containsKey(ARG_COUNTRY_CODE)) { mCountryCode = savedInstanceState.getString(ARG_COUNTRY_CODE); } // check if error message should be shown if (savedInstanceState.containsKey(InfoView.STATE_IS_ERROR) && savedInstanceState.getBoolean(InfoView.STATE_IS_ERROR)) { showError(); } else if (savedInstanceState.containsKey(STATE_TRACKS_LIST)) { // than restore tracks list without call to the web mTracksList = savedInstanceState.getParcelableArrayList(STATE_TRACKS_LIST); showTracks(); } // restore action bar to show correct information if (savedInstanceState.containsKey(ARG_ACTIVATED_ARTIST_NAME)) { mArtistName = savedInstanceState.getString(ARG_ACTIVATED_ARTIST_NAME); restoreActionBar(); } // restore artist id if (savedInstanceState.containsKey(ARG_ACTIVATED_ARTIST_ID)) { mArtistId = savedInstanceState.getString(ARG_ACTIVATED_ARTIST_ID); } }
From source file:de.sourcestream.movieDB.controller.CastDetailsInfo.java
/** * Fired when are restoring from backState or orientation has changed. * * @param args our bundle with saved state. Our parent fragment handles the saving. */// w w w . j ava 2 s . c o m @SuppressWarnings("ConstantConditions") private void onOrientationChange(Bundle args) { // Name name.setText(args.getString("name")); // Poster path if (args.getString("profilePathURL") != null) { activity.setBackDropImage(profilePath, args.getString("profilePathURL")); profilePath.setTag(args.getString("profilePathURL")); } // Birth info if (!args.getString("birthInfo").isEmpty()) activity.setText(birthInfo, args.getString("birthInfo")); else activity.hideView(birthInfo); // Also known as if (!args.getString("alsoKnownAs").isEmpty()) { activity.setText(alsoKnownAs, args.getString("alsoKnownAs")); } else activity.hideView(alsoKnownAs); knownList = args.getParcelableArrayList("knownList"); if (knownList != null && knownList.size() > 0) setKnownList(knownList); else activity.hideView(knownHolder); }
From source file:com.ushahidi.platform.mobile.app.presentation.view.ui.activity.AddPostActivity.java
private void initialize(Bundle savedInstanceState) { if (savedInstanceState == null) { mFormId = getIntent().getLongExtra(INTENT_EXTRA_PARAM_FORM_ID, 0l); mFormTitle = getIntent().getStringExtra(INTENT_EXTRA_PARAM_FORM_TITLE); initializeTagsView();/*ww w .ja v a 2 s . co m*/ initializeFormAttributeView(); } else { mFormId = savedInstanceState.getLong(BUNDLE_STATE_PARAM_FORM_ID); mFormTitle = savedInstanceState.getString(BUNDLE_STATE_PARAM_FORM_TITLE); mFormStages = (ArrayList) savedInstanceState.getParcelableArrayList(BUNDLE_STATE_PARAM_FORM_STEPS); mFormAttributeModels = (ArrayList) savedInstanceState .getParcelableArrayList(BUNDLE_STATE_PARAM_FORM_ATTRIBUTES); } getSupportActionBar().setTitle(mFormTitle); }
From source file:com.google.samples.apps.friendlyping.fragment.FriendlyPingFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // Get the list view and set it up. ListView listView = (ListView) view.findViewById(R.id.ping_list); listView.setOnItemClickListener(mOnItemClickListener); listView.setEmptyView(view.findViewById(android.R.id.empty)); if (listView.getAdapter() == null) { mPingerAdapter = new PingerAdapter(getActivity()); listView.setAdapter(mPingerAdapter); }//from w w w . j av a2s . c o m // Check for saved list of pingers. if (savedInstanceState == null) { // Start IntentService to register this application with GCM. Intent service = new Intent(getActivity(), RegistrationIntentService.class); getActivity().startService(service); } else { // If saved list of pingers exists use them. ArrayList<Pinger> tmpPingers = savedInstanceState.getParcelableArrayList(KEY_PINGERS); mPingerAdapter.addPinger(tmpPingers); } // Restore previously saved data. if (savedInstanceState != null) { ArrayList<Pinger> tmpPingers = savedInstanceState.getParcelableArrayList(KEY_PINGERS); if (tmpPingers != null) { mPingerAdapter = new PingerAdapter(view.getContext(), tmpPingers); listView.setAdapter(mPingerAdapter); } } final AppCompatActivity activity = (AppCompatActivity) getActivity(); if (null != activity) { // Setting the status bar color and Toolbar as ActionBar requires API 21+. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { activity.setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar_ping)); //noinspection ConstantConditions activity.getSupportActionBar().setDisplayShowTitleEnabled(false); activity.getWindow().setStatusBarColor(getResources().getColor(R.color.primary_dark)); } } // [START show_ad] AdView adView = (AdView) view.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); // [END show_ad] }
From source file:com.liferay.alerts.activity.MainActivity.java
@Override protected void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main);//from www. ja v a 2 s. c o m _cardList = (LinearLayout) findViewById(R.id.card_list); _send = (TextView) findViewById(R.id.send); _userName = (TextView) findViewById(R.id.user_name); _send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, SendActivity.class); startActivity(intent); } }); try { TextView version = (TextView) findViewById(R.id.version); PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); version.setText(info.versionName); } catch (PackageManager.NameNotFoundException nnfe) { } SettingsUtil.init(this); if (state != null) { _alerts = state.getParcelableArrayList(_ALERTS); } else { _alerts = AlertDAO.getInstance(this).getInstance(this).get(); } for (Alert alert : _alerts) { _addCard(alert); } _addPushNotificationsDevice(); _registerAddCardReceiver(); _checkSendPermission(); }
From source file:de.uni_koblenz_landau.apow.SettingsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.settings_fragment, container, false); // Create UI references. mUsernameView = (EditText) view.findViewById(R.id.settings_username); mPasswordView = (EditText) view.findViewById(R.id.settings_password); mLocationsView = (Spinner) view.findViewById(R.id.settings_locations); mFormView = view.findViewById(R.id.settings_form); mStatusView = view.findViewById(R.id.settings_status); mStatusMessageView = (TextView) view.findViewById(R.id.settings_status_message); // Restore UI from saved instance or load data. if (savedInstanceState != null) { mSettings = savedInstanceState.getParcelable(ARG_SETTINGS); if (mSettings != null) { mLocations = savedInstanceState.getParcelableArrayList(ARG_LOCATIONS); ArrayAdapter<ListViewItem> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, mLocations); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mLocationsView.setAdapter(adapter); }//from www . java2 s . c om } else { loadSettings(); } return view; }
From source file:org.gdg.frisbee.android.chapter.MainActivity.java
/** * Called when the activity is first created. * * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b> *//*from w w w . j av a 2 s . c om*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mLocationComparator = new ChapterComparator(PrefUtils.getHomeChapterIdNotNull(this), App.getInstance().getLastLocation()); mChapterAdapter = new ChapterAdapter(MainActivity.this, R.layout.spinner_item_actionbar); mChapterAdapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); initSpinner(); ArrayList<Chapter> chapters = null; if (savedInstanceState != null) { chapters = savedInstanceState.getParcelableArrayList(ARG_CHAPTERS); selectedChapterId = savedInstanceState.getString(ARG_SELECTED_CHAPTER); } else { Intent intent = getIntent(); if (FirstStartActivity.ACTION_FIRST_START.equals(intent.getAction())) { Timber.d("Completed FirstStartWizard"); if (PrefUtils.isSignedIn(this)) { mFirstStart = true; } } selectedChapterId = getChapterIdFromIntent(intent); if (AppInviteReferral.hasReferral(intent)) { // In this case the referral data is in the intent launching the MainActivity, // which means this user already had the app installed. We do not have to // register the Broadcast Receiver to listen for Play Store Install information launchAppInviteActivity(intent); } } if (selectedChapterId == null) { selectedChapterId = PrefUtils.getHomeChapterIdNotNull(this); } if (chapters != null) { initChapters(chapters); } else { App.getInstance().getModelCache().getAsync(Const.CACHE_KEY_CHAPTER_LIST_HUB, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Directory directory = (Directory) item; initChapters(directory.getGroups()); } @Override public void onNotFound(String key) { if (Utils.isOnline(MainActivity.this)) { fetchChapters(); } else { showError(R.string.offline_alert); } } }); } if (PrefUtils.shouldShowSeasonsGreetings(this)) { SeasonsGreetingsFragment seasonsGreetings = new SeasonsGreetingsFragment(); seasonsGreetings.show(getSupportFragmentManager(), "dialog"); } if (PrefUtils.isSignedIn(this)) { checkAchievements(); } }
From source file:com.simas.vc.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Reset player container and preview sizes when (re-)created sPlayerContainerSize = 0;//from w ww . j a va 2s. co m sPreviewSize = 0; // Always reset observers when (re-)creating the activity sItems.unregisterAllObservers(); // Restore items if available, otherwise make sure the list is empty if (savedInstanceState != null) { ArrayList<NavItem> items = savedInstanceState.getParcelableArrayList(STATE_ITEMS); if (items != null) { sItems = new ObservableList(); sItems.addAll(items); } else { sItems.clear(); } } else { sItems.clear(); } // Init a ProgressBar (to be used by PlayerFragments) mProgressOverlay = getLayoutInflater().inflate(R.layout.progress_bar_overlay, null); setContentView(R.layout.activity_main); /* Toolbar */ mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); // addTooltips(); /* Pager */ mViewPager = (ViewPager) findViewById(R.id.view_pager); mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); mViewPager.addOnPageChangeListener(new PagerScrollListener()); mViewPager.setAdapter(mPagerAdapter); // This is to avoid a black screen flash when the SurfaceView is setting up another window // https://code.google.com/p/gmaps-api-issues/issues/detail?id=4639#c2 mViewPager.requestTransparentRegion(mViewPager); // Observer final String PAGER_OBSERVER = "pager_observer"; MainActivity.sItems.registerDataSetObserver(new ObservableList.Observer() { @Override public void onRemoved(int position) { Log.e(TAG, "removed: " + position); // Remove fragment and its state from adapter mPagerAdapter.onItemRemoved(position + 1); // Update count and notify mPagerAdapter.setCount(MainActivity.sItems.size()); } @Override public void onModified() { super.onModified(); // Update count and notify mPagerAdapter.setCount(MainActivity.sItems.size()); } }, PAGER_OBSERVER); /* Drawer */ mNavDrawerFragment = (NavDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); mNavDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); // Make sure editor item is == to the LV's current selection (e.g. on adapter data deletion) final String EDITOR_AND_DRAWER_ITEM_MATCHER = "match_items_between_editor_and_drawer"; sItems.registerDataSetObserver(new ObservableList.Observer() { private ListView lv = mNavDrawerFragment.getListView(); private Runnable mCheckItems = new Runnable() { @Override public void run() { // Make sure we're not in CAB mode (multiple selections) Object checkedItem; if (lv.getChoiceMode() == ListView.CHOICE_MODE_SINGLE) { try { checkedItem = lv.getItemAtPosition(lv.getCheckedItemPosition()); } catch (IndexOutOfBoundsException ignored) { return; } // Make sure the editor's item is the same as the currently checked one if (getEditorFragment() != null && getEditorFragment().getItem() != checkedItem) { mNavDrawerFragment.selectItem(ListView.INVALID_POSITION); } } } }; @Override public void onModified() { super.onModified(); mCheckItems.run(); } @Override public void onRemoved(int position) { super.onRemoved(position); mCheckItems.run(); } }, EDITOR_AND_DRAWER_ITEM_MATCHER); // ToDo default item test if (sItems.size() == 0) { new Handler().postDelayed(new Runnable() { @Override public void run() { onFileChosen(new File("/sdcard/Movies/Serenity.mp4")); // onFileChosen(new File("/sdcard/Movies/iwatch.mp4")); // onFileChosen(new File("/sdcard/Movies/macbook.mp4")); // onFileChosen(new File("/sdcard/Movies/1.mp4")); // onFileChosen(new File("/sdcard/Movies/2.mp4")); // onFileChosen(new File("/sdcard/Movies/3.mp4")); } }, 1000); // new Handler().postDelayed(new Runnable() { // @Override // public void run() { //// sItems.remove(0); // mViewPager.setCurrentItem(2); // new Handler().postDelayed(new Runnable() { // @Override // public void run() { // sItems.remove(1); // } // }, 2000); // } // }, 2000); } }
From source file:com.gbozza.android.stockhawk.ui.StockFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_stocks, container, false); ButterKnife.bind(this, rootView); mContext = getContext();//from ww w . ja v a2s.c o m mAdapter = new StockAdapter(mContext, new StockAdapter.StockAdapterOnClickHandler() { @Override public void onClick(String symbol, StockAdapter.StockViewHolder vh) { ((Callback) getActivity()).onItemSelected(symbol, vh); } }); mStockRecyclerView.setAdapter(mAdapter); mStockRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); if (null != savedInstanceState) { manageError(); if (savedInstanceState.containsKey(BUNDLE_STOCK_KEY)) { ArrayList<StockParcelable> stockList = savedInstanceState.getParcelableArrayList(BUNDLE_STOCK_KEY); MatrixCursor matrixCursor = new MatrixCursor(DetailFragment.DETAIL_COLUMNS); getActivity().startManagingCursor(matrixCursor); for (StockParcelable stock : stockList) { matrixCursor.addRow(new Object[] { stock.getId(), stock.getSymbol(), stock.getPrice(), stock.getAbsolute_change(), stock.getPercentage_change(), stock.getHistory() }); } mAdapter.setCursor(matrixCursor); } } else { mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setRefreshing(true); Intent inboundIntent = getActivity().getIntent(); if (null != inboundIntent && !inboundIntent.hasExtra(ListWidgetService.EXTRA_LIST_WIDGET_SYMBOL)) { QuoteSyncJob.initialize(mContext, QuoteSyncJob.PERIODIC_ID); onRefresh(); } getActivity().getSupportLoaderManager().initLoader(STOCK_LOADER, null, this); } FloatingActionButton addStockFab = (FloatingActionButton) rootView.findViewById(R.id.fab); addStockFab.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new AddStockDialog().show(getActivity().getSupportFragmentManager(), "StockDialogFragment"); } }); new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { return false; } @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { String symbol = mAdapter.getSymbolAtPosition(viewHolder.getAdapterPosition()); PrefUtils.removeStock(mContext, symbol); mContext.getContentResolver().delete(Contract.Quote.makeUriForStock(symbol), null, null); } }).attachToRecyclerView(mStockRecyclerView); return rootView; }
From source file:com.baruckis.nanodegree.spotifystreamer.fragments.ArtistsListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (savedInstanceState != null) { // Check if error message should be shown, and if yes than don't continue on other checks and return; if (savedInstanceState.containsKey(InfoView.STATE_IS_ERROR) && savedInstanceState.getBoolean(InfoView.STATE_IS_ERROR)) { showError();/*from w w w .j a va2 s.c om*/ return; } // If the was no error than get artists list, which can be empty or filled with data. // If it is empty than there was no such artists based on search and message for the user will be showed. if (savedInstanceState.containsKey(STATE_ARTISTS_LIST)) { // restore the previously serialized artists list. mArtistsList = savedInstanceState.getParcelableArrayList(STATE_ARTISTS_LIST); showArtists(); return; } } // if there was no error or no artist list saved (is null), that means that initial message should be shown mInfoView.showEmpty(getString(R.string.info_msg_empty_artists_list_init)); resetActionBar(); }