List of usage examples for android.os Bundle getParcelableArrayList
@Nullable public <T extends Parcelable> ArrayList<T> getParcelableArrayList(@Nullable String key)
From source file:com.github.capone.controller.discovery.DiscoveryListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); adapter = new ServerListAdapter(getActivity()); adapter.setOnStarClickedListener(new ServerListAdapter.OnStarClickedListener() { @Override/*from w w w . j a v a 2s . c o m*/ public boolean onStarClicked(Server to) { ServerRecord server = ServerRecord.findByTo(to); if (server == null) { server = new ServerRecord(to); server.save(); return true; } else { server.delete(); return false; } } }); if (savedInstanceState != null) { ArrayList<Server> servers = savedInstanceState.getParcelableArrayList(EXTRA_SERVERS); adapter.addAll(servers); } }
From source file:elbauldelprogramador.com.gpsqr.MapsActivity.java
/** * Updates fields based on data stored in the bundle. * * @param savedInstanceState The activity state saved in the Bundle. */// ww w. j a va 2 s . com private void updateValuesFromBundle(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Log.d(TAG, "Updating values from bundle"); } if (savedInstanceState != null) { // Update the value of mLocationsList from the Bundle and update the UI to show the // correct latitude and longitude. if (savedInstanceState.keySet().contains(LOCATION_KEY)) { // Since LOCATION_KEY was found in the Bundle, we can be sure that mLocationsList // is not null. mLocationsList = savedInstanceState.getParcelableArrayList(LOCATION_KEY); mCurrentLocation = mLocationsList.get(mLocationsList.size() - 1); if (mLocationsList.size() >= 2) { mPreviousLocation = mLocationsList.get(mLocationsList.size() - 2); } } } else { mLocationsList = new ArrayList<>(2); } }
From source file:org.fs.galleon.presenters.ToolsFragmentPresenter.java
@Override public void restoreState(Bundle restoreState) { if (restoreState != null) { if (restoreState.containsKey(KEY_TEMP_TAKEN_PHOTO)) { String absolutePath = restoreState.getString(KEY_TEMP_TAKEN_PHOTO); if (!StringUtility.isNullOrEmpty(absolutePath)) { tempTakenPhoto = new File(absolutePath); }/*w ww .j a v a 2 s . co m*/ } if (restoreState.containsKey(KEY_IMAGE_ENTITIES)) { images = restoreState.getParcelableArrayList(KEY_IMAGE_ENTITIES); } if (restoreState.containsKey(KEY_PDF_FILES)) { List<String> absolutePaths = restoreState.getStringArrayList(KEY_PDF_FILES); if (!Collections.isNullOrEmpty(absolutePaths)) { List<File> fileList = StreamSupport.stream(absolutePaths).map(File::new) .collect(Collectors.toList()); pdfs.addAll(fileList); } } } }
From source file:com.bitants.wally.fragments.LatestFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_main, container, false); if (rootView != null) { super.onCreateView(rootView); setupAutoSizeGridView();// w w w .ja v a2 s . c om 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.ultramegasoft.flavordex2.fragment.AbsPhotosFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMediaReadable = Environment.getExternalStorageDirectory().canRead(); if (!mMediaReadable) { return;//w w w . j av a2 s. c o m } setHasOptionsMenu(true); final Context context = getContext(); if (context == null) { return; } mHasCamera = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); if (savedInstanceState != null) { final ArrayList<PhotoHolder> photos = savedInstanceState.getParcelableArrayList(STATE_PHOTOS); if (photos != null) { mPhotos = photos; } mCapturedPhoto = savedInstanceState.getParcelable(STATE_CAPTURE_URI); final Uri loadingUri = savedInstanceState.getParcelable(STATE_LOADING_URI); if (loadingUri != null) { mPhotoLoader = new PhotoLoader(context, this, loadingUri); mPhotoLoader.execute(); } } }
From source file:org.apps8os.motivator.ui.MoodQuestionActivity.java
/** Called when the activity is first created. */ @Override/*w w w . java 2s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mood_question); mDayDataHandler = new DayDataHandler(this); mCardsViewPagerEnergy = (ViewPager) findViewById(R.id.mood_question_viewpager_cards); mCardsViewPagerEnergy.setAdapter(new ImagesPagerAdapter(mImages1, mTitles1, this)); setViewPager(mCardsViewPagerEnergy); mEnergyLevelText = (TextView) findViewById(R.id.mood_question_energylevel_textview); mEnergyLevelText.setText(mCardsViewPagerEnergy.getAdapter().getPageTitle(DEFAULT_MOOD_SELECTION)); // Set an OnPageChangeListener to the ViewPager, change the text when a page is selected mCardsViewPagerEnergy .setOnPageChangeListener(new ViewPageChangeListener(mCardsViewPagerEnergy, mEnergyLevelText)); mCardsViewPagerMood = (ViewPager) findViewById(R.id.mood_question_viewpager_cards2); mCardsViewPagerMood.setAdapter(new ImagesPagerAdapter(mImages2, mTitles2, this)); setViewPager(mCardsViewPagerMood); // Get the text field for energy level mMoodLevelText = (TextView) findViewById(R.id.mood_question_moodlevel_textview); mMoodLevelText.setText(mCardsViewPagerMood.getAdapter().getPageTitle(DEFAULT_MOOD_SELECTION)); // Set an OnPageChangeListener to the ViewPager, change the text when a page is selected mCardsViewPagerMood .setOnPageChangeListener(new ViewPageChangeListener(mCardsViewPagerMood, mMoodLevelText)); final LayoutInflater inflater = getLayoutInflater(); LinearLayout buttons = (LinearLayout) findViewById(R.id.mood_question_buttons); // Change the OK button to next button which opens the checking events activity if there are events to check. final Bundle extras = getIntent().getExtras(); if (extras != null && extras.getBoolean(EventDataHandler.EVENTS_TO_CHECK, false)) { Button nextButton = (Button) inflater.inflate(R.layout.element_ok_button, buttons, false); nextButton.setText(getString(R.string.next)); nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { saveMood(v); Intent intent = new Intent(MoodQuestionActivity.this, CheckEventsActivity.class); intent.putExtra(MotivatorEvent.YESTERDAYS_EVENTS, extras.getParcelableArrayList(MotivatorEvent.YESTERDAYS_EVENTS)); startActivity(intent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(NotificationService.NOTIFICATION_ID_MOOD); finish(); } }); buttons.addView(nextButton); } else { Button okButton = (Button) inflater.inflate(R.layout.element_ok_button, buttons, false); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { saveMood(v); String toastMsg; if (mCardsViewPagerMood.getCurrentItem() > 2) { toastMsg = getString(R.string.questionnaire_done_toast_good_mood); } else if (mCardsViewPagerMood.getCurrentItem() == 2) { toastMsg = getString(R.string.questionnaire_done_toast_ok_mood); } else { toastMsg = getString(R.string.questionnaire_done_toast_bad_mood); } View toastLayout = (View) inflater.inflate(R.layout.element_mood_toast, (ViewGroup) findViewById(R.id.mood_toast_layout)); TextView toastText = (TextView) toastLayout.findViewById(R.id.mood_toast_text); toastText.setText(toastMsg); toastText.setTextColor(Color.WHITE); Toast questionnaireDone = new Toast(getApplicationContext()); questionnaireDone.setDuration(Toast.LENGTH_SHORT); questionnaireDone.setView(toastLayout); questionnaireDone.show(); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(NotificationService.NOTIFICATION_ID_MOOD); finish(); } }); buttons.addView(okButton); } }
From source file:eu.pellerito.popularmoviesproject2.fragment.DetailFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { reviewArrayList = new ArrayList<>(); trailerArrayList = new ArrayList<>(); //Restore the fragment state mMovieContent = savedInstanceState.getParcelable(String.valueOf(R.string.movie_save_state)); reviewArrayList = savedInstanceState.getParcelableArrayList(String.valueOf(R.string.review_save_state)); trailerArrayList = savedInstanceState .getParcelableArrayList(String.valueOf(R.string.trailer_save_state)); if (trailerArrayList != null) { viewTrailer(trailerArrayList); }/*from w w w . ja v a 2s . com*/ readReview(reviewArrayList); } else { fetchTrailer(mMovieContent.getId()); fetchReview(mMovieContent.getId()); } }
From source file:org.xbmc.kore.ui.sections.video.AllCastActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_all_cast); ButterKnife.inject(this); // Set up the drawer. navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); if (savedInstanceState == null) { movie_tvshow_title = getIntent().getStringExtra(EXTRA_TITLE); castArrayList = getIntent().getParcelableArrayListExtra(EXTRA_CAST_LIST); } else {/*from w ww . java2 s. co m*/ movie_tvshow_title = savedInstanceState.getString(EXTRA_TITLE); castArrayList = savedInstanceState.getParcelableArrayList(EXTRA_CAST_LIST); } //LogUtils.LOGD(TAG, "Showing cast for: " + movie_tvshow_title); // Configure the grid castGridView.setEmptyView(emptyView); castGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Get the name from the tag Utils.openImdbForPerson(AllCastActivity.this, ((ViewHolder) view.getTag()).castName); } }); CastArrayAdapter arrayAdapter = new CastArrayAdapter(this, castArrayList); castGridView.setAdapter(arrayAdapter); setupActionBar(movie_tvshow_title); }
From source file:com.bmd.android.collection.SimpleArrayMapTest.java
public void testParcelable() { final ParcelableObjectSparseObjectEntry[] parcelableArray = AndroidCollections.iterate(mArray).only() .values("4", "1").toParcelableArray(ParcelableObjectSparseObjectEntry.class); assertThat(parcelableArray).hasSize(2); assertThat(parcelableArray[0].getKey()).isEqualTo(1); assertThat(parcelableArray[0].getValue()).isEqualTo("1"); assertThat(parcelableArray[1].getKey()).isEqualTo(4); assertThat(parcelableArray[1].getValue()).isEqualTo("4"); final ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>> parcelableList = AndroidCollections .iterate(mArray).but().keys(Arrays.asList(1, 2, 3)).reverse().toParcelableList(); assertThat(parcelableList).hasSize(2); assertThat(parcelableList.get(0).getKey()).isEqualTo(4); assertThat(parcelableList.get(0).getValue()).isEqualTo("4"); assertThat(parcelableList.get(1).getKey()).isEqualTo(0); assertThat(parcelableList.get(1).getValue()).isEqualTo("0"); assertThat(parcelableList).containsExactly(SparseEntries.parcelableEntry(Integer.valueOf(4), "4"), SparseEntries.parcelableEntry(Integer.valueOf(0), "0")); final Bundle bundle = new Bundle(); bundle.putParcelableArray("array", parcelableArray); bundle.putParcelableArrayList("list", parcelableList); final Parcel parcel = Parcel.obtain(); bundle.writeToParcel(parcel, 0);//from w w w . j ava 2 s .c o m parcel.setDataPosition(0); final Bundle out = parcel.readBundle(); out.setClassLoader(AndroidCollections.class.getClassLoader()); assertThat(out.getParcelableArray("array")).isEqualTo(parcelableArray); assertThat(out.getParcelableArrayList("list")).isEqualTo(new ArrayList<Parcelable>(parcelableList)); final ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>> filledList = new ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>>( 2); AndroidCollections.iterate(mArray).but().keys(1, 2, 3).reverse().fillParcelable(filledList); assertThat(filledList).isEqualTo(parcelableList); final ParcelableObjectSparseObjectEntry[] filledArray = new ParcelableObjectSparseObjectEntry[2]; AndroidCollections.iterate(mArray).only().value("2").fillParcelable(filledArray); assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(Integer.valueOf(2), "2")); AndroidCollections.iterate(mArray).only().value("2").fillParcelable(filledArray, 1); assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(Integer.valueOf(2), "2")); assertThat(filledArray[0]).isEqualTo(filledArray[1]); try { AndroidCollections.iterate(mArray).fillParcelable(filledArray); fail(); } catch (final IndexOutOfBoundsException e) { } final Parcelable[] parcelables = new Parcelable[2]; AndroidCollections.iterate(mArray).only().to(1).fillParcelable(parcelables); assertThat(parcelables).containsExactly(filledArray); }
From source file:org.xbmc.kore.ui.AllCastActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_all_cast); ButterKnife.inject(this); // Set up the drawer. navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); if (savedInstanceState == null) { movie_tvshow_title = getIntent().getStringExtra(EXTRA_TITLE); castArrayList = getIntent().getParcelableArrayListExtra(EXTRA_CAST_LIST); } else {// w w w . jav a 2 s . c om movie_tvshow_title = savedInstanceState.getString(EXTRA_TITLE); castArrayList = savedInstanceState.getParcelableArrayList(EXTRA_CAST_LIST); } //LogUtils.LOGD(TAG, "Showing cast for: " + movie_tvshow_title); // Configure the grid castGridView.setEmptyView(emptyView); castGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Get the name from the tag Utils.openImdbForPerson(AllCastActivity.this, (String) ((ViewHolder) view.getTag()).castName); } }); CastArrayAdapter arrayAdapter = new CastArrayAdapter(this, castArrayList); castGridView.setAdapter(arrayAdapter); setupActionBar(movie_tvshow_title); }