Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TaxiInfo.java « taxi « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ac8da2929ab81defd716649c63e8e4387d17dc6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package com.mapswithme.maps.taxi;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TaxiInfo implements Parcelable
{
  public static final Parcelable.Creator<TaxiInfo> CREATOR = new Parcelable.Creator<TaxiInfo>()
  {
    @Override
    public TaxiInfo createFromParcel(Parcel source)
    {
      return new TaxiInfo(source);
    }

    @Override
    public TaxiInfo[] newArray(int size)
    {
      return new TaxiInfo[size];
    }
  };

  @NonNull
  private final TaxiType mType;
  @NonNull
  private final List<Product> mProducts;

  private TaxiInfo(int type, @NonNull Product[] products)
  {
    mType = TaxiType.values()[type];
    mProducts = new ArrayList<>(Arrays.asList(products));
  }

  private TaxiInfo(@NonNull Parcel parcel)
  {
    //noinspection WrongConstant
    mType = TaxiType.values()[parcel.readInt()];
    List<Product> products = new ArrayList<>();
    parcel.readTypedList(products, Product.CREATOR);
    mProducts = products;
  }

  @NonNull
  public final TaxiType getType()
  {
    return mType;
  }

  @NonNull
  public List<Product> getProducts()
  {
    return mProducts;
  }

  @Override
  public String toString()
  {
    return "TaxiInfo{" +
           "mType=" + mType +
           ", mProducts=" + mProducts +
           '}';
  }

  @Override
  public int describeContents()
  {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags)
  {
    dest.writeInt(mType.ordinal());
    dest.writeTypedList(mProducts);
  }

  public static class Product implements Parcelable
  {
    public static final Parcelable.Creator<Product> CREATOR = new Parcelable.Creator<Product>()
    {
      @Override
      public Product createFromParcel(Parcel source)
      {
        return new Product(source);
      }

      @Override
      public Product[] newArray(int size)
      {
        return new Product[size];
      }
    };

    @NonNull
    private final String mProductId;
    @NonNull
    private final String mName;
    @NonNull
    private final String mTime;
    @NonNull
    private final String mPrice;
    @NonNull
    private final String mCurrency;

    private Product(@NonNull String productId, @NonNull String name, @NonNull String time,
                    @NonNull String price, @NonNull String currency)
    {
      mProductId = productId;
      mName = name;
      mTime = time;
      mPrice = price;
      mCurrency = currency;
    }

    private Product(@NonNull Parcel parcel)
    {
      mProductId = parcel.readString();
      mName = parcel.readString();
      mTime = parcel.readString();
      mPrice = parcel.readString();
      mCurrency = parcel.readString();
    }

    @NonNull
    public String getProductId()
    {
      return mProductId;
    }

    @NonNull
    public String getName()
    {
      return mName;
    }

    @NonNull
    public String getTime()
    {
      return mTime;
    }

    @NonNull
    public String getPrice()
    {
      return mPrice;
    }

    @NonNull
    public String getCurrency()
    {
      return mCurrency;
    }

    @Override
    public String toString()
    {
      return "Product{" +
             "mProductId='" + mProductId + '\'' +
             ", mName='" + mName + '\'' +
             ", mTime='" + mTime + '\'' +
             ", mPrice='" + mPrice + '\'' +
             ", mCurrency='" + mCurrency + '\'' +
             '}';
    }

    @Override
    public int describeContents()
    {
      return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags)
    {
      dest.writeString(mProductId);
      dest.writeString(mName);
      dest.writeString(mTime);
      dest.writeString(mPrice);
      dest.writeString(mCurrency);
    }
  }
}