Example usage for android.os Bundle getSerializable

List of usage examples for android.os Bundle getSerializable

Introduction

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

Prototype

@Override
@Nullable
public Serializable getSerializable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.foursquare.android.nativeoauth.TokenExchangeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setTheme(getThemeRes());//w  w w.  j a va  2  s.com
    setContentView(R.layout.loading);

    String clientId = getIntent().getStringExtra(INTENT_EXTRA_CLIENT_ID);
    String clientSecret = getIntent().getStringExtra(INTENT_EXTRA_CLIENT_SECRET);
    String authCode = getIntent().getStringExtra(INTENT_EXTRA_AUTH_CODE);

    if (savedInstanceState == null) {
        mTask = new TokenExchangeTask(this);
        mTask.execute(clientId, clientSecret, authCode);

    } else {
        mTask = (TokenExchangeTask) savedInstanceState.getSerializable(INTENT_EXTRA_TOKEN_EXCHANGE_TASK);
        mTask.setActivity(this);
    }
}

From source file:com.example.ali.topcoderandroid.ui.RecyclerViewFragment.java

@Nullable
@Override/*ww  w  . j  a va  2 s.c  om*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.recyclerview_fragment, container, false);
    rootView.setTag(TAG);

    /*init recyclerview */
    mRecyclerView = (ChallengeRecyclerView) rootView.findViewById(R.id.recyclerview);
    mRecyclerView.setEmptyView(rootView.findViewById(android.R.id.empty));
    mRecyclerView.setHasFixedSize(true);

    mLayoutManager = new LinearLayoutManager(context);

    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }

    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    /*init adapter*/
    ArrayList<ChallengeModel> emptyChallengeList = new ArrayList<>();

    challengeRecyclerViewAdapter = new ChallengeRecyclerViewAdapter(context, emptyChallengeList);
    mRecyclerView.setAdapter(challengeRecyclerViewAdapter);

    /*init pull to refresh*/
    swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setOnRefreshListener(this);

    /*   mLinearLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.linear_layout_rb);
       mLinearLayoutRadioButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER);
    }
       });
            
       mGridLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.grid_layout_rb);
       mGridLayoutRadioButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        setRecyclerViewLayoutManager(LayoutManagerType.GRID_LAYOUT_MANAGER);
    }
       });*/

    fetchChallenges(preferredChallengeType);

    return rootView;

}

From source file:pl.bcichecki.rms.client.android.activities.EditEventActivity.java

protected void setUpForm(Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            originalEvent = (Event) extras.getSerializable(EDIT_EVENT_EXTRA);
        } else {//from  www  .  j  a  v  a 2 s. co m
            originalEvent = null;
        }
    } else {
        originalEvent = (Event) savedInstanceState.getSerializable(EDIT_EVENT_EXTRA);
    }

    eventCopy = PojoUtils.createDefensiveCopy(originalEvent);

    if (eventCopy == null) {
        Log.d(TAG, "No event to edit passed. Acting as new event form");

        editEventForm = false;

        Date now = new Date();
        startDate = DateUtils.addHours(now, 1);
        endDate = DateUtils.addHours(now, 2);

        setTitle(R.string.activity_edit_event_title_new);

    } else {
        Log.d(TAG, "Event to edit passed. Acting as edit event form");

        titleText.setText(eventCopy.getTitle());
        descriptionText.setText(eventCopy.getDescription());

        if (eventCopy.getType().equals(EventType.MEETING)) {
            meetingRdbtn.setChecked(true);
        }
        if (eventCopy.getType().equals(EventType.INTERVIEW)) {
            interviewRdbtn.setChecked(true);
        }

        startDate = eventCopy.getStartDate();
        endDate = eventCopy.getEndDate();

        pickedParticipants.clear();
        pickedParticipants.addAll(eventCopy.getParticipants());
        pickedDevices.clear();
        pickedDevices.addAll(eventCopy.getDevices());

        updateParticipantsText();
        updateDevicesText();
    }
}

