Code Monkey home page Code Monkey logo

Comments (4)

DariusL avatar DariusL commented on July 18, 2024

That's how "not supported" is implemented. You can generate the entire class and change the parts that read and write your array. What other solution would you recommend?

from android-parcelable-intellij-plugin.

rekire avatar rekire commented on July 18, 2024

I would prefer if the generated code would just work^^

Here is the generated code from my own library:

// read from the parcable
int[] shortArrayAsIntArray = in.createIntArray();
shortArray = new short[shortArrayAsIntArray.length];
for(int i = 0; i < shortArrayAsIntArray.length; i++) {
    shortArray[i] = (short)shortArrayAsIntArray[i];
}

// write to the parcable
int[] shortArrayAsIntArray = new int[shortArray.length];
for(int i = 0; i < shortArrayAsIntArray.length; i++) {
    shortArrayAsIntArray[i] = (int)shortArray[i];
}
dest.writeIntArray(shortArrayAsIntArray);

Currently will be this code generated which won't compile:

// write to the parcable
dest.writeParcelable(this.shortArray, flags);
// read from the parcable
this.shortArray = in.readParcelable(short[].class.getClassLoader());

from android-parcelable-intellij-plugin.

DariusL avatar DariusL commented on July 18, 2024

I agree that the feature is useful, I'm just saying that the best failure is an early failure. Your code would work, I don't know if this plugin can generate a utils class with methods for conversion, though. So you'll have to keep this code in every task.

Other than that, you could probably pack two shorts into an int for memory efficiency, but you'll need benchmarks to check if that helps.

from android-parcelable-intellij-plugin.

rekire avatar rekire commented on July 18, 2024

If you talk about memory efficiency keep in mind that every boolean is stored as byte or even as integer. They can been packed much more efficiency.

from android-parcelable-intellij-plugin.

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.