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

Items.java « gallery « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e5b1e9dbb4e1de05f788e34b3599dc61f16d1814 (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.gallery;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
import com.mapswithme.maps.search.Popularity;
import com.mapswithme.maps.search.SearchResult;

import static com.mapswithme.maps.gallery.Constants.TYPE_MORE;
import static com.mapswithme.maps.gallery.Constants.TYPE_PRODUCT;
import static com.mapswithme.util.Constants.Rating.RATING_INCORRECT_VALUE;

public class Items
{
  public static class LocalExpertItem extends RegularAdapterStrategy.Item
  {
    @Nullable
    private final String mPhotoUrl;
    private final double mPrice;
    @NonNull
    private final String mCurrency;
    private final double mRating;

    public LocalExpertItem(@Constants.ViewType int viewType, @NonNull String title,
                           @Nullable String url, @Nullable String photoUrl, double price,
                           @NonNull String currency, double rating)
    {
      super(viewType, title, null, url);
      mPhotoUrl = photoUrl;
      mPrice = price;
      mCurrency = currency;
      mRating = rating;
    }

    @Nullable
    String getPhotoUrl()
    {
      return mPhotoUrl;
    }

    public double getPrice()
    {
      return mPrice;
    }

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

    public double getRating()
    {
      return mRating;
    }
  }

  public static class LocalExpertMoreItem extends LocalExpertItem
  {

    public LocalExpertMoreItem(@Nullable String url)
    {
      super(TYPE_MORE, MwmApplication.get().getString(R.string.placepage_more_button), url,
            null, 0, "", 0);
    }
  }

  public static class SearchItem extends RegularAdapterStrategy.Item
  {
    @NonNull
    private final SearchResult mResult;

    public SearchItem(@NonNull SearchResult result)
    {
      super(TYPE_PRODUCT, result.name, result.description.featureType, null);
      mResult = result;
    }

    public SearchItem(@NonNull String title)
    {
      super(TYPE_MORE, title, null, null);
      mResult = SearchResult.EMPTY;
    }

    @NonNull
    public String getDistance()
    {
      SearchResult.Description d = mResult.description;
      return d != null ? d.distance : "";
    }

    public double getLat()
    {
      return mResult.lat;
    }

    public double getLon()
    {
      return mResult.lon;
    }

    public int getStars()
    {
      if (mResult.description == null)
        return 0;

      return mResult.description.stars;
    }

    public float getRating()
    {
      if (mResult.description == null)
        return RATING_INCORRECT_VALUE;

      return mResult.description.rating;
    }

    @Nullable
    public String getPrice()
    {
      if (mResult.description == null)
        return null;

      return mResult.description.pricing;
    }

    @Nullable
    public String getFeatureType()
    {
      if (mResult.description == null)
        return null;

      return mResult.description.featureType;
    }

    @NonNull
    public Popularity getPopularity()
    {
      return mResult.getPopularity();
    }
  }

  public static class MoreSearchItem extends SearchItem
  {
    public MoreSearchItem()
    {
      super(MwmApplication.get().getString(R.string.placepage_more_button));
    }
  }

  public static class Item
  {
    @NonNull
    private final String mTitle;
    @Nullable
    private final String mUrl;
    @Nullable
    private final String mSubtitle;

    public Item(@NonNull String title, @Nullable String url,
                @Nullable String subtitle)
    {
      mTitle = title;
      mUrl = url;
      mSubtitle = subtitle;
    }

    @NonNull
    public String getTitle()
    {
      return mTitle;
    }

    @Nullable
    public String getSubtitle()
    {
      return mSubtitle;
    }

    @Nullable
    public String getUrl()
    {
      return mUrl;
    }
  }
}