Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.fasten.communication.data.history;
- import android.os.Parcel;
- import android.os.Parcelable;
- import com.fasten.communication.OrderStatus;
- import com.fasten.communication.OrderSubStatus;
- import com.fasten.utils.DateUtils;
- import com.google.gson.annotations.Expose;
- import com.google.gson.annotations.SerializedName;
- import com.fasten.communication.tick.CustomerCost;
- import java.text.SimpleDateFormat;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- /**
- * Created by ios on 30.04.15.
- */
- public class OrderDetails implements Parcelable {
- @SerializedName("order_id")
- String orderId;
- @SerializedName("start_address")
- String startAddress;
- @SerializedName("end_address")
- String endAddress;
- @SerializedName("track_url")
- String trackUrl;
- @SerializedName("promo_code_discount")
- int promoDiscount;
- @SerializedName("promo_code_desc")
- String promoDescription;
- @SerializedName("customer_costs")
- CustomerCost[] customerCosts;
- @SerializedName("car_info")
- HistoryCarInfo carInfo;
- HistoryRating rating;
- @SerializedName("payment")
- PaymentInfo paymentInfo;
- String comments;
- @SerializedName("driver_info")
- DriverInfo driverInfo;
- Toll[] tolls;
- @SerializedName("lost_stuff_counter")
- byte lostStuffCounter;
- // ------------------------------------- //
- @SerializedName("start_date")
- Date startDate;
- @SerializedName("end_date")
- Date endDate;
- int total;
- @SerializedName("car_class")
- int carClass;
- @SerializedName("car_capacity")
- int carCapacity;
- @Expose
- @SerializedName("state")
- OrderStatus state;
- @Expose
- @SerializedName("sub_state")
- OrderSubStatus subState;
- // ------------------------------ //
- public static final Creator<OrderDetails> CREATOR = new Creator<OrderDetails>() {
- @Override
- public OrderDetails createFromParcel(Parcel source) {
- return new OrderDetails(source);
- }
- @Override
- public OrderDetails[] newArray(int size) {
- return new OrderDetails[size];
- }
- };
- private CustomerCost[] convertParcelableArray(Parcel parcel) {
- Parcelable[] parcelableArray =
- parcel.readParcelableArray(CustomerCost.class.getClassLoader());
- CustomerCost[] resultArray = null;
- if (parcelableArray != null) {
- resultArray = Arrays.copyOf(parcelableArray, parcelableArray.length, CustomerCost[].class);
- }
- return resultArray;
- }
- private OrderDetails(Parcel in) {
- orderId = in.readString();
- startAddress = in.readString();
- endAddress = in.readString();
- trackUrl = in.readString();
- promoDiscount = in.readInt();
- promoDescription = in.readString();
- customerCosts = convertParcelableArray(in);
- carInfo = in.readParcelable(HistoryCarInfo.class.getClassLoader());
- rating = in.readParcelable(HistoryRating.class.getClassLoader());
- comments = in.readString();
- driverInfo = in.readParcelable(DriverInfo.class.getClassLoader());
- paymentInfo = in.readParcelable(PaymentInfo.class.getClassLoader());
- tolls = in.createTypedArray(Toll.CREATOR);
- lostStuffCounter = in.readByte();
- // ------------------------- //
- startDate = (Date) in.readSerializable();
- endDate = (Date) in.readSerializable();
- total = in.readInt();
- carClass = in.readInt();
- carCapacity = in.readInt();
- state = (OrderStatus) in.readSerializable();
- subState = (OrderSubStatus) in.readSerializable();
- // ------------------------- //
- }
- @Override
- public int describeContents() {
- return 0;
- }
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(orderId);
- dest.writeString(startAddress);
- dest.writeString(endAddress);
- dest.writeString(trackUrl);
- dest.writeInt(promoDiscount);
- dest.writeString(promoDescription);
- dest.writeParcelableArray(customerCosts, flags);
- dest.writeParcelable(carInfo, flags);
- dest.writeParcelable(rating, flags);
- dest.writeString(comments);
- dest.writeParcelable(driverInfo, flags);
- dest.writeParcelable(paymentInfo, flags);
- dest.writeTypedArray(tolls, flags);
- dest.writeByte(lostStuffCounter);
- //-------------------------------- //
- dest.writeSerializable(startDate);
- dest.writeSerializable(endDate);
- dest.writeInt(total);
- dest.writeInt(carClass);
- dest.writeInt(carCapacity);
- dest.writeSerializable(state);
- dest.writeSerializable(subState);
- //------------------------------- //
- }
- public PaymentInfo getPaymentInfo() {
- return paymentInfo;
- }
- public String getOrderId() {
- return orderId;
- }
- public CustomerCost[] getCustomerCosts() {
- return customerCosts;
- }
- public String getStartAddress() {
- return startAddress;
- }
- public String getEndAddress() {
- return endAddress;
- }
- public String getTrackUrl() {
- return trackUrl;
- }
- public int getPromoDiscount() {
- return promoDiscount;
- }
- public String getPromoDescription() {
- return promoDescription;
- }
- public HistoryCarInfo getCarInfo() {
- return carInfo;
- }
- public HistoryRating getRating() {
- return rating;
- }
- public String getComments() {
- return comments;
- }
- public DriverInfo getDriverInfo() {
- return driverInfo;
- }
- public Toll[] getTolls() {
- return tolls;
- }
- public boolean isHotCall() {
- if(getCustomerCosts()[0].getHotCoefficient() > 1) {
- return true;
- }
- return false;
- }
- static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm");
- public String getStartTime() {
- Calendar calendar = Calendar.getInstance();
- TIME_FORMAT.setTimeZone(calendar.getTimeZone());
- return TIME_FORMAT.format(startDate);
- }
- public String getEndTime() {
- Calendar calendar = Calendar.getInstance();
- TIME_FORMAT.setTimeZone(calendar.getTimeZone());
- return TIME_FORMAT.format(endDate);
- }
- public String getOnlyStartDate() {
- return DateUtils.formatDate(startDate);
- }
- public byte getLostStuffCounter() {
- return lostStuffCounter;
- }
- public void setLostStuffCounter(byte lostStuffCounter) {
- this.lostStuffCounter = lostStuffCounter;
- }
- public Date getStartDate() {
- return startDate;
- }
- public Date getEndDate() {
- return endDate;
- }
- public int getTotal() {
- return total;
- }
- public int getCarClass() {
- return carClass;
- }
- public int getCarCapacity() {
- return carCapacity;
- }
- public OrderStatus getState() {
- return state;
- }
- public OrderSubStatus getSubState() {
- return subState;
- }
- public boolean isCancelled() {
- return subState == OrderSubStatus.CUSTOMER_CANCEL_BEFORE_TRIP || subState == OrderSubStatus.CUSTOMER_CANCEL_BEFORE_ARRIVE;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement