Example usage for android.os Bundle putSerializable

List of usage examples for android.os Bundle putSerializable

Introduction

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

Prototype

@Override
public void putSerializable(@Nullable String key, @Nullable Serializable value) 

Source Link

Document

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

Usage

From source file:com.makotogo.mobile.datetimepickerexample.MainActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putSerializable(STATE_LOCAL_DATE_TIME, mLocalDateTime);
}

From source file:com.bukanir.android.activities.SearchActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    Log.d(TAG, "onSaveInstanceState");
    outState.putSerializable("search", movies);
}

From source file:ch.scythe.hsr.DayFragment.java

@Override
public void onSaveInstanceState(Bundle instanceToSave) {
    super.onSaveInstanceState(instanceToSave);
    instanceToSave.putSerializable(FRAGMENT_PARAMETER_DATA, week);
    instanceToSave.putSerializable(FRAGMENT_PARAMETER_WEEKDAY, weekDay);
}

From source file:com.example.mego.adas.videos.ui.VideosFragments.java

@Override
public void onCLick(Item item) {
    //get the current video
    WatchVideoFragment watchVideoFragment = new WatchVideoFragment();

    //set the video information to the next fragment
    Bundle args = new Bundle();
    args.putSerializable(Constants.KEY_ITEM_VIDEO, item);
    watchVideoFragment.setArguments(args);

    getActivity().getSupportFragmentManager().beginTransaction()
            .replace(R.id.fragment_container, watchVideoFragment).addToBackStack(null).commit();
}

From source file:org.alfresco.mobile.android.api.session.impl.RepositorySessionImpl.java

@Override
public void writeToParcel(Parcel dest, int arg1) {
    dest.writeString(baseUrl);/*from   w  w  w .ja v a  2s  .c  om*/
    dest.writeString(userIdentifier);
    dest.writeString(password);
    dest.writeParcelable(rootNode, PARCELABLE_WRITE_RETURN_VALUE);
    dest.writeSerializable(repositoryInfo);
    dest.writeSerializable(cmisSession);
    Bundle b = new Bundle();
    b.putSerializable("userParameters", (Serializable) userParameters);
    dest.writeBundle(b);
}

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

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    savedInstanceState.putSerializable(KEY_LAYOUT_MANAGER, mCurrentLayoutManagerType);

    super.onSaveInstanceState(savedInstanceState);

}

From source file:at.bitfire.davdroid.syncadapter.QueryServerDialogFragment.java

@Override
public void onLoadFinished(Loader<ServerInfo> loader, ServerInfo serverInfo) {
    if (serverInfo.getErrorMessage() != null)
        Toast.makeText(getActivity(), serverInfo.getErrorMessage(), Toast.LENGTH_LONG).show();
    else {/*from   w  w w  .j ava 2  s.  c  om*/
        SelectCollectionsFragment selectCollections = new SelectCollectionsFragment();
        Bundle arguments = new Bundle();
        arguments.putSerializable(SelectCollectionsFragment.KEY_SERVER_INFO, serverInfo);
        selectCollections.setArguments(arguments);

        getFragmentManager().beginTransaction().replace(R.id.fragment_container, selectCollections)
                .addToBackStack(null).commitAllowingStateLoss();
    }

    getDialog().dismiss();
}

From source file:carsharing.starter.automotive.iot.ibm.com.mobilestarterapp.Trips.Trips.java

private void getTrips() {
    final String url = API.tripBehavior + "?all=true";
    try {/*from   www  . j a v  a  2  s  .c  om*/
        final API.doRequest task = new API.doRequest(new API.doRequest.TaskListener() {
            @Override
            public void postExecute(JSONArray result) throws JSONException {
                result.remove(result.length() - 1);

                final ListView listView = (ListView) view.findViewById(R.id.listView);
                final ArrayList<TripData> tripsArray = new ArrayList<TripData>();
                for (int i = 0; i < result.length(); i++) {
                    final JSONObject data = result.getJSONObject(i);
                    if (data.has("start_time")) {
                        TripData tempTripData = new TripData(data);
                        tripsArray.add(tempTripData);
                    }
                }

                Collections.sort(tripsArray, new Comparator<TripData>() {
                    @Override
                    public int compare(TripData b1, TripData b2) {
                        final long delta = b2.start_time - b1.start_time;
                        if (delta > 0) {
                            return 1;
                        } else if (delta < 0) {
                            return -1;
                        } else {
                            return 0;
                        }
                    }
                });

                final FragmentActivity activity = getActivity();
                if (activity == null) {
                    return;
                }
                final TripsDataAdapter adapter = new TripsDataAdapter(activity.getApplicationContext(),
                        tripsArray);
                listView.setAdapter(adapter);

                final ArrayList<TripData> finalTripArray = tripsArray;
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
                        final Intent tripDetails = new Intent(view.getContext(), TripDetails.class);

                        final Bundle bundle = new Bundle();
                        bundle.putSerializable("tripData", finalTripArray.get(position));
                        tripDetails.putExtras(bundle);

                        startActivity(tripDetails);
                    }
                });

                final ActionBar supportActionBar = ((AppCompatActivity) activity).getSupportActionBar();
                switch (tripsArray.size()) {
                case 0:
                    supportActionBar.setTitle("You have no trips.");
                case 1:
                    supportActionBar.setTitle("You have 1 trip.");
                default:
                    supportActionBar.setTitle("You have " + tripsArray.size() + " trips.");
                }

                Log.i("Trip Data", result.toString());
            }
        });

        task.execute(url, "GET").get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}

