Example usage for android.os Bundle putSparseParcelableArray

List of usage examples for android.os Bundle putSparseParcelableArray

Introduction

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

Prototype

public void putSparseParcelableArray(@Nullable String key, @Nullable SparseArray<? extends Parcelable> value) 

Source Link

Document

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

Usage

From source file:android.support.v17.leanback.widget.ViewsStateBundle.java

/**
 * The on screen view is saved when policy is not {@link #SAVE_NO_CHILD}.
 *
 * @param bundle   Bundle where we save the on screen view state.  If null,
 *                 a new Bundle is created and returned.
 * @param view     The view to save.//  ww w.j a  v a  2  s  . c  o  m
 * @param id       Id of the view.
 */
public final Bundle saveOnScreenView(Bundle bundle, View view, int id) {
    if (mSavePolicy != SAVE_NO_CHILD) {
        String key = getSaveStatesKey(id);
        SparseArray<Parcelable> container = new SparseArray<Parcelable>();
        view.saveHierarchyState(container);
        if (bundle == null) {
            bundle = new Bundle();
        }
        bundle.putSparseParcelableArray(key, container);
    }
    return bundle;
}

From source file:com.quectel.presentationtest.PresentationTest.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    // Be sure to call the super class.
    super.onSaveInstanceState(outState);
    outState.putSparseParcelableArray(PRESENTATION_KEY, mSavedPresentationContents);
}

From source file:com.tomeokin.widget.jotablayout2.JoTabLayout.java

@Override
protected Parcelable onSaveInstanceState() {
    Bundle bundle = new Bundle();
    bundle.putParcelable("parentInstanceState", super.onSaveInstanceState());
    bundle.putInt("mCurrentTab", mCurrentTab);
    SparseArray<Parcelable> childInstanceState = new SparseArray<>();
    for (int i = 0; i < getChildCount(); i++) {
        getChildAt(i).saveHierarchyState(childInstanceState);
    }/*from   w  w w .ja  v a2s  .  c  o  m*/
    bundle.putSparseParcelableArray("childInstanceState", childInstanceState);
    return bundle;
}

From source file:android.support.design.internal.NavigationMenuPresenter.java

@Override
public Parcelable onSaveInstanceState() {
    if (Build.VERSION.SDK_INT >= 11) {
        // API 9-10 does not support ClassLoaderCreator, therefore things can crash if they're
        // loaded via different loaders. Rather than crash we just won't save state on those
        // platforms
        final Bundle state = new Bundle();
        if (mMenuView != null) {
            SparseArray<Parcelable> hierarchy = new SparseArray<>();
            mMenuView.saveHierarchyState(hierarchy);
            state.putSparseParcelableArray(STATE_HIERARCHY, hierarchy);
        }//from   www . ja va2 s  . com
        if (mAdapter != null) {
            state.putBundle(STATE_ADAPTER, mAdapter.createInstanceState());
        }
        if (mHeaderLayout != null) {
            SparseArray<Parcelable> header = new SparseArray<>();
            mHeaderLayout.saveHierarchyState(header);
            state.putSparseParcelableArray(STATE_HEADER, header);
        }
        return state;
    }
    return null;
}

From source file:com.ruesga.rview.drawer.DrawerNavigationMenuPresenter.java

@Override
public Parcelable onSaveInstanceState() {
    final Bundle state = new Bundle();
    if (mMenuView != null) {
        SparseArray<Parcelable> hierarchy = new SparseArray<>();
        mMenuView.saveHierarchyState(hierarchy);
        state.putSparseParcelableArray(STATE_HIERARCHY, hierarchy);
    }//from   ww w .jav  a2  s . c o m
    if (mAdapter != null) {
        state.putBundle(STATE_ADAPTER, mAdapter.createInstanceState());
    }
    if (mHeaderLayout != null) {
        SparseArray<Parcelable> header = new SparseArray<>();
        mHeaderLayout.saveHierarchyState(header);
        state.putSparseParcelableArray(STATE_HEADER, header);
    }
    return state;
}

