Filtering by dot notation and only returning specific results - android

Customer class
#RealmClass
public class Customer extends RealmObject {
#PrimaryKey private int id;
private int customerSerial;
#Required private String customerName;
private RealmList<Invoice> invoices = new RealmList<>();
public Customer() {}
public Customer(int id, int customerSerial, String customerName) {
this.id = id;
this.customerSerial = customerSerial;
this.customerName = customerName;
}
public int getId() { return id; }
public void setId(int id) { this.id = id; }
public int getCustomerSerial() { return customerSerial; }
public void setCustomerSerial(int customerSerial) { this.customerSerial = customerSerial; }
public String getCustomerName() { return customerName; }
public void setCustomerName(String customerName) { this.customerName = customerName; }
public List<Invoice> getInvoices() { return invoices; }
public void setInvoices(RealmList<Invoice> invoices) { this.invoices = invoices; }
}
Invoice class
#RealmClass
public class Invoice extends RealmObject {
#PrimaryKey private int invoiceNumber;
private Date invoiceDate;
private String invoiceTime;
private int debtorSerNo;
private int deliveryStatus;
private long invoiceSort;
private int driverId;
private String debtorName;
private boolean codCustomer;
private boolean outstandingCOD;
private double outstandingCODAmount;
private String deliveryNotes;
private int lineCount;
public Invoice() {}
public Invoice(TtInvoice invoice) {
this.invoiceNumber = invoice.getInvoiceNumber();
this.invoiceDate = invoice.getInvoiceDate();
this.invoiceTime = invoice.getInvoiceTime();
this.debtorSerNo = invoice.getDebtorSerNo();
this.deliveryStatus = 0;
this.debtorName = invoice.getDebtorName();
this.codCustomer = invoice.isCodCustomer();
this.outstandingCOD = invoice.isOutstandingCOD();
this.outstandingCODAmount = invoice.getOutstandingCODAmount();
this.deliveryNotes = invoice.getDeliveryNotes();
this.lineCount = invoice.getLineCount();
}
public int getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(int invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public LocalDateTime getInvoiceDateTime() {
LocalTime time = LocalTime.parse(invoiceTime);
LocalDate date = invoiceDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return date.atTime(time);
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getInvoiceTime() {
return invoiceTime;
}
public void setInvoiceTime(String invoiceTime) {
this.invoiceTime = invoiceTime;
}
public int getDebtorSerNo() {
return debtorSerNo;
}
public void setDebtorSerNo(int debtorSerNo) {
this.debtorSerNo = debtorSerNo;
}
public String getDebtorName() {
return debtorName;
}
public void setDebtorName(String debtorName) {
this.debtorName = debtorName;
}
public boolean isCodCustomer() {
return codCustomer;
}
public void setCodCustomer(boolean codCustomer) {
this.codCustomer = codCustomer;
}
public boolean isOutstandingCOD() {
return outstandingCOD;
}
public void setOutstandingCOD(boolean outstandingCOD) {
this.outstandingCOD = outstandingCOD;
}
public double getOutstandingCODAmount() {
return outstandingCODAmount;
}
public void setOutstandingCODAmount(double outstandingCODAmount) {
this.outstandingCODAmount = outstandingCODAmount;
}
public String getDeliveryNotes() {
return deliveryNotes;
}
public void setDeliveryNotes(String deliveryNotes) {
this.deliveryNotes = deliveryNotes;
}
public int getLineCount() {
return lineCount;
}
public void setLineCount(int lineCount) {
this.lineCount = lineCount;
}
public int getDeliveryStatus() {
return deliveryStatus;
}
public void setDeliveryStatus(int deliveryStatus) {
this.deliveryStatus = deliveryStatus;
}
public long getInvoiceSort() {
return invoiceSort;
}
public void setInvoiceSort(long invoiceSort) {
this.invoiceSort = invoiceSort;
}
public int getDriverId() {
return driverId;
}
public void setDriverId(int driverId) {
this.driverId = driverId;
}
}
TtInvoice class
TtInvoice is created from a remote JSON object when the barcode on an invoice is scanned, have added a constructor just for testing purposes.
public class TtInvoice implements Serializable {
#JsonProperty("Invoice_Number")
private int invoiceNumber;
#JsonProperty("Invoice_Date")
private Date invoiceDate;
#JsonProperty("Invoice_Time")
private String invoiceTime;
#JsonProperty("Debtor_Ser_No")
private int debtorSerNo;
#JsonProperty("Debtor_Name")
private String debtorName;
#JsonProperty("COD_Customer")
private boolean codCustomer;
#JsonProperty("Outstanding_COD")
private boolean outstandingCOD;
#JsonProperty("Outstanding_COD_Amount")
private double outstandingCODAmount;
#JsonProperty("Delivery_Notes")
private String deliveryNotes;
#JsonProperty("Line_Count")
private int lineCount;
public TtInvoice(int invoiceNumber, Date invoiceDate, String invoiceTime, int debtorSerNo, int deliveryStatus) {
this.invoiceNumber = invoiceNumber;
this.invoiceDate = invoiceDate;
this.invoiceTime = invoiceTime;
this.debtorSerNo = debtorSerNo;
this.deliveryStatus = deliveryStatus;
}
public int getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(int invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getInvoiceTime() {
return invoiceTime;
}
public void setInvoiceTime(String invoiceTime) {
this.invoiceTime = invoiceTime;
}
public LocalDateTime getInvoiceDateTime() {
LocalTime time = LocalTime.parse(invoiceTime);
LocalDate date = invoiceDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return date.atTime(time);
}
public int getDebtorSerNo() {
return debtorSerNo;
}
public void setDebtorSerNo(int debtorSerNo) {
this.debtorSerNo = debtorSerNo;
}
public String getDebtorName() {
return debtorName;
}
public void setDebtorName(String debtorName) {
this.debtorName = debtorName;
}
public String getDeliveryNotes() {
return deliveryNotes;
}
public void setDeliveryNotes(String deliveryNotes) {
this.deliveryNotes = deliveryNotes;
}
public boolean isCodCustomer() {
return codCustomer;
}
public void setCodCustomer(boolean codCustomer) {
this.codCustomer = codCustomer;
}
public boolean isOutstandingCOD() {
return outstandingCOD;
}
public void setOutstandingCOD(boolean outstandingCOD) {
this.outstandingCOD = outstandingCOD;
}
public double getOutstandingCODAmount() {
return outstandingCODAmount;
}
public void setOutstandingCODAmount(double outstandingCODAmount) {
this.outstandingCODAmount = outstandingCODAmount;
}
public int getLineCount() {
return lineCount;
}
public void setLineCount(int lineCount) {
this.lineCount = lineCount;
}
}
In my fragment, if I do
private RealmChangeListener<RealmResults<Customer>> customerRealmChangeListener;
RealmResults<Customer> customerRealmResults;
Realm realm = Realm.getDefaultInstance();
customerRealmChangeListener = customers -> {
customers.forEach(customer -> {
Log.w("CUSTOMERS", customer.getCustomerName());
});
};
customerRealmResults = realm.where(Customer.class).equalTo("invoices.deliveryStatus", 0).findAllAsync();
customerRealmResults.addChangeListener(customerRealmChangeListener);
realm.executeTransactionAsync(transactionRealm -> {
Customer newCustomer = new Customer(1, 1, "Test Customer 1");
Invoice newInvoice1 = new Invoice(new TtInvoice(1234, 20/02/2023, "10:07:00", 1, 0));
Invoice newInvoice2 = new Invoice(new TtInvoice(2468, 20/02/2023, "10:08:00", 1, 1));
newCustomer.getInvoices().add(newInvoice1);
newCustomer.getInvoices().add(newInvoice2);
transactionRealm.insert(newCustomer);
});
No issues with the adding, the problem I am having is the 'findAllAsync', it returns both invoices instead of only the 1.
I get the customer back as I would expect, but a call to 'customer.getInvoices()' returns 2 invoices instead of just 1.
I feel like what I am trying to do is super simple and I'm just not seeing the problem, have been trying to figure this out for a couple of days now to no avail.
If I set a breakpoint on the findAllAsync() call and run my own 'findAll()' using the same query, it has the same issue.
Maybe it is how I am adding new invoices, not 100% sure on that one though.
Otherwise I am liking Realm a hell of a lot better than Room.

Related

Realm in android

I want to use two class for database.
here is my source.
public class UserInfo extends RealmObject {
private String user_email;
private String nick_name;
private String expected_date;
private boolean initial_autho;
private int resultDay;
public int getResultDay() {
return resultDay;
}
public void setResultDay(int resultDay) {
this.resultDay = resultDay;
}
public String getUser_email() {
return user_email;
}
public void setUser_email(String user_email) {
this.user_email = user_email;
}
public String getNick_name() {
return nick_name;
}
public void setNick_name(String nick_name) {
this.nick_name = nick_name;
}
public String getExpected_date() {
return expected_date;
}
public void setExpected_date(String expected_date) {
this.expected_date = expected_date;
}
public boolean getInitial_autho() {
return initial_autho;
}
public void setInitial_autho(boolean initial_autho) {
this.initial_autho = initial_autho;
}
}
public class Calendar extends Realmobject {
private long millis;
private String note; // 노트
private String mail; // who
private int image; // image resource
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public long getTime() {
return millis;
}
public String getNote() {
return note;
}
public int getImage() {
return image;
}
public void setDate(long time) {
this.millis = time;
}
public void setNote(String note) {
this.note = note;
}
public void setImage(int image) {
this.image = image;
}
}
How do I use these things in Activity?
I don't know exactly and I much appreciate if you guys could tell about that more specifically as much as you can.

Not able to access getter method of POJO inside OnNext() in rxretrofit

I am trying to access getter property of the pojo received in the response, but there is no such option.so is there any other way, I can do that?
The code for that call is as below:
results.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<GenericResponse<List<FoodTruck>>>() {
#Override
public void onCompleted() {
Toast.makeText(getActivity(), "completed", Toast.LENGTH_SHORT).show();
unsubscribe();
}
#Override
public void onError(Throwable e) {
Toast.makeText(getActivity(), "error", Toast.LENGTH_SHORT).show();
}
#Override
public void onNext(GenericResponse<List<FoodTruck>> response) {
Toast.makeText(getActivity(), response.toString(), Toast.LENGTH_SHORT).show();
}
});
GenericResponse.java
public class GenericResponse<T> {
#JsonProperty("status")
private String status;
#JsonProperty("message")
private String message;
#JsonProperty("data")
private T data;
}
FoodTruck.java
#JsonInclude(JsonInclude.Include.NON_NULL)
public class FoodTruck implements Parcelable {
#JsonProperty("_id")
private String foodTruckId;
#JsonProperty("foodtruck_name")
private String foodTruckName;
#JsonProperty("foodtruck_location")
private String foodTruckLocation;
#JsonProperty("foodtruck_tag")
private String foodTruckTag;
#JsonProperty("foodtruck_timing")
private String foodTruckTiming;
#JsonProperty("foodtruck_cusine")
private String foodTruckCusine;
#JsonProperty("foodtruck_img")
private String foodTruckImg;
#JsonProperty("foodtruck_logo")
private String foodTruckLogo;
#JsonProperty("foodtruck_total_votes")
private int foodTruckTotalVotes;
#JsonProperty("foodtruck_rating")
private double foodTruckRating;
#JsonProperty("item_list")
private List<FoodTruckItem> foodTruckItemList;
public String getFoodTruckId() {
return foodTruckId;
}
public String getFoodTruckName() {
return foodTruckName;
}
public String getFoodTruckLocation() {
return foodTruckLocation;
}
public String getFoodTruckTag() {
return foodTruckTag;
}
public String getFoodTruckTiming() {
return foodTruckTiming;
}
public String getFoodTruckCusine() {
return foodTruckCusine;
}
public String getFoodTruckImg() {
return foodTruckImg;
}
public String getFoodTruckLogo() {
return foodTruckLogo;
}
public int getFoodTruckTotalVotes() {
return foodTruckTotalVotes;
}
public double getFoodTruckRating() {
return foodTruckRating;
}
public List<FoodTruckItem> getFoodTruckItemList() {
return foodTruckItemList;
}
public void setFoodTruckId(String foodTruckId) {
this.foodTruckId = foodTruckId;
}
public void setFoodTruckName(String foodTruckName) {
this.foodTruckName = foodTruckName;
}
public void setFoodTruckLocation(String foodTruckLocation) {
this.foodTruckLocation = foodTruckLocation;
}
public void setFoodTruckTag(String foodTruckTag) {
this.foodTruckTag = foodTruckTag;
}
public void setFoodTruckTiming(String foodTruckTiming) {
this.foodTruckTiming = foodTruckTiming;
}
public void setFoodTruckCusine(String foodTruckCusine) {
this.foodTruckCusine = foodTruckCusine;
}
public void setFoodTruckImg(String foodTruckImg) {
this.foodTruckImg = foodTruckImg;
}
public void setFoodTruckLogo(String foodTruckLogo) {
this.foodTruckLogo = foodTruckLogo;
}
public void setFoodTruckTotalVotes(int foodTruckTotalVotes) {
this.foodTruckTotalVotes = foodTruckTotalVotes;
}
public void setFoodTruckRating(double foodTruckRating) {
this.foodTruckRating = foodTruckRating;
}
public void setFoodTruckItemList(List<FoodTruckItem> foodTruckItemList) {
this.foodTruckItemList = foodTruckItemList;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.foodTruckId);
dest.writeString(this.foodTruckName);
dest.writeString(this.foodTruckLocation);
dest.writeString(this.foodTruckTag);
dest.writeString(this.foodTruckTiming);
dest.writeString(this.foodTruckCusine);
dest.writeString(this.foodTruckImg);
dest.writeString(this.foodTruckLogo);
dest.writeInt(this.foodTruckTotalVotes);
dest.writeDouble(this.foodTruckRating);
dest.writeTypedList(this.foodTruckItemList);
}
public FoodTruck() {
}
protected FoodTruck(Parcel in) {
this.foodTruckId = in.readString();
this.foodTruckName = in.readString();
this.foodTruckLocation = in.readString();
this.foodTruckTag = in.readString();
this.foodTruckTiming = in.readString();
this.foodTruckCusine = in.readString();
this.foodTruckImg = in.readString();
this.foodTruckLogo = in.readString();
this.foodTruckTotalVotes = in.readInt();
this.foodTruckRating = in.readDouble();
this.foodTruckItemList = in.createTypedArrayList(FoodTruckItem.CREATOR);
}
public static final Parcelable.Creator<FoodTruck> CREATOR = new Parcelable.Creator<FoodTruck>() {
#Override
public FoodTruck createFromParcel(Parcel source) {
return new FoodTruck(source);
}
#Override
public FoodTruck[] newArray(int size) {
return new FoodTruck[size];
}
};
}
FoodTruckItem.java
#JsonInclude(JsonInclude.Include.NON_NULL)
public class FoodTruckItem implements Parcelable {
#JsonProperty("_id")
private String itemId;
#JsonProperty("no_of_times_ordered")
private int noOfTimesOrdered;
#JsonProperty("item_name")
private String itemName;
#JsonProperty("item_tag")
private String itemTag;
#JsonProperty("item_category")
private String itemCategory;
#JsonProperty("item_stock")
private int itemStock;
#JsonProperty("item_price")
private double itemPrice;
#JsonProperty("item_img")
private String itemImg;
#JsonProperty("no_of_likes")
private int noOfLikes;
#JsonProperty("item_quantity_ordered")
private int itemQuantityOrdered;
#JsonProperty("item_illustrations")
private List<String> itemIllustration;
public String getItemId() {
return itemId;
}
public int getNoOfTimesOrdered() {
return noOfTimesOrdered;
}
public String getItemName() {
return itemName;
}
public String getItemTag() {
return itemTag;
}
public String getItemCategory() {
return itemCategory;
}
public int getItemStock() {
return itemStock;
}
public double getItemPrice() {
return itemPrice;
}
public String getItemImg() {
return itemImg;
}
public int getNoOfLikes() {
return noOfLikes;
}
public int getItemQuantityOrdered() {
return itemQuantityOrdered;
}
public List<String> getItemIllustration() {
return itemIllustration;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public void setNoOfTimesOrdered(int noOfTimesOrdered) {
this.noOfTimesOrdered = noOfTimesOrdered;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public void setItemTag(String itemTag) {
this.itemTag = itemTag;
}
public void setItemCategory(String itemCategory) {
this.itemCategory = itemCategory;
}
public void setItemStock(int itemStock) {
this.itemStock = itemStock;
}
public void setItemPrice(double itemPrice) {
this.itemPrice = itemPrice;
}
public void setItemImg(String itemImg) {
this.itemImg = itemImg;
}
public void setNoOfLikes(int noOfLikes) {
this.noOfLikes = noOfLikes;
}
public void setItemQuantityOrdered(int itemQuantityOrdered) {
this.itemQuantityOrdered = itemQuantityOrdered;
}
public void setItemIllustration(List<String> itemIllustration) {
this.itemIllustration = itemIllustration;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.itemId);
dest.writeInt(this.noOfTimesOrdered);
dest.writeString(this.itemName);
dest.writeString(this.itemTag);
dest.writeString(this.itemCategory);
dest.writeInt(this.itemStock);
dest.writeDouble(this.itemPrice);
dest.writeString(this.itemImg);
dest.writeInt(this.noOfLikes);
dest.writeInt(this.itemQuantityOrdered);
dest.writeStringList(this.itemIllustration);
}
public FoodTruckItem() {
}
protected FoodTruckItem(Parcel in) {
this.itemId = in.readString();
this.noOfTimesOrdered = in.readInt();
this.itemName = in.readString();
this.itemTag = in.readString();
this.itemCategory = in.readString();
this.itemStock = in.readInt();
this.itemPrice = in.readDouble();
this.itemImg = in.readString();
this.noOfLikes = in.readInt();
this.itemQuantityOrdered = in.readInt();
this.itemIllustration = in.createStringArrayList();
}
public static final Parcelable.Creator<FoodTruckItem> CREATOR = new Parcelable.Creator<FoodTruckItem>() {
#Override
public FoodTruckItem createFromParcel(Parcel source) {
return new FoodTruckItem(source);
}
#Override
public FoodTruckItem[] newArray(int size) {
return new FoodTruckItem[size];
}
};
}
Now Basically I want to acess someting like response.getData().... But there is no such option.
Possibly data not accessible, because it is private. Try to crete getter method.
public class GenericResponse<T> {
#JsonProperty("status")
private String status;
#JsonProperty("message")
private String message;
#JsonProperty("data")
private T data;
public T getData() {
return data;
}
}

Android Json parsing with GSON?

I am quite familiar with Json parsing with Gson. I have done Json parsing using Gson but recently i have multiple json objects with response, i am getting little bit stuck with parsing, here is my code,can anyone help me to solve my problem,that where i am doing wrong.
Thanks in advance
Here is my json response :-
Json response
Here is my POGO class of parsing :-
Style Profile.java
public class StyleProfile implements Parcelable {
#SerializedName("user_name")
#Expose
private String user_name;
#SerializedName("user_picture")
#Expose
private String user_picture;
#SerializedName("user_attr")
#Expose
private UserAttrEntity user_attr;
#SerializedName("user_attributes")
#Expose
private UserAttributes userAttributes;
#SerializedName("style_attr")
#Expose
private StyleAttr style_attr;
private StyleAttrEntity style_attrEntity;
private UserAttributesEntity user_attributes;
private String user_style;
#SerializedName("user_background_image")
#Expose
private String userBackgroundImage;
#SerializedName("user_style_message")
#Expose
private String userStyleMessage;
private String user_style_message;
private List<String> style_message;
public StyleProfile() {
}
protected StyleProfile(Parcel in)
{
user_name = in.readString();
user_picture = in.readString();
user_style = in.readString();
// style_message = in.readString();
}
public static final Creator<StyleProfile> CREATOR = new Creator<StyleProfile>() {
#Override
public StyleProfile createFromParcel(Parcel in) {
return new StyleProfile(in);
}
#Override
public StyleProfile[] newArray(int size) {
return new StyleProfile[size];
}
};
public StyleAttr getStyle_attr() {
return style_attr;
}
public void setStyle_attr(StyleAttr style_attr) {
this.style_attr = style_attr;
}
public String getName() {
return user_name;
}
public void setName(String name) {
this.user_name = name;
}
public String getImage() {
return user_picture;
}
public void setImage(String image) {
this.user_picture = image;
}
public UserAttrEntity getUser_attr() {
return user_attr;
}
public void setUser_attributes(UserAttributesEntity user_attributes) {
this.user_attributes = user_attributes;
}
public void setUser_style(String user_style) {
this.user_style = user_style;
}
public String getUser_style() {
return user_style;
}
public List<String> getStyle_message() {
return style_message;
}
public void setStyle_message(List<String> style_message) {
this.style_message = style_message;
}
public String getStyleMessageAsString() {
return TextUtils.join(". ", style_message);
}
public void setUser_style_message(String user_style_message) {
this.user_style_message = user_style_message;
}
public String getUser_style_message() {
return user_style_message;
}
public UserAttributesEntity getUser_attributes() {
return user_attributes;
}
public void setUser_attr(UserAttrEntity user_attr) {
this.user_attr = user_attr;
}
public UserAttributes getUserAttr() {
return userAttributes;
}
public void setUserAttr(UserAttributes userAttr) {
this.userAttributes = userAttr;
}
public UserAttributes getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(UserAttributes userAttributes) {
this.userAttributes = userAttributes;
}
public String getUserStyle() {
return user_style;
}
public void setUserStyle(String userStyle) {
this.user_style = userStyle;
}
public String getUserBackgroundImage() {
return userBackgroundImage;
}
public void setUserBackgroundImage(String userBackgroundImage) {
this.userBackgroundImage = userBackgroundImage;
}
public String getUserStyleMessage() {
return userStyleMessage;
}
public void setUserStyleMessage(String userStyleMessage) {
this.userStyleMessage = userStyleMessage;
}
#Override
public int describeContents() {
return 0;
}
public StyleAttrEntity getStyle_attrEntity() {
return style_attrEntity;
}
public static Creator<StyleProfile> getCREATOR() {
return CREATOR;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(user_name);
dest.writeString(user_picture);
dest.writeParcelable(user_attr, flags);
dest.writeParcelable(style_attr, flags);
dest.writeString(user_style);
}
public void setStyle_attrEntity(StyleAttrEntity style_attrEntity) {
this.style_attrEntity = style_attrEntity;
}
public static class StyleAttr implements Parcelable {
#SerializedName("Edgy")
#Expose
private Integer edgy;
#SerializedName("Feminine")
#Expose
private Integer feminine;
#SerializedName("Fashion Forward")
#Expose
private Integer fashionForward;
#SerializedName("Classic")
#Expose
private Integer classic;
#SerializedName("Casual")
#Expose
private Integer casual;
#SerializedName("Bohemian")
#Expose
private Integer bohemian;
protected StyleAttr(Parcel in) {
edgy = in.readInt();
casual = in.readInt();
classic = in.readInt();
edgy = in.readInt();
fashionForward = in.readInt();
feminine = in.readInt();
}
public static final Creator<StyleAttr> CREATOR = new Creator<StyleAttr>() {
#Override
public StyleAttr createFromParcel(Parcel in) {
return new StyleAttr(in);
}
#Override
public StyleAttr[] newArray(int size) {
return new StyleAttr[size];
}
};
public void setBohemian(int Bohemian) {
this.bohemian = Bohemian;
}
public void setCasual(int Casual) {
this.casual = Casual;
}
public void setClassic(int Classic) {
this.classic = Classic;
}
public void setEdgy(int Edgy) {
this.edgy = Edgy;
}
public void setFashionForward(int FashionForward) {
this.fashionForward = FashionForward;
}
public void setFeminine(int Feminine) {
this.feminine = Feminine;
}
public int getBohemian() {
return bohemian;
}
public int getCasual() {
return casual;
}
public int getClassic() {
return classic;
}
public int getEdgy() {
return edgy;
}
public int getFashionForward() {
return fashionForward;
}
public int getFeminine() {
return feminine;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(bohemian);
dest.writeInt(casual);
dest.writeInt(classic);
dest.writeInt(edgy);
dest.writeInt(fashionForward);
dest.writeInt(feminine);
}
}
}
UserAttrEntity.java
public class UserAttrEntity implements Parcelable {
#SerializedName("Size")
private String Size = "";
#SerializedName("Shape")
private String Shape = "";
#SerializedName("Bottoms Size")
private String Bottoms_Size = "";
#SerializedName("Height")
private String Height = "";
#SerializedName("Shoes Size")
private String Shoes_Size = "";
#SerializedName("Complexion")
private String Face_Color = "";
#SerializedName("Face Shape")
private String Face_Shape = "";
public UserAttrEntity() {
}
protected UserAttrEntity(Parcel in) {
Shape = in.readString();
Size = in.readString();
Bottoms_Size = in.readString();
Height = in.readString();
Shoes_Size = in.readString();
Face_Color = in.readString();
Face_Shape = in.readString();
}
public static final Creator<UserAttrEntity> CREATOR = new Creator<UserAttrEntity>() {
#Override
public UserAttrEntity createFromParcel(Parcel in) {
return new UserAttrEntity(in);
}
#Override
public UserAttrEntity[] newArray(int size) {
return new UserAttrEntity[size];
}
};
public void setShape(String Shape) {
this.Shape = Shape;
}
public void setSize(String Size) {
this.Size = Size.replace("\n", " ");
}
public void setBottoms_Size(String Bottoms_Size) {
this.Bottoms_Size = Bottoms_Size + " Inch";
}
public void setHeight(String Height) {
this.Height = Height;
}
public void setShoes_Size(String Shoes_Size) {
this.Shoes_Size = Shoes_Size;
}
public void setFace_Color(String Face_Color) {
this.Face_Color = Face_Color;
}
public void setFace_Shape(String Face_Shape) {
this.Face_Shape = Face_Shape;
}
public String getShape() {
return Shape;
}
public String getSize() {
return Size;
}
public String getBottoms_Size() {
return Bottoms_Size;
}
public String getHeight() {
return Height;
}
public String getShoes_Size() {
return Shoes_Size;
}
public String getFace_Color() {
return Face_Color;
}
public String getFace_Shape() {
return Face_Shape;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(Shape);
dest.writeString(Size);
dest.writeString(Bottoms_Size);
dest.writeString(Height);
dest.writeString(Shoes_Size);
dest.writeString(Face_Color);
dest.writeString(Face_Shape);
}
}
User AttributesEntity.java
public class UserAttributes {
#SerializedName("Size")
#Expose
private Size size;
#SerializedName("Shape")
#Expose
private Shape shape;
#SerializedName("Bottoms Size")
#Expose
private BottomsSize bottomsSize;
#SerializedName("Height")
#Expose
private Height height;
#SerializedName("Shoes Size")
#Expose
private ShoesSize shoesSize;
#SerializedName("Complexion")
#Expose
private Complexion complexion;
#SerializedName("Face Shape")
#Expose
private FaceShape faceShape;
public Size getSize() {
return size;
}
public void setSize(Size size) {
this.size = size;
}
public Shape getShape() {
return shape;
}
public void setShape(Shape shape) {
this.shape = shape;
}
public BottomsSize getBottomsSize() {
return bottomsSize;
}
public void setBottomsSize(BottomsSize bottomsSize) {
this.bottomsSize = bottomsSize;
}
public Height getHeight() {
return height;
}
public void setHeight(Height height) {
this.height = height;
}
public ShoesSize getShoesSize() {
return shoesSize;
}
public void setShoesSize(ShoesSize shoesSize) {
this.shoesSize = shoesSize;
}
public Complexion getComplexion() {
return complexion;
}
public void setComplexion(Complexion complexion) {
this.complexion = complexion;
}
public FaceShape getFaceShape() {
return faceShape;
}
public void setFaceShape(FaceShape faceShape) {
this.faceShape = faceShape;
}
}
Style Profile.java
Here i am using it like this
Profile profile = gson.fromJson(obj.toString(), Profile.class);
Log.e("", "profile.getStatus() " + profile.getStatus());
mReceiver.onResponse(profile, tag);
Try this way
//Main data
public class MainData{
#SerializedName("status")
#Expose
private String status;
#SerializedName("data")
#Expose
private Data data;
}
//Data
public class Data {
#SerializedName("user_name")
#Expose
private String userName;
#SerializedName("user_picture")
#Expose
private String userPicture;
#SerializedName("user_attr")
#Expose
private UserAttr userAttr;
#SerializedName("user_attributes")
#Expose
private UserAttributes userAttributes;
#SerializedName("style_attr")
#Expose
private StyleAttr styleAttr;
#SerializedName("user_style")
#Expose
private String userStyle;
#SerializedName("user_background_image")
#Expose
private String userBackgroundImage;
#SerializedName("user_style_message")
#Expose
private String userStyleMessage;
}
//user_attr
public class UserAttr {
#SerializedName("user_attr")
private Map<String, String> userAttributes;
public Map<String, String> getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(Map<String, String> userattributes) {
this.userAttributes= userattributes;
}
}
//user_attributes
public class UserAttributes {
#SerializedName("user_attributes")
private Map<String, CommonUserAttributes> userAttributes;
public Map<String, CommonUserAttributes> getUserAttributes() {
return userAttributes;
}
public void setUserAttributes(Map<String, CommonUserAttributes> userattributes) {
this.userAttributes = userattributes;
}
}
//StyleAttr
public class StyleAttr {
#SerializedName("style_attr")
private Map<String, Integer> styleAttributes;
public Map<String, Integer> getStyleAttributes() {
return styleAttributes;
}
public void setStyleAttributes(Map<String, Integer> styleAttributes) {
this.styleAttributes = styleAttributes;
}
}
//CommonUserAttributes
public class CommonUserAttributes {
#SerializedName("user_attr")
private String value;
#SerializedName("que_id")
private String bottmque_id;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getBottmque_id() {
return bottmque_id;
}
public void setBottmque_id(String bottmque_id) {
this.bottmque_id = bottmque_id;
}
}
put your get,set method yourself.

Android Realm return exception "Table has no columns"

This is my code:
PSTrip psTrip = JsonUtil.jsonToObject(jsonObject.toString(), PSTrip.class);
int size = psTrip.getTripSteps().size()-1;
RealmList<Step> steps = psTrip.getTripSteps().get(size).getSteps();
RealmList<TripStep> tripSteps = psTrip.getTripSteps();
Log.i("","continue init after getting tripsteps and steps");
if(tripSteps.size() > 0) {
Log.i("","continue init blabla");
for (int i = 0; i < tripSteps.size(); i++) {
RealmList<Step> mergedSteps = Utils.getMergedSteps(context, tripSteps.get(i).getRoute().getSteps());
tripSteps.get(i).getRoute().getSteps().clear();
for (Step step : mergedSteps) {
tripSteps.get(i).getRoute().getSteps().add(step);
}
}
Log.i("", "continue init after for in which I merge the steps for the tripsteps");
steps = Utils.getMergedSteps(context, steps);
Log.i("", "continue init after merging the steps");
tripSteps.get(size).setSteps(steps);
Log.i("", "continue init after settting steps on tripsteps");
psTrip.setTripSteps(tripSteps);
}
PSTripDBFactory.getInstance(context).addToList(psTrip);
The Utils.getMergedSteps just takes the list of steps (Step from Google maps class), and if it is possible, it merges them.
My problem is at the last line which does:
public void addToList(PSTrip psTrip){
try{
PSTrip insideAlready = getListOfCompletedTripsByID(psTrip.getId());
Log.i("","continue init inside already:" + insideAlready);
if(insideAlready == null){
Log.i("","continue init will copy to realm");
realm.beginTransaction();
realm.copyToRealm(psTrip);
realm.commitTransaction();
Log.i("","continue init will copy to realm finished");
}else{
Log.i("","continue init will copyorupdate to realm");
realm.beginTransaction();
realm.copyToRealmOrUpdate(psTrip);
realm.commitTransaction();
Log.i("","continue init will copyorupdate to realm finished");
}
}catch (Exception e){
Log.i("","continue init error trying to add to realm" + e.getMessage());
realm.cancelTransaction();
}
}
Where getListOfCompletedTripsByID is the following function:
public PSTrip getListOfCompletedTripsByID( String id){
RealmResults<PSTrip> completed = realm.where(PSTrip.class).equalTo("id" , id).findAll();
if(completed.size() > 0){
return completed.get(0);
}else{
return null;
}
}
I get back the following error response:
03-18 11:14:56.135 21908-21908/nl.hgrams.passenger I/﹕ continue init after for in which I merge the steps for the tripsteps
03-18 11:14:56.135 21908-21908/nl.hgrams.passenger I/﹕ continue init after merging the steps
03-18 11:14:56.135 21908-21908/nl.hgrams.passenger I/﹕ continue init after settting steps on tripsteps
03-18 11:14:56.135 21908-21908/nl.hgrams.passenger I/﹕ continue init inside already:null
03-18 11:14:56.136 21908-21908/nl.hgrams.passenger I/﹕ continue init will copy to realm
03-18 11:14:56.137 21908-21908/nl.hgrams.passenger D/REALM﹕ jni: ThrowingException 7, Table has no columns, .
03-18 11:14:56.137 21908-21908/nl.hgrams.passenger D/REALM﹕ Exception has been throw: Table has no columns
03-18 11:14:56.138 21908-21908/nl.hgrams.passenger I/﹕ continue init error trying to add to realmAn exception was thrown in the copyToRealm method in the proxy class io.realm.PSTripRealmProxy: Annotation processor may not have been executed.
Does anyone have an ideea why does realm return me a "table has no columns" error?
EDIT:
This is my PSTrip class:
public class PSTrip extends RealmObject {
private boolean valid;
private String detail;
private String icon_small;
private double avgspeed;
private String type;
private RealmList<RealmObj> messages = new RealmList<RealmObj>();
private String travel_mode;
private String id;
private Owner_data owner_data;
private int distance;
private RealmObj errors;
private String name;
private String destination_status;
private double checkinLat;
private double checkinLng;
private double checkoutLng;
private double checkoutLat;
private String icon;
private String status;
private int update_interval;
private Destination destination;
private double elapsed;
private int checkout_time;
private int checkin_time;
private Route route;
private String owner;
private double delay;
private String vehicle;
private Flight flight;
#SerializedName("last_updated")
private int lastUpdated;
#SerializedName("steps")
private RealmList<TripStep> tripSteps = new RealmList<TripStep>();
private Group group;
private boolean isRoaming = false;
public boolean getIsRoaming() {
return isRoaming;
}
public void setIsRoaming(boolean isRoaming) {
this.isRoaming = isRoaming;
}
public Group getGroup() {
return group;
}
public void setGroup(Group group) {
this.group = group;
}
public int getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(int lastUpdated) {
this.lastUpdated = lastUpdated;
}
public RealmList<TripStep> getTripSteps() {
return tripSteps;
}
public void setTripSteps(RealmList<TripStep> steps) {
this.tripSteps = steps;
}
public String getVehicle() {
return vehicle;
}
public void setVehicle(String vehicle) {
this.vehicle = vehicle;
}
public Flight getFlight() {
return flight;
}
public void setFlight(Flight flight) {
this.flight = flight;
}
public boolean getValid() {
return valid;
}
public void setValid(boolean valid) {
this.valid = valid;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public String getIcon_small() {
return icon_small;
}
public void setIcon_small(String icon_small) {
this.icon_small = icon_small;
}
public double getAvgspeed() {
return avgspeed;
}
public void setAvgspeed(double avgspeed) {
this.avgspeed = avgspeed;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public RealmList<RealmObj> getMessages() {
return messages;
}
public void setMessages(RealmList<RealmObj> messages) {
this.messages = messages;
}
public String getTravel_mode() {
return travel_mode;
}
public void setTravel_mode(String travel_mode) {
this.travel_mode = travel_mode;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Owner_data getOwner_data() {
return owner_data;
}
public void setOwner_data(Owner_data owner_data) {
this.owner_data = owner_data;
}
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
public RealmObj getErrors() {
return errors;
}
public void setErrors(RealmObj errors) {
this.errors = errors;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDestination_status() {
return destination_status;
}
public void setDestination_status(String destination_status) {
this.destination_status = destination_status;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public int getUpdate_interval() {
return update_interval;
}
public void setUpdate_interval(int update_interval) {
this.update_interval = update_interval;
}
public Destination getDestination() {
return destination;
}
public void setDestination(Destination destination) {
this.destination = destination;
}
public double getElapsed() {
return elapsed;
}
public void setElapsed(double elapsed) {
this.elapsed = elapsed;
}
public int getCheckout_time() {
return checkout_time;
}
public void setCheckout_time(int checkout_time) {
this.checkout_time = checkout_time;
}
public int getCheckin_time() {
return checkin_time;
}
public void setCheckin_time(int checkin_time) {
this.checkin_time = checkin_time;
}
public Route getRoute() {
return route;
}
public void setRoute(Route route) {
this.route = route;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public PSTrip() {
}
public double getDelay() {
return delay;
}
public void setDelay(double delay) {
this.delay = delay;
}
public PSTrip(String id) {
this.id = id;
}
public double getCheckoutLng() {
return checkoutLng;
}
public void setCheckoutLng(double checkoutLng) {
this.checkoutLng = checkoutLng;
}
#Override
public boolean isValid() {
return valid;
}
public double getCheckinLat() {
return checkinLat;
}
public void setCheckinLat(double checkinLat) {
this.checkinLat = checkinLat;
}
public double getCheckinLng() {
return checkinLng;
}
public void setCheckinLng(double checkinLng) {
this.checkinLng = checkinLng;
}
public double getCheckoutLat() {
return checkoutLat;
}
public void setCheckoutLat(double checkoutLat) {
this.checkoutLat = checkoutLat;
}
public boolean isRoaming() {
return isRoaming;
}
public void setRoaming(boolean isRoaming) {
this.isRoaming = isRoaming;
}
}
This is my TripStep class:
public class TripStep extends RealmObject{
#SerializedName("travel_mode")
private String travelMode;
#SerializedName("moving_time")
private int movingTime;
#SerializedName("moving_distance")
private int movingDistance;
private Polyline polyline;
private String vehicle;
private Route route;
#SerializedName("trip_id")
private int tripId;
#SerializedName("departure_stop")
private DepartureStop departureStop;
#SerializedName("arrival_stop")
private DepartureStop arrivalStop;
#PrimaryKey
private int id;
private Transit_details transit_details;
private RealmList<Step> steps = new RealmList<Step>();
private boolean hasStarted = false;
public Transit_details getTransit_details() {
return transit_details;
}
public void setTransit_details(Transit_details transit_details) {
this.transit_details = transit_details;
}
public String getTravelMode() {
return travelMode;
}
public void setTravelMode(String travelMode) {
this.travelMode = travelMode;
}
public int getMovingTime() {
return movingTime;
}
public void setMovingTime(int movingTime) {
this.movingTime = movingTime;
}
public int getMovingDistance() {
return movingDistance;
}
public void setMovingDistance(int movingDistance) {
this.movingDistance = movingDistance;
}
public Polyline getPolyline() {
return polyline;
}
public void setPolyline(Polyline polyline) {
this.polyline = polyline;
}
public String getVehicle() {
return vehicle;
}
public void setVehicle(String vehicle) {
this.vehicle = vehicle;
}
public Route getRoute() {
return route;
}
public void setRoute(Route route) {
this.route = route;
}
public int getTripId() {
return tripId;
}
public void setTripId(int tripId) {
this.tripId = tripId;
}
public DepartureStop getDepartureStop() {
return departureStop;
}
public void setDepartureStop(DepartureStop departureStop) {
this.departureStop = departureStop;
}
public DepartureStop getArrivalStop() {
return arrivalStop;
}
public void setArrivalStop(DepartureStop arrivalStop) {
this.arrivalStop = arrivalStop;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public RealmList<Step> getSteps() {
return steps;
}
public void setSteps(RealmList<Step> steps) {
this.steps = steps;
}
public boolean isHasStarted() {
return hasStarted;
}
public void setHasStarted(boolean hasStarted) {
this.hasStarted = hasStarted;
}
}
The rest are mostly google maps classes.
The PSTrip RealmList messages is empty.
the Route class contains a RealmList which is not empty (thats why I try doing copy to realm on it before)

How to access Serializable object in android

I am using Serializable interface to send user defined data from one activity to another.
Here is my code :
TasksheetData[] alltasks = new TasksheetData();
Intent in=new Intent(TaskSheetList.this, TaskDetails.class);
in.putExtra("TaskSheetData", alltasks);
and in other activity I am accessing this object like :
TasksheetData tData = (TasksheetData) getIntent().getSerializableExtra("TaskSheetData");
and here is my TasksheetData class
#SuppressWarnings("serial")
public class TasksheetData implements Serializable {
private int TaskID;
private int AttendantID;
private String AttendentName;
private String ReservationID;
private String ResStatusCode;
private int InspectionStartedById;
private String HKStatusCode;
private int FOStatusID;
private String FOStatusCode;
private int JobStatusID;
private String JobStatusCode;
private int LocationID;
private String LocationName;
private int RoomTypeID;
private String RoomType;
private int SectionID;
private String GuestID;
private String GuestName;
private String VIPCode;
private String Pax;
private String ArrivalTime;
private String CheckInTime;
private String CheckOutTime;
private String QueueSince;
private Trace[] arrTraces;
private String Specials;
private String ReservationComments;
private String SupervisorComments;
private String HKNotes;
private String TaskSheetName;
private int StandardCleaningTime;
private int AttendantPriority;
private String SupervisorPriority;
private String TaskStartTime;
private String TaskEndTime;
private String TasksheetInstruction;
private String localJobStatusCode;
private Boolean isSynch;
private String credit;
private String RemainingTimeSec;
private String TaskTypeId;
private String AttendantCLTypeId, SupervisorCLTypeId;
private String TritonLocationID;
private String PendingTritonJob;
private Boolean isDiscrepancy, InspectionStatus, IsTaskInspected;
public int getTaskID() {
return TaskID;
}
public void setTaskID(int taskID) {
TaskID = taskID;
}
public int getAttendantID() {
return AttendantID;
}
public void setAttendantID(int attendantID) {
AttendantID = attendantID;
}
public String getAttendentName() {
return AttendentName;
}
public void setAttendentName(String attendentName) {
AttendentName = attendentName;
}
public String getReservationID() {
return ReservationID;
}
public void setReservationID(String reservationID) {
ReservationID = reservationID;
}
public String getResStatusCode() {
return ResStatusCode;
}
public void setResStatusCode(String resStatusCode) {
ResStatusCode = resStatusCode;
}
public int getInspectionStartedById() {
return InspectionStartedById;
}
public void setInspectionStartedById(int inspectionStartedById) {
InspectionStartedById = inspectionStartedById;
}
public String getHKStatusCode() {
return HKStatusCode;
}
public void setHKStatusCode(String hKStatusCode) {
HKStatusCode = hKStatusCode;
}
public int getFOStatusID() {
return FOStatusID;
}
public void setFOStatusID(int fOStatusID) {
FOStatusID = fOStatusID;
}
public String getFOStatusCode() {
return FOStatusCode;
}
public void setFOStatusCode(String fOStatusCode) {
FOStatusCode = fOStatusCode;
}
public int getJobStatusID() {
return JobStatusID;
}
public void setJobStatusID(int jobStatusID) {
JobStatusID = jobStatusID;
}
public String getJobStatusCode() {
return JobStatusCode;
}
public void setJobStatusCode(String jobStatusCode) {
JobStatusCode = jobStatusCode;
}
public int getLocationID() {
return LocationID;
}
public void setLocationID(int locationID) {
LocationID = locationID;
}
public String getLocationName() {
return LocationName;
}
public void setLocationName(String locationName) {
LocationName = locationName;
}
public int getRoomTypeID() {
return RoomTypeID;
}
public void setRoomTypeID(int roomTypeID) {
RoomTypeID = roomTypeID;
}
public String getRoomType() {
return RoomType;
}
public void setRoomType(String roomType) {
RoomType = roomType;
}
public int getSectionID() {
return SectionID;
}
public void setSectionID(int sectionID) {
SectionID = sectionID;
}
public String getGuestID() {
return GuestID;
}
public void setGuestID(String guestID) {
GuestID = guestID;
}
public String getGuestName() {
return GuestName;
}
public void setGuestName(String guestName) {
GuestName = guestName;
}
public String getVIPCode() {
return VIPCode;
}
public void setVIPCode(String vIPCode) {
VIPCode = vIPCode;
}
public String getPax() {
return Pax;
}
public void setPax(String pax) {
Pax = pax;
}
public String getArrivalTime() {
return ArrivalTime;
}
public void setArrivalTime(String arrivalTime) {
ArrivalTime = arrivalTime;
}
public String getCheckInTime() {
return CheckInTime;
}
public void setCheckInTime(String checkInTime) {
CheckInTime = checkInTime;
}
public String getCheckOutTime() {
return CheckOutTime;
}
public void setCheckOutTime(String checkOutTime) {
CheckOutTime = checkOutTime;
}
public String getQueueSince() {
return QueueSince;
}
public void setQueueSince(String queueSince) {
QueueSince = queueSince;
}
public Trace[] getArrTraces() {
return arrTraces;
}
public void setArrTraces(Trace[] arrTraces) {
this.arrTraces = arrTraces;
}
public String getSpecials() {
return Specials;
}
public void setSpecials(String specials) {
Specials = specials;
}
public String getReservationComments() {
return ReservationComments;
}
public void setReservationComments(String reservationComments) {
ReservationComments = reservationComments;
}
public String getSupervisorComments() {
return SupervisorComments;
}
public void setSupervisorComments(String supervisorComments) {
SupervisorComments = supervisorComments;
}
public String getHKNotes() {
return HKNotes;
}
public void setHKNotes(String hKNotes) {
HKNotes = hKNotes;
}
public String getTaskSheetName() {
return TaskSheetName;
}
public void setTaskSheetName(String taskSheetName) {
TaskSheetName = taskSheetName;
}
public int getStandardCleaningTime() {
return StandardCleaningTime;
}
public void setStandardCleaningTime(int standardCleaningTime) {
StandardCleaningTime = standardCleaningTime;
}
public int getAttendantPriority() {
return AttendantPriority;
}
public void setAttendantPriority(int attendantPriority) {
AttendantPriority = attendantPriority;
}
public String getSupervisorPriority() {
return SupervisorPriority;
}
public void setSupervisorPriority(String supervisorPriority) {
SupervisorPriority = supervisorPriority;
}
public String getTaskStartTime() {
return TaskStartTime;
}
public void setTaskStartTime(String taskStartTime) {
TaskStartTime = taskStartTime;
}
public String getTaskEndTime() {
return TaskEndTime;
}
public void setTaskEndTime(String taskEndTime) {
TaskEndTime = taskEndTime;
}
public String getTasksheetInstruction() {
return TasksheetInstruction;
}
public void setTasksheetInstruction(String tasksheetInstruction) {
TasksheetInstruction = tasksheetInstruction;
}
public String getLocalJobStatusCode() {
return localJobStatusCode;
}
public void setLocalJobStatusCode(String localJobStatusCode) {
this.localJobStatusCode = localJobStatusCode;
}
public Boolean getIsSynch() {
return isSynch;
}
public void setIsSynch(Boolean isSynch) {
this.isSynch = isSynch;
}
public String getCredit() {
return credit;
}
public void setCredit(String credit) {
this.credit = credit;
}
public String getRemainingTimeSec() {
return RemainingTimeSec;
}
public void setRemainingTimeSec(String remainingTimeSec) {
RemainingTimeSec = remainingTimeSec;
}
public String getTaskTypeId() {
return TaskTypeId;
}
public void setTaskTypeId(String taskTypeId) {
TaskTypeId = taskTypeId;
}
public String getAttendantCLTypeId() {
return AttendantCLTypeId;
}
public void setAttendantCLTypeId(String attendantCLTypeId) {
AttendantCLTypeId = attendantCLTypeId;
}
public String getSupervisorCLTypeId() {
return SupervisorCLTypeId;
}
public void setSupervisorCLTypeId(String supervisorCLTypeId) {
SupervisorCLTypeId = supervisorCLTypeId;
}
public String getTritonLocationID() {
return TritonLocationID;
}
public void setTritonLocationID(String tritonLocationID) {
TritonLocationID = tritonLocationID;
}
public String getPendingTritonJob() {
return PendingTritonJob;
}
public void setPendingTritonJob(String pendingTritonJob) {
PendingTritonJob = pendingTritonJob;
}
public Boolean getIsDiscrepancy() {
return isDiscrepancy;
}
public void setIsDiscrepancy(Boolean isDiscrepancy) {
this.isDiscrepancy = isDiscrepancy;
}
public Boolean getInspectionStatus() {
return InspectionStatus;
}
public void setInspectionStatus(Boolean inspectionStatus) {
InspectionStatus = inspectionStatus;
}
public Boolean getIsTaskInspected() {
return IsTaskInspected;
}
public void setIsTaskInspected(Boolean isTaskInspected) {
IsTaskInspected = isTaskInspected;
}
}
But it is giving class cast exception when I try to cast it to my data object.
Please help me to resolve this?
You are putting in an Array and expecting out a single object. Also, use ArrayList which is serializable.
Not sure what your TasksheetData class is, but maybe you should use your alltasks as a ParcelableArray instead.
Checkout this
Your array of TasksheetData is definitely not an instance of one Serializable class...

Categories

Resources