Git Product home page Git Product logo

Comments (18)

johncarl81 avatar johncarl81 commented on August 10, 2024

Is the boolean[] field itself null or does it contain nulls?

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

It's not even a boolean[] field... the def is:

Boolean isFeatured;

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

Oh, I see... will fix tonight.

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

Now that I think about it.. I bet this is a problem for all Object version of primitives (Integer, Float, etc). We should probably have a null check for all of them.

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

Yeah.. I think I'm going to hit this problem quite a bit in these classes... lots of primitive wrappers..

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

this should do the trick: 73d8d68 Deployed under 0.2.8-SNAPSHOT. Let me know if it works for you.

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

Awesome! Thanks! I'll try it shortly

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

I think this fixed my problem... but is this generated code for an Integer correct?

        int int$$3 = parcel$$0 .readInt();
        java.lang.Long long$$0;
        if (int$$3 < 0) {
            long$$0 = null;
        } else {
            long$$0 = parcel$$0 .readLong();
        }
        listingEntity$$0 .listingId = long$$0;

That looks like I can't have negative values in an Integer field?

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

er.. sorry, Long

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

There are two variables in play here. The int value is there as a flag to determine if the Long is null or not.

        int int$$3 = parcel$$0 .readInt(); //null flag
        java.lang.Long long$$0; // eventual value
        if (int$$3 < 0) { // <- is the value null?
            long$$0 = null;
        } else { // nope...
            long$$0 = parcel$$0 .readLong();
        }
        listingEntity$$0 .listingId = long$$0;

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

Ahhh, duh, got it... thanks. Seems like everything is working great then!

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

I was thinking about defining a null constant so that this code is more readable:

        int int$$3 = parcel$$0 .readInt();
        java.lang.Long long$$0;
        if (int$$3 == IS_NULL) {
            long$$0 = null;
        } else {
            long$$0 = parcel$$0 .readLong();
        }
        listingEntity$$0 .listingId = long$$0;

I use this technique all over the place, especially in collections and arrays where -1 represents null, 0 represents empty and > 0 represents the size of the collection:

        int int$$18 = parcel$$12 .readInt();
        java.util.ArrayList<org.parceler.SubParcel> list$$4;
        if (int$$18 < 0) {
            list$$4 = null;
        } else {
            list$$4 = new java.util.ArrayList<org.parceler.SubParcel>();
            for (int int$$19 = 0; (int$$19 <int$$18); int$$19 ++) {
                list$$4 .add(...);
            }
        }
        converterTarget$$0 .parcelList = list$$4;

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

That certainly would have prevented my stupid question :)

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

Still hitting this issue in public void writeToParcel(android.os.Parcel parcel$$1, int flags):

parcel$$1 .writeBooleanArray(new boolean[] {listingEntity$$0 .isFeatured });

where isFeatured is a null Boolean

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

Robolectic's lack of Parcelable support is biting me... Looks like I missed
Boolean and Character. Will fix shortly.
On Mar 4, 2014 4:53 PM, "dbachelder" [email protected] wrote:

Still hitting this issue in public void writeToParcel(android.os.Parcel
parcel$$1, int flags):

parcel$$1 .writeBooleanArray(new boolean[] {listingEntity$$0 .isFeatured
});

where isFeatured is a null Boolean

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-36694495
.

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

try again with 0.2.8-SNAPSHOT

from parceler.

dbachelder avatar dbachelder commented on August 10, 2024

looks good, thanks

from parceler.

johncarl81 avatar johncarl81 commented on August 10, 2024

Finally... thanks for sticking with it.

from parceler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.