Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

In this page you can find the example usage for android.os Bundle putParcelable.

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

Inserts a Parcelable value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:de.sourcestream.movieDB.controller.GenresList.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*from  w w  w .j av  a2 s .  c o  m*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null)
        outState.putBundle("save", save);
    else {
        Bundle send = new Bundle();
        send.putInt("backState", backState);
        if (backState == 1) {
            send.putParcelableArrayList("listData", genresList);
            // used to restore the scroll listener variables
            // Save scroll position
            if (listView != null) {
                Parcelable listState = listView.onSaveInstanceState();
                send.putParcelable("listViewScroll", listState);
            }

        }
        outState.putBundle("save", send);

    }
}

From source file:com.xorcode.andtweet.TweetListActivity.java

@Override
public boolean onSearchRequested() {
    Bundle appDataBundle = new Bundle();
    appDataBundle.putParcelable("content_uri", AndTweetDatabase.Tweets.SEARCH_URI);
    startSearch(null, false, appDataBundle, false);
    return true;/*from w ww  .  ja  v  a 2 s .  co  m*/
}

From source file:com.btmura.android.reddit.app.NavigationFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(STATE_REQUESTED_SUBREDDIT, requestedSubreddit);
    outState.putParcelable(STATE_REQUESTED_THING_BUNDLE, requestedThingBundle);

    outState.putString(STATE_ACCOUNT_NAME, accountName);
    outState.putInt(STATE_PLACE, place);
    outState.putString(STATE_SUBREDDIT, subreddit);
    outState.putBoolean(STATE_IS_RANDOM, isRandom);
    outState.putInt(STATE_FILTER, filter);
}

From source file:com.artemchep.horario.ui.fragments.master.LessonsFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mEmptyView = view.findViewById(R.id.empty);
    mWeekView = (WeekView) view.findViewById(R.id.week_view);
    mWeekView.setMultiSelectEnabled(mEditable);
    mWeekView.getFilterManager().registerListener(mObserver);

    if (savedInstanceState != null) {
        // Restore current selections; note: do it before registering
        // event listener -- all other components should have restored
        // their states.
        ArrayList<String> selections = savedInstanceState.getStringArrayList(SIS_SELECTIONS);
        if (selections != null)
            for (String key : selections) {
                mWeekView.getMultiSelector().add(key);
            }/*from  w w  w . ja v a  2  s .c o  m*/
    }

    mWeekView.setSubjects(mWatcherSubjects.getMap());
    mWeekView.setTeachers(mWatcherTeachers.getMap());
    mWeekView.setFilter(new Filter<Lesson>() {
        @Override
        public boolean isValid(@NonNull Lesson model) {
            return !mHiddenSet.contains(model.key);
        }
    });
    mWeekView.getMultiSelector().registerListener(this);
    mWeekView.setOnLessonClickListener(new WeekView.OnLessonClickListener() {
        @Override
        public void onLessonClick(@NonNull View view, @NonNull Lesson lesson) {
            Bundle args = new Bundle();
            args.putString(ModelFragment.EXTRA_TIMETABLE_PATH, mTimetablePath);
            args.putParcelable(MooDetailsFragment.EXTRA_MODEL, lesson);
            Fragment fragment = new LessonDetailsFragment();
            fragment.setArguments(args);

            MainActivity activity = (MainActivity) getActivity();
            activity.navigateDetailsFrame(fragment);
        }
    });
}

From source file:com.binomed.showtime.android.screen.results.tablet.CineShowTimeResultsTabletActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if ((getModelActivity().getNearResp() != null) || (fragmentMovie != null)) {
        outState.putBoolean(ParamIntent.BUNDLE_SAVE, true);
        // Save results state
        if (getModelActivity().getNearResp() != null) {
            outState.putParcelable(ParamIntent.NEAR_RESP, getModelActivity().getNearResp());
        } else {//from ww  w .  j  ava  2s .  c  o  m
            outState.putBoolean(ParamIntent.ACTIVITY_SEARCH_FORCE_REQUEST,
                    getModelActivity().isForceResearch());
        }
        if (getModelActivity().getLocalisation() != null) {
            outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LATITUDE,
                    getModelActivity().getLocalisation().getLatitude());
            outState.putDouble(ParamIntent.ACTIVITY_SEARCH_LONGITUDE,
                    getModelActivity().getLocalisation().getLongitude());
        }
        outState.putString(ParamIntent.ACTIVITY_SEARCH_THEATER_ID, getModelActivity().getFavTheaterId());
        outState.putInt(ParamIntent.ACTIVITY_SEARCH_DAY, getModelActivity().getDay());
        outState.putString(ParamIntent.ACTIVITY_SEARCH_CITY, getModelActivity().getCityName());
        outState.putString(ParamIntent.ACTIVITY_SEARCH_MOVIE_NAME, getModelActivity().getMovieName());
        outState.putIntegerArrayList(ParamIntent.ACTIVITY_SEARCH_GROUP_EXPAND,
                new ArrayList<Integer>(getModelActivity().getGroupExpanded()));

        // Save movie state
        if ((fragmentMovie != null) && (getModelActivity().getMovie() != null)) {
            outState.putParcelable(ParamIntent.MOVIE, getModelActivity().getMovie());
            outState.putParcelable(ParamIntent.THEATER, getModelActivity().getTheater());
            outState.putDouble(ParamIntent.ACTIVITY_MOVIE_LATITUDE,
                    (getModelActivity().getLocalisation() != null)
                            ? getModelActivity().getLocalisation().getLatitude()
                            : -1);
            outState.putDouble(ParamIntent.ACTIVITY_MOVIE_LONGITUDE,
                    (getModelActivity().getLocalisation() != null)
                            ? getModelActivity().getLocalisation().getLongitude()
                            : -1);
        }
    }
    super.onSaveInstanceState(outState);
}

