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.example.caique.educam.Activities.TimelineActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    // Save currently selected layout manager.
    savedInstanceState.putSerializable(KEY_LAYOUT_MANAGER, mCurrentLayoutManagerType);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.auth0.lock.util.LockFragmentBuilder.java

public Fragment loginWithSocial() {
    final SocialDBFragment fragment = new SocialDBFragment();
    if (lock.getConfiguration() != null) {
        Bundle bundle = new Bundle();
        bundle.putStringArrayList(SocialDBFragment.SOCIAL_FRAGMENT_STRATEGIES_ARGUMENT,
                activeSocialStrategies());
        bundle.putBoolean(BaseTitledFragment.AUTHENTICATION_USES_EMAIL_ARGUMENT, lock.shouldUseEmail());
        bundle.putSerializable(BaseTitledFragment.AUTHENTICATION_PARAMETER_ARGUMENT,
                new HashMap<>(lock.getAuthenticationParameters()));
        fragment.setArguments(bundle);//from w w  w.ja va2s .  c o  m
    }
    return fragment;
}

From source file:com.eugene.fithealthmaingit.MainActivity.java

/**
 * Get the Results from the Other Activities
 *
 * @param requestCode In this case either 1 = ACTIVITY_ONE_REQUEST  or 2 = ACTIVITY_TWO_REQUEST
 * @param resultCode  Determines whether the request was successful.
 * @param data        The being sent from other activities via Intent
 *//*from   w  ww .j  av a 2s . c  o  m*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTIVITY_ONE_REQUEST && resultCode == RESULT_OK) {
        if (data.hasExtra(ACTIVITY_ONE_RESULT)) {
            Date result = (Date) data.getExtras().get(ACTIVITY_ONE_RESULT);
            Fragment fragmentJournalMainHome = new FragmentJournalMainHome();
            Bundle bundle = new Bundle();
            bundle.putSerializable("DATE", result);
            fragmentJournalMainHome.setArguments(bundle);
            if (fragmentJournalMainHome != null && result != new Date())
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.container, fragmentJournalMainHome, "JOURNAL").commitAllowingStateLoss();
        }
    }
}

From source file:com.github.hobbe.android.openkarotz.fragment.RadioTabFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.v(LOG_TAG, "onSaveInstanceState: " + (group == null ? "no group" : group.getName()));
    outState.putSerializable(RadioTabFragment.KEY_GROUP, group);
}

From source file:com.ehelp.home.SuperAwesomeCardFragment.java

public void setLocation() {
    HomeAdapter que1 = new HomeAdapter(getActivity(), user_id, 1, eventCache);
    HomeAdapter que2 = new HomeAdapter(getActivity(), user_id, 2, eventCache);
    helpList = que1.getEvent();/* w w  w .j  av a2 s  .c om*/
    sosList = que2.getEvent();

    BitmapDescriptor bd = BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding);
    LatLngBounds.Builder builder = new LatLngBounds.Builder();

    //??
    for (Event help : helpList) {
        LatLng pt = new LatLng(help.getLatitude(), help.getLongitude());
        //          OverlayOptions o = new MarkerOptions().icon(bd).position(pt);
        MarkerOptions markerOptions = new MarkerOptions().icon(bd).position(pt);
        Marker mMarker1 = (Marker) (mBaiduMap.addOverlay(markerOptions));
        Bundle bundle = new Bundle();
        int type = 1;
        bundle.putSerializable("event", help);
        bundle.putInt("type", type);
        mMarker1.setExtraInfo(bundle);
    }

    //??sos?
    for (Event sos : sosList) {
        LatLng pt = new LatLng(sos.getLatitude(), sos.getLongitude());
        MarkerOptions markerOptions = new MarkerOptions().icon(bd).position(pt);
        builder.include(pt);
        Marker mMarker1 = (Marker) (mBaiduMap.addOverlay(markerOptions));
        Bundle bundle = new Bundle();
        int eventid = sos.getEventId();
        int type = 2;
        bundle.putInt("eventid", eventid);
        bundle.putInt("type", type);
        mMarker1.setExtraInfo(bundle);
    }
    mBaiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            // TODO Auto-generated method stub
            Toast.makeText(getActivity().getApplicationContext(), "Marker?", Toast.LENGTH_SHORT)
                    .show();
            int type = (int) marker.getExtraInfo().get("type");
            if (type == 2) {
                int eventid = (int) marker.getExtraInfo().get("eventid");
                Intent intent = new Intent(getActivity(), recievesos_map.class);
                intent.putExtra(EXTRA_MESSAGE, eventid);
                startActivity(intent);
            } else {
                Event event = (Event) marker.getExtraInfo().get("event");
                Intent intent = new Intent(getActivity(), recieve_help_ans_map.class);
                intent.putExtra(EXTRA_MESSAGE, event);
                startActivity(intent);
            }
            return false;
        }
    });
}

