List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:it.geosolutions.geocollect.android.map.GeoCollectMapActivity.java
/** * Create the markers and add them to the MarkerOverlay Gets it from the Intent or from the savedInstanceState Assign them the proper <GeoPoint> * if missing//from w ww .j av a 2 s.c o m * * @param savedInstanceState */ private void createMarkers(Bundle savedInstanceState) { List<MarkerDTO> markerDTOs = null; // add the OverlayItem to the ArrayItemizedOverlay ArrayList<DescribedMarker> markers = null; if (savedInstanceState != null) { markerDTOs = savedInstanceState.getParcelableArrayList(MapsActivity.PARAMETERS.MARKERS); markers = MarkerUtils.markerDTO2DescribedMarkers(this, markerDTOs); } else { markerDTOs = getIntent().getParcelableArrayListExtra(MapsActivity.PARAMETERS.MARKERS); markers = MarkerUtils.markerDTO2DescribedMarkers(this, markerDTOs); // retrieve geopoint if missing if (getIntent().getExtras() == null) { return; } featureIdField = getIntent().getExtras().getString(PARAMETERS.FEATURE_ID_FIELD); if (featureIdField == null) { featureIdField = FEATURE_DEFAULT_ID; } if (!MarkerUtils.assignFeaturesFromDb(markers, featureIdField)) { Toast.makeText(this, R.string.error_unable_getfeature_db, Toast.LENGTH_LONG).show(); canConfirm = false; // TODO dialog : download features for this area? } } // create an ItemizedOverlay with the default marker overlayManager.getMarkerOverlay().getOverlayItems().addAll(markers); }
From source file:net.naonedbus.fragment.impl.ItineraireFragment.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); mIconPadding = getResources().getDimensionPixelSize(R.dimen.itinerary_icon_padding); if (savedInstanceState != null) { mFromLocation.set((Location) savedInstanceState.getParcelable(BUNDLE_LOCATION_FROM)); mToLocation.set((Location) savedInstanceState.getParcelable(BUNDLE_LOCATION_TO)); mDateTime.setMillis(savedInstanceState.getLong(BUNDLE_DATE_TIME)); mArriveBy = savedInstanceState.getBoolean(BUNDLE_ARRIVE_BY); mIconFromResId = savedInstanceState.getInt(BUNDLE_ICON_FROM); mIconToResId = savedInstanceState.getInt(BUNDLE_ICON_TO); mIconFromColor = savedInstanceState.getInt(BUNDLE_COLOR_FROM); mIconToColor = savedInstanceState.getInt(BUNDLE_COLOR_TO); final List<Parcelable> results = savedInstanceState.getParcelableArrayList(BUNDLE_RESULTS); for (final Parcelable parcelable : results) { mItineraryWrappers.add((ItineraryWrapper) parcelable); }/*from w w w . jav a 2 s. c om*/ } }
From source file:com.krayzk9s.imgurholo.ui.MessagingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.account_layout, container, false); LinearLayout headerLayout = (LinearLayout) view.findViewById(R.id.header); headerLayout.setVisibility(View.GONE); errorText = (TextView) view.findViewById(R.id.error); mDrawerList = (ListView) view.findViewById(R.id.account_list); ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); SharedPreferences settings = activity.getApiCall().settings; Log.d("Theme", settings.getString("theme", MainActivity.HOLO_LIGHT) + ""); if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT)) messageAdapter = new MessageAdapter(activity, R.layout.message_layout); else//from ww w. j a v a 2 s . co m messageAdapter = new MessageAdapter(activity, R.layout.message_layout_dark); if (savedInstanceState == null) { getMessages(); } else { ArrayList<JSONParcelable> messageDataArray = savedInstanceState.getParcelableArrayList("content"); messageAdapter.addAll(messageDataArray); messageAdapter.notifyDataSetChanged(); } mDrawerList.setAdapter(messageAdapter); if (messageData != null) mDrawerList.setClickable(false); else mDrawerList.setOnItemClickListener(new ItemClickListener()); return view; }
From source file:by.zatta.pilight.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "onCreate starts"); setContentView(R.layout.mainactivity_layout); mCurrentTitle = getString(R.string.app_name); SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String language = getPrefs.getString("languagePref", "unknown"); if (!language.equals("unknown")) makeLocale(language);//ww w . j a va 2s . c o m mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer); mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); if (savedInstanceState != null) { Log.v(TAG, "savedInstanceState was not null"); mDevices = savedInstanceState.getParcelableArrayList("config"); mCurrentTitle = savedInstanceState.getString("currentTitle", "oops"); getActionBar().setTitle(mCurrentTitle); initMenu(); } else { mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); openDialogFragment(StatusDialog.newInstance("CONNECTING")); } automaticBind(); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).build(); Log.v(TAG, "onCreate done"); }
From source file:com.bitants.wally.fragments.RandomImagesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_main_swiperefresh, container, false); if (rootView != null) { super.onCreateView(rootView); gridView = (AutoGridView) rootView.findViewById(R.id.listview); swipeClearLayout = (SwipeClearLayout) rootView.findViewById(R.id.swipe_container); swipeClearLayout.setOnRefreshListener(this); swipeClearLayout.setOnSwipeListener(this); swipeClearLayout.setCircleColor(getAppBarColor()); final ProgressBar progressBar = (ProgressBar) inflater.inflate(R.layout.view_custom_progressbar, swipeClearLayout, false); swipeClearLayout.setProgressBar(progressBar); setupAutoSizeGridView();//from w w w .ja v a 2s . co m if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) { Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_IMAGES_REQUEST_CREATE; msgObj.arg1 = 1; msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES); uiHandler.sendMessage(msgObj); currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE); } else { showLoader(); getImages(1, null); } ((MainActivity) getActivity()).addOnFileChangedListener(this); ((MainActivity) getActivity()).addOnFiltersChangedListener(this); } return rootView; }
From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_app_selector); LAUNCH_ACTIVITY_ANIM_BUNDLE = ActivityOptions .makeCustomAnimation(AppChoicesActivity.this, R.transition.left_in, R.transition.left_out) .toBundle();//w w w . j ava2s . c o m mPackageManager = getPackageManager(); mAppSelectionsStore = AppSelectionsStore.get(this); mRecyclerView = (RecyclerView) findViewById(R.id.app_selections_recycler_view); mLoadingView = (TextView) findViewById(R.id.app_list_loading_text_view); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); PreferenceManager.setDefaultValues(this, R.xml.main_settings, false); mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mShowOnlyEnabledApps = mPreferences.getBoolean(getString(R.string.show_enabled_apps_key), false); if (savedInstanceState != null && getSetupStatus(savedInstanceState)) { mAppSelections = savedInstanceState.getParcelableArrayList(STATE_APP_SELECTIONS); Parcelable listState = savedInstanceState.getParcelable(STATE_RECYCLER_VIEW); if (mShowOnlyEnabledApps) { List<AppSelection> appSelectionsSubList = new ArrayList<>(); for (AppSelection appSelection : mAppSelections) { if (appSelection.isSelected()) { appSelectionsSubList.add(appSelection); } } mAdapter = new ActivityAdapter(appSelectionsSubList); } else { mAdapter = new ActivityAdapter(mAppSelections); } mRecyclerView.setAdapter(mAdapter); mRecyclerView.getLayoutManager().onRestoreInstanceState(listState); mSetupComplete = getSetupStatus(savedInstanceState); } else { mLoadingView.setText(getString(R.string.app_list_loading_text)); mRecyclerView.setVisibility(View.GONE); mLoadingView.setVisibility(View.VISIBLE); mProgressBar.setVisibility(View.VISIBLE); new AppListSetup().execute(); } }
From source file:com.example.smsquickform.Homescreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_homescreen); ActivityHelper.initialize(this); //This is to ensure that the rotation persists across activities and not just this one Log.d(TAG, "Created"); Intent intent = getIntent();/*from w w w .j a v a2 s . com*/ mBtnSearch = (Button) findViewById(R.id.btnSearch); mBtnConnect = (Button) findViewById(R.id.btnConnect); mButtonAnak = (Button) findViewById(R.id.buttonAnak); mButtonIbu = (Button) findViewById(R.id.buttonIbu); heading = (TextView) findViewById(R.id.txtListHeading); mLstDevices = (ListView) findViewById(R.id.lstDevices); /* *Check if there is a savedInstanceState. If yes, that means the onCreate was probably triggered by a configuration change *like screen rotate etc. If that's the case then populate all the views that are necessary here */ if (savedInstanceState != null) { ArrayList<BluetoothDevice> list = savedInstanceState.getParcelableArrayList(DEVICE_LIST); if (list != null) { initList(list); MyAdapter adapter = (MyAdapter) mLstDevices.getAdapter(); int selectedIndex = savedInstanceState.getInt(DEVICE_LIST_SELECTED); if (selectedIndex != -1) { adapter.setSelectedIndex(selectedIndex); mBtnConnect.setEnabled(true); } } else { initList(new ArrayList<BluetoothDevice>()); } } else { initList(new ArrayList<BluetoothDevice>()); } //IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); //this.registerReceiver(mReceiver, filter); // Register for broadcasts when discovery has finished //filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); //this.registerReceiver(mReceiver, filter); mBtnSearch.setOnClickListener(new OnClickListener() { List<BluetoothDevice> listDevices; @Override public void onClick(View arg0) { mBTAdapter = BluetoothAdapter.getDefaultAdapter(); heading.setText("Searching"); mBtnSearch.setEnabled(false); if (mBTAdapter == null) { Toast.makeText(getApplicationContext(), "Bluetooth not found", Toast.LENGTH_SHORT).show(); } else if (!mBTAdapter.isEnabled()) { Intent enableBT = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBT, BT_ENABLE_REQUEST); } else { //listDevices = new ArrayList<BluetoothDevice>(); /*for (BluetoothDevice device : pairedDevices) { listDevices.add(device); }*/ new SearchDevices().execute(); } } }); mButtonIbu.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (mLstDevices != null) { ArrayList<BluetoothDevice> devices = (ArrayList<BluetoothDevice>) ((MyAdapter) (mLstDevices .getAdapter())).getEntireList(); Intent intent = new Intent(getApplicationContext(), MainActivity.class); intent.putExtra(DEVICES_LISTS, devices); try { } catch (NullPointerException ex) { } intent.putExtra(DEVICE_UUID, mDeviceUUID.toString()); intent.putExtra(BUFFER_SIZE, mBufferSize); startActivity(intent); } } }); mBtnConnect.setOnClickListener(new OnClickListener() { /** * connect to all paired devices */ @Override public void onClick(View arg0) { List<BluetoothDevice> devices = ((MyAdapter) (mLstDevices.getAdapter())).getEntireList(); for (int i = 0; i < devices.size(); i++) { BluetoothDevice device = devices.get(i); msg(device.getName()); Intent intent = new Intent(getApplicationContext(), MainActivity.class); intent.putExtra(DEVICE_EXTRA, device); intent.putExtra(DEVICE_UUID, mDeviceUUID.toString()); intent.putExtra(BUFFER_SIZE, mBufferSize); startActivity(intent); } } }); }
From source file:com.dmitrymalkovich.android.popularmoviesapp.MovieListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_list); ButterKnife.bind(this); mToolbar.setTitle(R.string.title_movie_list); setSupportActionBar(mToolbar);//from w w w .ja v a 2s . co m String tag = RetainedFragment.class.getName(); this.mRetainedFragment = (RetainedFragment) getSupportFragmentManager().findFragmentByTag(tag); if (this.mRetainedFragment == null) { this.mRetainedFragment = new RetainedFragment(); getSupportFragmentManager().beginTransaction().add(this.mRetainedFragment, tag).commit(); } mRecyclerView.setLayoutManager( new GridLayoutManager(this, getResources().getInteger(R.integer.grid_number_cols))); // To avoid "E/RecyclerView: No adapter attached; skipping layout" mAdapter = new MovieListAdapter(new ArrayList<Movie>(), this); mRecyclerView.setAdapter(mAdapter); // For large-screen layouts (res/values-w900dp). mTwoPane = findViewById(R.id.movie_detail_container) != null; if (savedInstanceState != null) { mSortBy = savedInstanceState.getString(EXTRA_SORT_BY); if (savedInstanceState.containsKey(EXTRA_MOVIES)) { List<Movie> movies = savedInstanceState.getParcelableArrayList(EXTRA_MOVIES); mAdapter.add(movies); findViewById(R.id.progress).setVisibility(View.GONE); // For listening content updates for tow pane mode if (mSortBy.equals(FetchMoviesTask.FAVORITES)) { getSupportLoaderManager().initLoader(FAVORITE_MOVIES_LOADER, null, this); } } updateEmptyState(); } else { // Fetch Movies only if savedInstanceState == null fetchMovies(mSortBy); } }
From source file:com.example.julia.popularmovies.details.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); // horizontal list layout for trailers mTrailerListAdapter = new TrailerListAdapter(new ArrayList<Trailer>()); LinearLayoutManager horizontalLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); mTrailersRecyclerView.setLayoutManager(horizontalLayoutManager); mTrailersRecyclerView.setAdapter(mTrailerListAdapter); // vertical list layout for reviews mReviewListAdapter = new ReviewListAdapter(new ArrayList<Review>()); LinearLayoutManager verticalLayoutManager = new LinearLayoutManager(getContext()); mReviewsRecyclerView.setLayoutManager(verticalLayoutManager); mReviewsRecyclerView.setAdapter(mReviewListAdapter); if (mMovie != null) { // fetch trailers only if there is no trailers fetched yet if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_TRAILERS)) { ArrayList<Trailer> trailers = savedInstanceState.getParcelableArrayList(EXTRA_TRAILERS); mTrailerListAdapter.add(trailers); } else {//from w w w . ja va2 s .c o m new FetchTrailersTask(this).execute(Long.toString(mMovie.getId())); } // fetch reviews only if there is no reviews fetched yet if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_REVIEWS)) { List<Review> reviews = savedInstanceState.getParcelableArrayList(EXTRA_REVIEWS); mReviewListAdapter.add(reviews); } else { new FetchReviewsTask(this).execute(Long.toString(mMovie.getId())); } new FetchMovieInfoTask(this).execute(Long.toString(mMovie.getId())); if (mListener.isTwoPane()) { // Set movie backdrop String backdropUrl = mMovie.getBackdrop(); if (!backdropUrl.equals("null")) { Picasso.with(getContext()).load(mMovie.getImagePath(getContext(), backdropUrl)) .into(mBackdropView); } } else { mListener.backdropUrl(mMovie.getImagePath(getContext(), mMovie.getBackdrop())); mBackdropView.setVisibility(View.GONE); } // Set movie poster String posterUrl = mMovie.getPoster(); if (!posterUrl.equals("null")) { Picasso.with(getContext()).load(mMovie.getImagePath(getContext(), posterUrl)).into(mPosterView); } else { mPosterView.setImageDrawable(mPlaceHolderPoster); } // Set movie title mTitleView.setText(mMovie.getTitle()); // Set movie genres if (mMovie.getReadableGenres() != null) { mGenresView.setText(mMovie.getReadableGenres()); } else { mGenresView.setVisibility(View.GONE); } // Set movie release date in user-friendly view mDateView.setText(mMovie.getDate(getContext())); // Set movie rating setRatingBar(); mRatingView.setText(getResources().getString(R.string.format_movie_rating, mMovie.getRating())); // Set movie overview mPlotView.setText(mMovie.getPlot()); } return rootView; }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
@Override public void onViewStateRestored(@Nullable Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); if (savedInstanceState != null) { mCapturedImageURI = savedInstanceState.getParcelable(IMAGE_URI); mImagePath = savedInstanceState.getString(IMAGE_PATH); mArrivalInfo = (ObaArrivalInfo) savedInstanceState.getSerializable(TRIP_INFO); mAgencyName = savedInstanceState.getString(AGENCY_NAME); List<AttributeValue> values = savedInstanceState.getParcelableArrayList(ATTRIBUTES); mAttributeValueHashMap.clear();//from w w w. ja v a 2s .c o m if (values != null) { for (AttributeValue v : values) { mAttributeValueHashMap.put(v.getCode(), v); } } mIsProgressDialogShowing = savedInstanceState.getBoolean(SHOW_PROGRESS_DIALOG); if (mIsProgressDialogShowing) { showProgressDialog(true); } } }