From source file:com.edicon.firebase.devs.firepix.PostsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setReverseLayout(true);
    linearLayoutManager.setStackFromEnd(true);
    mRecyclerView.setLayoutManager(linearLayoutManager);

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mRecyclerViewPosition = (int) savedInstanceState.getSerializable(KEY_LAYOUT_POSITION);
        mRecyclerView.scrollToPosition(mRecyclerViewPosition);
        // TODO: RecyclerView only restores position properly for some tabs.
    }/*from  w  w  w.  j a  v a 2 s.  c o  m*/

    switch (getArguments().getInt(KEY_TYPE)) {
    case TYPE_FEED:
        Log.d(TAG, "Restoring recycler view position (all): " + mRecyclerViewPosition);
        Query allPostsQuery = FirebaseUtil.getPostsRef();
        mAdapter = getFirebaseRecyclerAdapter(allPostsQuery);
        mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
            @Override
            public void onItemRangeInserted(int positionStart, int itemCount) {
                super.onItemRangeInserted(positionStart, itemCount);
                // TODO: Refresh feed view.
            }
        });
        break;
    case TYPE_HOME:
        Log.d(TAG, "Restoring recycler view position (following): " + mRecyclerViewPosition);

        FirebaseUtil.getCurrentUserRef().child("following").addChildEventListener(new ChildEventListener() {
            @Override
            public void onChildAdded(final DataSnapshot followedUserSnapshot, String s) {
                String followedUserId = followedUserSnapshot.getKey();
                String lastKey = "";
                if (followedUserSnapshot.getValue() instanceof String) {
                    lastKey = followedUserSnapshot.getValue().toString();
                }
                Log.d(TAG, "followed user id: " + followedUserId);
                Log.d(TAG, "last key: " + lastKey);
                FirebaseUtil.getPeopleRef().child(followedUserId).child("posts").orderByKey().startAt(lastKey)
                        .addChildEventListener(new ChildEventListener() {
                            @Override
                            public void onChildAdded(final DataSnapshot postSnapshot, String s) {
                                HashMap<String, Object> addedPost = new HashMap<String, Object>();
                                addedPost.put(postSnapshot.getKey(), true);
                                FirebaseUtil.getFeedRef().child(FirebaseUtil.getCurrentUserId())
                                        .updateChildren(addedPost)
                                        .addOnSuccessListener(new OnSuccessListener<Void>() {
                                            @Override
                                            public void onSuccess(Void aVoid) {
                                                FirebaseUtil.getCurrentUserRef().child("following")
                                                        .child(followedUserSnapshot.getKey())
                                                        .setValue(postSnapshot.getKey());
                                            }
                                        });
                            }

                            @Override
                            public void onChildChanged(DataSnapshot dataSnapshot, String s) {

                            }

                            @Override
                            public void onChildRemoved(DataSnapshot dataSnapshot) {

                            }

                            @Override
                            public void onChildMoved(DataSnapshot dataSnapshot, String s) {

                            }

                            @Override
                            public void onCancelled(DatabaseError databaseError) {

                            }
                        });
            }

            @Override
            public void onChildChanged(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onChildRemoved(DataSnapshot dataSnapshot) {

            }

            @Override
            public void onChildMoved(DataSnapshot dataSnapshot, String s) {

            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });

        FirebaseUtil.getFeedRef().child(FirebaseUtil.getCurrentUserId())
                .addListenerForSingleValueEvent(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                        final List<String> postPaths = new ArrayList<>();
                        for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                            Log.d(TAG, "adding post key: " + snapshot.getKey());
                            postPaths.add(snapshot.getKey());
                        }
                        mAdapter = new FirebasePostQueryAdapter(postPaths,
                                new FirebasePostQueryAdapter.OnSetupViewListener() {
                                    @Override
                                    public void onSetupView(PostViewHolder holder, Post post, int position,
                                            String postKey) {
                                        setupPost(holder, post, position, postKey);
                                    }
                                });
                    }

                    @Override
                    public void onCancelled(DatabaseError firebaseError) {

                    }
                });
        break;
    default:
        throw new RuntimeException("Illegal post fragment type specified.");
    }
    mRecyclerView.setAdapter(mAdapter);
}

From source file:de.grobox.transportr.trips.search.DirectionsFragment.java

