Comments (4)
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.
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.
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.
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)
- runtime exception when readList
- NullPointerException: null HOT 4
- android studio mac 配置环境 HOT 1
- There is no Preferences -> Plugins -> Install plugin from disk....
- Parent class CREATOR is miss when i parcelable with it in child class HOT 6
- Object is not parceled correctly if it has a field of an array of its own type HOT 1
- Not work in Andriod_studio_window_x64_2.1.2
- Generate final parameters where possible? HOT 2
- Enum support HOT 3
- Code formating
- Generate code with parent object from library
- After installing, plugin not visible in AS 2.3 HOT 1
- [Question] Why the generated constructor is protected rather than private? HOT 1
- Error writing a list of Parcelable objects with subclasses
- How to parcel private List<T> data; HOT 1
- Request: support Kotlin too
- Android Studio 3.0 not work HOT 10
- when map is null. HOT 1
- Android Studio 4.1 support HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-parcelable-intellij-plugin.