From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java

void saveSettingsToBundle(Bundle outState) {
    super.saveSettingsToBundle(outState);

    outState.putInt(RADIUS_IN_METERS_BUNDLE_KEY, radiusInMeters);
    outState.putInt(RESULTS_LIMIT_BUNDLE_KEY, resultsLimit);
    outState.putString(SEARCH_TEXT_BUNDLE_KEY, searchText);
    outState.putParcelable(LOCATION_BUNDLE_KEY, location);
    outState.putBoolean(SHOW_SEARCH_BOX_BUNDLE_KEY, showSearchBox);
}

From source file:net.reichholf.dreamdroid.fragment.TimerEditFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putParcelable("timer", mTimer);
    outState.putParcelable("timerOld", mTimerOld);

    String[] selectedTags;/*from  w ww .  j  a v a  2  s  . co m*/
    if (mSelectedTags != null) {
        selectedTags = new String[mSelectedTags.size()];
        mSelectedTags.toArray(selectedTags);
    } else {
        selectedTags = new String[0];
    }
    outState.putStringArray("selectedTags", selectedTags);

    if (mProgress != null) {
        if (mProgress.isShowing()) {
            mProgress.dismiss();
        }
    }

    super.onSaveInstanceState(outState);
}

From source file:com.nextgis.firereporter.GetFiresService.java

protected void SendItem(FireItem item) {
    if (mUserNasaReceiver == null)
        return;//from  ww w . j  ava2 s.  co m
    Bundle b = new Bundle();
    b.putParcelable(ITEM, item);
    mUserNasaReceiver.send(SERVICE_DATA, b);
}

From source file:com.android.mail.ui.FolderListFragment.java

/**
 * Construct a bundle that represents the state of this fragment.
 *
 * @param parentFolder non-null for trees, the parent of this list
 * @param folderListUri the URI which contains all the list of folders
 * @param excludedFolderTypes if non-null, this indicates folders to exclude in lists.
 * @return Bundle containing parentFolder, divided list boolean and
 *         excluded folder types/*  ww w  .j a v  a 2 s  . co m*/
 */
private static Bundle getBundleFromArgs(Folder parentFolder, Uri folderListUri,
        final ArrayList<Integer> excludedFolderTypes) {
    final Bundle args = new Bundle(3);
    if (parentFolder != null) {
        args.putParcelable(ARG_PARENT_FOLDER, parentFolder);
    }
    if (folderListUri != null) {
        args.putString(ARG_FOLDER_LIST_URI, folderListUri.toString());
    }
    if (excludedFolderTypes != null) {
        args.putIntegerArrayList(ARG_EXCLUDED_FOLDER_TYPES, excludedFolderTypes);
    }
    return args;
}

From source file:fiskinfoo.no.sintef.fiskinfoo.Implementation.FiskInfoUtility.java

public Fragment createFragment(String tag, User user, String currentTag) {
    Bundle userBundle = new Bundle();
    userBundle.putParcelable("user", user);
    switch (tag) {
    case MyPageFragment.TAG:
        MyPageFragment myPageFragment = new MyPageFragment();
        myPageFragment.setArguments(userBundle);
        return myPageFragment;
    case MapFragment.TAG:
        MapFragment mapFragment = new MapFragment();
        mapFragment.setArguments(userBundle);
        return mapFragment;
    default://from  w  w  w. j  a  v a 2  s  .  c o m
        Log.d(currentTag, "Trying to create invalid fragment with TAG: " + tag);
    }
    return null;
}