@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);
    if (savedInstanceState != null && viewModel.getTrips().getValue() == null) {
        viewModel.setIsExpanded(savedInstanceState.getBoolean(EXPANDED, false));
        viewModel.setIsDeparture(savedInstanceState.getBoolean(DEPARTURE, true));
        viewModel.setFromLocation(from.getLocation());
        viewModel.setViaLocation(via.getLocation());
        viewModel.setToLocation(to.getLocation());
        viewModel.onTimeAndDateSet((Calendar) savedInstanceState.getSerializable(DATE));
    }//from  w  w w . ja v  a 2 s  . c o m
}

From source file:ca.ypg.pdavid.com.yp_dine.fragment.RecyclerViewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_recycler_view, container, false);
    rootView.setTag(TAG);/*w w w  .  j  a  v a  2 s.c o m*/

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);

    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    mLayoutManager = new LinearLayoutManager(getActivity());

    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    //      mAdapter = new CustomAdapter(mDataset);
    // Set CustomAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mAdapter);

    mLinearLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.linear_layout_rb);
    mLinearLayoutRadioButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerViewLayoutManager(LayoutManagerType.LINEAR_LAYOUT_MANAGER);
        }
    });

    mGridLayoutRadioButton = (RadioButton) rootView.findViewById(R.id.grid_layout_rb);
    mGridLayoutRadioButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRecyclerViewLayoutManager(LayoutManagerType.GRID_LAYOUT_MANAGER);
        }
    });

    return rootView;
}

From source file:de.grobox.liberario.fragments.DirectionsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        setType(savedInstanceState.getBoolean("type"));
        Serializable tmpProducts = savedInstanceState.getSerializable("products");
        if (tmpProducts instanceof EnumSet) {
            //noinspection unchecked
            products = (EnumSet<Product>) tmpProducts;
            onProductsChanged(products);
        }//  w w w  .j a va  2s  .  c  o  m
        // re-attach fragment listener
        Fragment fragment = getActivity().getSupportFragmentManager()
                .findFragmentByTag(ProductDialogFragment.TAG);
        if (fragment != null && fragment.getUserVisibleHint()) {
            ((ProductDialogFragment) fragment).setOnProductsChangedListener(this);
        }
    }
}

From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    Bundle extras = this.getIntent().getExtras();
    if (extras != null && extras.get("pi") != null) {
        LOGGER.debug("onCreate: get currentDevice out of intent.");
        currentDevice = (RaspberryDeviceBean) extras.get("pi");
    } else if (savedInstanceState.getSerializable("pi") != null) {
        LOGGER.debug("onCreate: get currentDevice out of savedInstanceState.");
        currentDevice = (RaspberryDeviceBean) savedInstanceState.getSerializable("pi");
    }/*from w  w  w . ja  v  a 2  s. c  o  m*/
    if (currentDevice != null) {
        LOGGER.debug("Setting activity title for device.");
        getSupportActionBar().setTitle(currentDevice.getName());
        LOGGER.debug("Initializing ListView");
        this.initListView(currentDevice);
    } else {
        LOGGER.debug("No current device! Setting no title");
    }

}

From source file:ch.teamuit.android.soundplusplus.LibraryPagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    Bundle in = (Bundle) state;
    mPendingArtistLimiter = (Limiter) in.getSerializable("limiter_artists");
    mPendingAlbumLimiter = (Limiter) in.getSerializable("limiter_albums");
    mPendingSongLimiter = (Limiter) in.getSerializable("limiter_songs");
    mPendingFileLimiter = (Limiter) in.getSerializable("limiter_files");
}

From source file:com.lozasolutions.spaces4all.fragments.ListPoi.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.list_poi_fragment, container, false);
    rootView.setTag(TAG);//from www .  j  av  a2 s .co  m

    // BEGIN_INCLUDE(initializeRecyclerView)
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);

    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    mLayoutManager = new LinearLayoutManager(getActivity());

    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    mAdapter = new PoiAdapter(mDataset);
    // Set PoiAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mAdapter);
    // END_INCLUDE(initializeRecyclerView)

    return rootView;
}