Back to project page dejalist.
The source code is released under:
Apache License
If you think the Android project dejalist listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.luboganev.dejalist.data.entities; // ww w . j av a 2 s . c o m import android.os.Parcel; import android.os.Parcelable; public class Category implements Parcelable { // The db columns public Long _id; public String name; public int color; // Variables for the parcable transient private static final int FLAG_SET_ID = 0x01; transient private static final int FLAG_SET_NAME = 0x02; public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) { // set the field set flags int fieldsSetFlags = 0; if(_id != null) fieldsSetFlags = fieldsSetFlags | FLAG_SET_ID; if(name != null) fieldsSetFlags = fieldsSetFlags | FLAG_SET_NAME; out.writeInt(fieldsSetFlags); if((fieldsSetFlags & FLAG_SET_ID) != 0) out.writeLong(_id); if((fieldsSetFlags & FLAG_SET_NAME) != 0) out.writeString(name); out.writeInt(color); } // 12414 in binary is: // Binary number: 1 1 0 0 0 0 0 1 1 1 1 1 1 0 // ------------------------------------------------------- // Bit positions: 13 12 11 10 9 8 7 6 5 4 3 2 1 0 // bitmask = TRADEABLE | SELLABLE | STORABLE | STORABLE_IN_WH | STORABLE_IN_LEGION_WH | BREAKABLE | BLACK_CLOUD_TRADERS | CAN_SPLIT; // if(bitmask & TRADEABLE != 0) { // // This item can be traded // } else { // // This item cannot be traded // } // bitmask |= TRADEABLE; // Sets the flag using bitwise OR // bitmask &= ~TRADEABLE; // Clears the flag using bitwise AND and NOT // bitmask ^= TRADEABLE; // Toggles the flag using bitwise XOR public static final Parcelable.Creator<Category> CREATOR = new Parcelable.Creator<Category>() { public Category createFromParcel(Parcel in) { return new Category(in); } public Category[] newArray(int size) { return new Category[size]; } }; private Category(Parcel in) { int fieldsSetFlags = in.readInt(); _id = ((fieldsSetFlags & FLAG_SET_ID) != 0) ? in.readLong() : null; name = ((fieldsSetFlags & FLAG_SET_NAME) != 0) ? in.readString() : null; color = in.readInt(); } public Category() { _id = null; name = null; color = -1; } }