From source file:com.hscardref.android.view.MainActivity.java

@Override
public void onAction(int id, int filterType) {

    NodeSelectorFragment nodeSelectorFragment = (NodeSelectorFragment) getSupportFragmentManager()
            .findFragmentById(R.id.nodeselector);

    if (nodeSelectorFragment != null) {
        if (R.id.btn_nodefilter_custom == id) {
            //IMPROVE: use English comment for open source community~~
            // Activitiy??Activity?
            Intent intent = new Intent(MainActivity.this, SearchActivity.class);
            CardFilterCollection cardFilter = nodeSelectorFragment.get_cardSearchCondition();

            // ??
            Bundle mBundle = new Bundle();
            mBundle.putSerializable("com.hscardref.generic.domain.CardCompositeFilter",
                    cardFilter == null ? null : cardFilter.get_cardCompositeFilter());
            // intent 
            intent.putExtra("CardCompositeFilter", mBundle);

            // ??startActivityForResult(intent,?)?startActivity(intent)
            // startActivityForResultstartActivity??
            // 1.??
            // 2.???
            startActivityForResult(intent, WIN_MODEL_REQUEST_CODE);
        } else {/*w ww.  j  a  v  a2  s .c om*/
            // Call a method in the NodeSelectorFragment to search card info
            nodeSelectorFragment.applyCardFilter(id, filterType, null);
        }
    }
}

From source file:com.mgfypy.imagelibrary.ui.activity.ImagePreviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_pre);

    androidImagePicker = AndroidImagePicker.getInstance();
    androidImagePicker.addOnImageSelectedChangeListener(this);

    mImageList = AndroidImagePicker.getInstance().getImageItemsOfCurrentImageSet();
    mShowItemPosition = getIntent().getIntExtra(AndroidImagePicker.KEY_PIC_SELECTED_POSITION, 0);

    mBtnOk = (TextView) findViewById(R.id.btn_ok);
    mBtnOk.setOnClickListener(this);

    mCbSelected = (CheckBox) findViewById(R.id.btn_check);
    mTitleCount = (TextView) findViewById(R.id.tv_title_count);
    mTitleCount.setText("1/" + mImageList.size());

    int selectedCount = AndroidImagePicker.getInstance().getSelectImageCount();

    onImageSelectChange(0, null, selectedCount, androidImagePicker.getSelectLimit());

    //back press//www  .j  a  va 2  s.  com
    findViewById(R.id.btn_backpress).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    mCbSelected.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (androidImagePicker.getSelectImageCount() > androidImagePicker.getSelectLimit()) {
                if (mCbSelected.isChecked()) {
                    //holder.cbSelected.setCanChecked(false);
                    mCbSelected.toggle();
                    String toast = getResources().getString(R.string.you_have_a_select_limit,
                            androidImagePicker.getSelectLimit());
                    Toast.makeText(ImagePreviewActivity.this, toast, Toast.LENGTH_SHORT).show();
                } else {
                    //
                }
            } else {
                //
            }
        }

    });

    mCbSelected.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mFragment.selectCurrent(isChecked);
        }
    });

    mFragment = new ImagePreviewFragment();
    Bundle data = new Bundle();
    data.putSerializable(AndroidImagePicker.KEY_PIC_PATH, (Serializable) mImageList);
    data.putInt(AndroidImagePicker.KEY_PIC_SELECTED_POSITION, mShowItemPosition);
    mFragment.setArguments(data);

    getSupportFragmentManager().beginTransaction().replace(R.id.container, mFragment).commit();

}