From source file:org.totschnig.myexpenses.fragment.TransactionList.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putSparseParcelableArray(KEY_FILTER, mFilter.getCriteria());
}

From source file:org.ale.scanner.zotero.MainActivity.java

@Override
public void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    state.putStringArrayList(RC_PEND, mPendingItems);
    state.putIntegerArrayList(RC_PEND_STAT, mPendingStatus);
    state.putIntArray(RC_CHECKED, mItemAdapter.getChecked());
    state.putParcelable(RC_ACCESS, mAccountAccess);
    state.putInt(RC_UPLOADING, mUploadState);
    state.putSparseParcelableArray(RC_GROUPS, mGroups);
}

From source file:atownsend.swipeopenhelper.SwipeOpenItemTouchHelper.java

public void onSaveInstanceState(Bundle outState) {
    outState.putSparseParcelableArray(OPENED_STATES, openedPositions);
}

From source file:org.totschnig.myexpenses.activity.MyExpenses.java

@SuppressWarnings("incomplete-switch")
@Override// www .  j  av  a2  s  .  co m
public void contribFeatureCalled(ContribFeature feature, Serializable tag) {
    switch (feature) {
    case DISTRIBUTION:
        Account a = Account.getInstanceFromDb(mAccountId);
        recordUsage(feature);
        Intent i = new Intent(this, ManageCategories.class);
        i.setAction("myexpenses.intent.distribution");
        i.putExtra(KEY_ACCOUNTID, mAccountId);
        if (tag != null) {
            int year = (int) ((Long) tag / 1000);
            int groupingSecond = (int) ((Long) tag % 1000);
            i.putExtra("grouping", a != null ? a.grouping : Grouping.NONE);
            i.putExtra("groupingYear", year);
            i.putExtra("groupingSecond", groupingSecond);
        }
        startActivity(i);
        break;
    case SPLIT_TRANSACTION:
        if (tag != null) {
            startTaskExecution(TaskExecutionFragment.TASK_SPLIT, (Object[]) tag, null, 0);
        }
        break;
    case PRINT:
        TransactionList tl = getCurrentFragment();
        if (tl != null) {
            Bundle args = new Bundle();
            args.putSparseParcelableArray(TransactionList.KEY_FILTER, tl.getFilterCriteria());
            args.putLong(KEY_ROWID, mAccountId);
            getSupportFragmentManager().beginTransaction()
                    .add(TaskExecutionFragment.newInstancePrint(args), ProtectionDelegate.ASYNC_TAG)
                    .add(ProgressDialogFragment.newInstance(R.string.progress_dialog_printing),
                            ProtectionDelegate.PROGRESS_TAG)
                    .commit();
        }
        break;
    }
}

From source file:org.totschnig.myexpenses.activity.MyExpenses.java

@Override
public void onPositive(Bundle args) {
    switch (args.getInt(ConfirmationDialogFragment.KEY_COMMAND_POSITIVE)) {
    case R.id.START_EXPORT_COMMAND:
        mExportFormat = args.getString("format");
        args.putSparseParcelableArray(TransactionList.KEY_FILTER, getCurrentFragment().getFilterCriteria());
        getSupportFragmentManager().beginTransaction()
                .add(TaskExecutionFragment.newInstanceExport(args), ProtectionDelegate.ASYNC_TAG)
                .add(ProgressDialogFragment.newInstance(R.string.pref_category_title_export, 0,
                        ProgressDialog.STYLE_SPINNER, true), ProtectionDelegate.PROGRESS_TAG)
                .commit();//from w w w.j  a va  2s . com
        break;
    case R.id.BALANCE_COMMAND_DO:
        startTaskExecution(TaskExecutionFragment.TASK_BALANCE, new Long[] { args.getLong(KEY_ROWID) },
                args.getBoolean("deleteP"), 0);
        break;
    case R.id.DELETE_COMMAND_DO:
        //Confirmation dialog was shown without Checkbox, because it was called with only void transactions
        onPositive(args, false);
    }
}