Example usage for android.os Parcel recycle

List of usage examples for android.os Parcel recycle

Introduction

In this page you can find the example usage for android.os Parcel recycle.

Prototype

public final void recycle() 

Source Link

Document

Put a Parcel object back into the pool.

Usage

From source file:com.scvngr.levelup.core.model.CreditCardTest.java

@SmallTest
public void testParcel() {
    final CreditCard card = CreditCardFixture.getFullModel(0);

    final Parcel parcel = Parcel.obtain();
    card.writeToParcel(parcel, 0);/*  w  w w . j av  a  2  s .  co  m*/
    parcel.setDataPosition(0);

    final CreditCard card2 = CreditCard.CREATOR.createFromParcel(parcel);
    parcel.recycle();
    assertEquals(card, card2);
}

From source file:com.scvngr.levelup.core.model.CreditCardTest.java

@SmallTest
public void testParcelWithMinimalModel() {
    final CreditCard card = CreditCardFixture.getMinimalModel(1);

    final Parcel parcel = Parcel.obtain();
    card.writeToParcel(parcel, 0);//from w w  w  . j  a  v a  2 s  .co m
    parcel.setDataPosition(0);

    final CreditCard card2 = CreditCard.CREATOR.createFromParcel(parcel);
    parcel.recycle();
    assertEquals(card, card2);
}

From source file:com.scvngr.levelup.core.model.LocationTest.java

@SmallTest
public void testParcel() throws JSONException {
    final JSONObject object = LocationFixture.getFullJsonObject();

    final Location location = new LocationJsonFactory().from(object);
    final Parcel parcel = Parcel.obtain();
    location.writeToParcel(parcel, 0);/*from  w  w w  .jav a2  s  .  c  o  m*/
    parcel.setDataPosition(0);

    final Location parceled = Location.CREATOR.createFromParcel(parcel);
    assertEquals(location, parceled);
    parcel.recycle();
}

From source file:com.scvngr.levelup.core.model.CauseAffiliationTest.java

@SmallTest
public void testParcel() {
    final CauseAffiliation causeAffiliation = CauseAffiliationFixture.getFullModel();

    final Parcel parcel = Parcel.obtain();
    causeAffiliation.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);//from   w ww  .  j  av  a  2  s. co m

    final CauseAffiliation causeAffiliation2 = CauseAffiliation.CREATOR.createFromParcel(parcel);
    parcel.recycle();
    assertEquals(causeAffiliation, causeAffiliation2);
}

From source file:com.scvngr.levelup.core.model.CauseAffiliationTest.java

@SmallTest
public void testParcel_nullId() {
    final CauseAffiliation causeAffiliation = CauseAffiliationFixture.getFullModel(null);

    final Parcel parcel = Parcel.obtain();
    causeAffiliation.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);/*w ww  . j av  a2  s.c o  m*/

    final CauseAffiliation causeAffiliation2 = CauseAffiliation.CREATOR.createFromParcel(parcel);
    parcel.recycle();
    assertEquals(causeAffiliation, causeAffiliation2);
}

From source file:org.droid2droid.internal.RemoteBinderProxy.java

@Override
public void dump(FileDescriptor fd, String[] args) throws RemoteException {
    Parcel data = Parcel.obtain();
    data.writeFileDescriptor(fd);// w  w  w.  j a  v a  2s .  com
    data.writeStringArray(args);
    try {
        transact(DUMP_TRANSACTION, data, null, 0);
    } finally {
        data.recycle();
    }
}

From source file:edu.umich.flowfence.common.ParceledPayload.java

public Object getValue(ClassLoader loader) {
    Parcel p = Parcel.obtain();
    try {/*from  w ww.  j a  v  a2 s.  c o  m*/
        p.unmarshall(data, 0, data.length);
        p.setDataPosition(0);
        return p.readValue(loader);
    } finally {
        p.recycle();
    }
}

From source file:org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter.java

public ArrayList<CertifyAction> getSelectedCertifyActions() {
    LongSparseArray<CertifyAction> actions = new LongSparseArray<>();
    for (int i = 0; i < mCheckStates.size(); i++) {
        if (mCheckStates.get(i)) {
            mCursor.moveToPosition(i);/*from  ww  w  . j  av a  2 s.  c om*/

            long keyId = mCursor.getLong(0);
            byte[] data = mCursor.getBlob(1);

            Parcel p = Parcel.obtain();
            p.unmarshall(data, 0, data.length);
            p.setDataPosition(0);
            ArrayList<String> uids = p.createStringArrayList();
            p.recycle();

            CertifyAction action = actions.get(keyId);
            if (actions.get(keyId) == null) {
                actions.put(keyId, new CertifyAction(keyId, uids, null));
            } else {
                action.mUserIds.addAll(uids);
            }
        }
    }

    ArrayList<CertifyAction> result = new ArrayList<>(actions.size());
    for (int i = 0; i < actions.size(); i++) {
        result.add(actions.valueAt(i));
    }
    return result;
}

From source file:com.scvngr.levelup.core.model.WebLinkTest.java

@SmallTest
public void testParcel_full() {
    final WebLink loyalty = WebLinkFixture.getFullModel(1);
    final Parcel parcel = Parcel.obtain();

    try {//from  ww w .j a  va  2 s. co m
        loyalty.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        final WebLink parceled = WebLink.CREATOR.createFromParcel(parcel);
        assertEquals(loyalty, parceled);
    } finally {
        parcel.recycle();
    }
}

From source file:com.scvngr.levelup.core.model.WebLinkTest.java

@SmallTest
public void testParcel_minimal() {
    final WebLink loyalty = WebLinkFixture.getMinimalModel(1);
    final Parcel parcel = Parcel.obtain();

    try {/*from w  w w  .j av a 2  s .  c  o m*/
        loyalty.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        final WebLink parceled = WebLink.CREATOR.createFromParcel(parcel);
        assertEquals(loyalty, parceled);
    } finally {
        parcel.recycle();
    }
}