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.github.mobile.gauges.ui.GaugePagerAdapter.java

@Override
public Fragment getItem(int position) {
    Bundle bundle = new Bundle();
    bundle.putSerializable(GAUGE, gauge);
    bundle.putString(GAUGE_ID, gauge.getId());
    switch (position) {
    case 0:/*from  ww w. j  a va 2  s .  c om*/
        ContentListFragment contentFragment = new ContentListFragment();
        contentFragment.setArguments(bundle);
        return contentFragment;
    case 1:
        TrafficListFragment trafficFragment = new TrafficListFragment();
        trafficFragment.setArguments(bundle);
        return trafficFragment;
    case 2:
        ReferrerListFragment referrerFragment = new ReferrerListFragment();
        referrerFragment.setArguments(bundle);
        return referrerFragment;
    default:
        return null;
    }
}

From source file:edu.htl3r.schoolplanner.gui.selectScreen.ViewTypeSpinnerOnItemSelectedListener.java

/**
 * Fires event but does not remember position.
 * @param viewTypeId ID of the ViewType, retrieved via {@link ViewType#getId()}.
 *//*ww  w.  ja va  2 s.c  om*/
public void fireEventByIdAndDontRemember(int viewTypeId) {
    ViewType item = null;
    for (ViewType viewType : list) {
        if (viewType.getId() == viewTypeId) {
            item = viewType;
            break;
        }
    }
    Assert.notNull(item, "ViewType for ID " + viewTypeId + " not found. Unable to continue.");

    Bundle bundle = new Bundle();
    bundle.putSerializable(BundleConstants.SELECTED_VIEW_TYPE, item);
    intent.putExtras(bundle);
    this.parent.startActivity(intent);
}

From source file:ch.dissem.apps.abit.SubscriptionDetailActivity.java

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

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*w w  w . j  a v a2s  .co  m*/
    // Show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // savedInstanceState is non-null when there is fragment state
    // saved from previous configurations of this activity
    // (e.g. when rotating the screen from portrait to landscape).
    // In this case, the fragment will automatically be re-added
    // to its container so we don't need to manually add it.
    // For more information, see the Fragments API guide at:
    //
    // http://developer.android.com/guide/components/fragments.html
    //
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putSerializable(SubscriptionDetailFragment.ARG_ITEM,
                getIntent().getSerializableExtra(SubscriptionDetailFragment.ARG_ITEM));
        SubscriptionDetailFragment fragment = new SubscriptionDetailFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction().add(R.id.content, fragment).commit();
    }
}

From source file:com.github.riotopsys.malforandroid2.activity.BaseDetailActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putSerializable("currentDetail", currentDetail);
    outState.putSerializable("manualBackStack", manualBackStack);

    super.onSaveInstanceState(outState);
}

From source file:com.indragie.cmput301as1.ExpenseClaimPagerAdapter.java

@Override
public Fragment getItem(int i) {
    Fragment fragment = null;/*from  w w w.jav  a 2s .c o  m*/
    switch (i) {
    case TAB_OWNED_CLAIMS:
        fragment = new ExpenseClaimOwnedListFragment();
        break;
    case TAB_REVIEWAL_CLAIMS:
        fragment = new ExpenseClaimReviewalListFragment();
    }
    Bundle args = new Bundle();
    args.putSerializable(ExpenseClaimListFragment.BUNDLE_USER, user);
    fragment.setArguments(args);
    return fragment;
}

From source file:ca.six.unittestapp.todo.tasks.TasksActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putSerializable(CURRENT_FILTERING_KEY, mTasksPresenter.getFiltering());

    super.onSaveInstanceState(outState);
}

From source file:com.akaashvani.akaashvani.springIndicator.PagerModelManager.java

public PagerModelManager addCommonFragment(Class<?> c, List<? extends Serializable> list) {
    try {/*  w w  w  .ja va 2 s.  c  o m*/
        for (int i = 0; i < list.size(); i++) {
            Fragment fragment = (Fragment) c.newInstance();
            Bundle bundle = new Bundle();
            bundle.putSerializable(DATA, list.get(i));
            fragment.setArguments(bundle);
            fragmentList.add(fragment);
        }
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return this;
}

From source file:com.medvid.andriy.housemanager.multiplemodel.viewpager.PagerManager.java

public PagerManager addFragments(List<ItemEntity> dataList) {
    try {/*  www .  j  a  v  a 2  s . c om*/
        for (ItemEntity itemEntity : dataList) {
            Fragment fragment = (Fragment) itemEntity.getModelView().newInstance();
            Bundle bundle = new Bundle();
            bundle.putSerializable(DATA, itemEntity);
            fragment.setArguments(bundle);
            fragmentList.add(fragment);
        }
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return this;
}

From source file:com.github.riotopsys.shoppinglist.adapter.ShoppingListCollectionAdapter.java

@Override
public Fragment getItem(int position) {
    Fragment fragment = new ShoppingListFragment();
    Bundle args = new Bundle();
    args.putSerializable(AppKeys.LIST_KEY, mItems.get(position).getGuid());
    fragment.setArguments(args);/*w  ww. j a v a 2  s  . com*/
    return fragment;
}

From source file:com.github.pockethub.android.ui.issue.IssueDashboardPagerAdapter.java

@Override
public Fragment getItem(final int position) {
    String filter;//  w ww.j  a v  a2 s.  c  o m
    switch (position) {
    case 0:
        filter = FILTER_SUBSCRIBED;
        break;
    case 1:
        filter = FILTER_ASSIGNED;
        break;
    case 2:
        filter = FILTER_CREATED;
        break;
    case 3:
        filter = FILTER_MENTIONED;
        break;
    default:
        return null;
    }
    final Map<String, Object> filterData = new HashMap<>();
    filterData.put(FIELD_FILTER, filter);
    filterData.put(FIELD_SORT, SORT_UPDATED);
    filterData.put(FIELD_DIRECTION, DIRECTION_DESCENDING);
    Bundle bundle = new Bundle();
    bundle.putSerializable(ARG_FILTER, (Serializable) filterData);
    DashboardIssueFragment fragment = new DashboardIssueFragment();
    fragment.setArguments(bundle);
    return fragment;
}