From source file:com.money.manager.ex.reports.CategoriesReportFragment.java

public void showChart() {
    CategoriesReportAdapter adapter = (CategoriesReportAdapter) getListAdapter();
    if (adapter == null)
        return;/*from   w  w w  . java 2s  . c  o  m*/
    Cursor cursor = adapter.getCursor();
    if (cursor == null)
        return;
    if (cursor.getCount() <= 0)
        return;

    ArrayList<ValuePieEntry> arrayList = new ArrayList<>();
    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());

    // Reset cursor to initial position.
    cursor.moveToPosition(-1);
    // process cursor
    while (cursor.moveToNext()) {
        ValuePieEntry item = new ValuePieEntry();
        String category = cursor.getString(cursor.getColumnIndex(ViewMobileData.Category));
        if (!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)))) {
            category += " : " + cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory));
        }
        // total
        double total = Math.abs(cursor.getDouble(cursor.getColumnIndex("TOTAL")));
        // check if category is empty
        if (TextUtils.isEmpty(category)) {
            category = getString(R.string.empty_category);
        }

        item.setText(category);
        item.setValue(total);
        item.setValueFormatted(currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(),
                MoneyFactory.fromDouble(total)));
        // add element
        arrayList.add(item);
    }

    Bundle args = new Bundle();
    args.putSerializable(PieChartFragment.KEY_CATEGORIES_VALUES, arrayList);
    //get fragment manager
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    if (fragmentManager != null) {
        PieChartFragment fragment;
        fragment = (PieChartFragment) fragmentManager
                .findFragmentByTag(IncomeVsExpensesChartFragment.class.getSimpleName());
        if (fragment == null) {
            fragment = new PieChartFragment();
        }
        fragment.setChartArguments(args);
        fragment.setDisplayHomeAsUpEnabled(true);

        if (fragment.isVisible())
            fragment.onResume();

        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        if (((CategoriesReportActivity) getActivity()).mIsDualPanel) {
            fragmentTransaction.replace(R.id.fragmentChart, fragment, PieChartFragment.class.getSimpleName());
        } else {
            fragmentTransaction.replace(R.id.fragmentMain, fragment, PieChartFragment.class.getSimpleName());
            fragmentTransaction.addToBackStack(null);
        }
        fragmentTransaction.commit();
    }
}

From source file:com.github.blalasaadri.sprinttopics.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment;//  w  w  w .  j  a v a2 s  . com
    Bundle args = new Bundle();

    switch (navigationListIds[position]) {
    case "topics":
        fragment = new TopicsFragment();
        break;
    case "new":
        fragment = new NurseryRhymeFragment();
        args.putSerializable(NURSERY_RHYME_ARGUMENT, NEW);
        break;
    case "old":
        fragment = new NurseryRhymeFragment();
        args.putSerializable(NURSERY_RHYME_ARGUMENT, OLD);
        break;
    case "licenses":
        fragment = new LicensesFragment();
        break;
    default:
        // How did we land here?
        fragment = new ErrorFragment();
        args.putInt(ERROR_MESSAGE_ARG, R.string.navigation_error);
    }
    fragment.setArguments(args);

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // update selected item and title, then close the drawer
    mDrawerList.setItemChecked(position, true);
    setTitle(navigationListItems[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    if (!CurrencyValue.isNullOrZero(_amount)) {
        outState.putSerializable(AMOUNT, _amount);
    }//  w  w w  . j a  v a2  s  .  c o m
    outState.putLong(RECEIVING_SINCE, _receivingSince);
    outState.putInt(SYNC_ERRORS, _syncErrors);
    outState.putSerializable(LAST_ADDRESS_BALANCE, _lastAddressBalance);
    super.onSaveInstanceState(outState);
}

From source file:com.zzisoo.toylibrary.fragment.ToyListViewFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    // Save currently selected layout manager.
    savedInstanceState.putSerializable(KEY_LAYOUT_MANAGER, mLayoutType);
    super.onSaveInstanceState(savedInstanceState);

    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putParcelable(BUNDLE_RECYCLER_LAYOUT,
            mToyListView.getLayoutManager().onSaveInstanceState());

}

From source file:com.android.contacts.list.MultiSelectContactsListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putSerializable(EXTRA_KEY_SELECTED_CONTACTS, getSelectedContactIds());
}