Style.java
2.4 KB
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
package com.styleteq.app.models;
import android.text.TextUtils;
import com.styleteq.app.helpers.ImageHelper;
import com.styleteq.app.mixpanel.MixPanelModel;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Style extends Model implements Likeable, Mappable, MixPanelModel {
public int id;
public String name;
public List<Attachment> images;
public String description;
@JsonProperty("user")
public User owner;
@JsonProperty("tag_list")
public String[] tagList;
@JsonProperty("like_count")
public int likeCount;
@JsonProperty("comment_count")
public int commentCount;
@Override
public int likeCount() {
return likeCount;
}
@JsonProperty("primary_picture_url")
public String primaryPictureUrl;
@JsonProperty("user_id")
public long userId;
public float latitude;
public float longitude;
public String primaryPictureUrl(int style) {
return ImageHelper.getImageUrl(primaryPictureUrl, style);
}
@JsonProperty("images_attributes")
public List<ImageAttributes> imageAttributes;
@Override
public long id() {
return id;
}
public static Style createFromJsonString(String json) {
return createFromJsonString(json, Style.class);
}
public boolean is_liked;
@Override
public boolean isLiked() {
return is_liked;
}
@Override
public void setLiked(boolean liked) {
this.is_liked = liked;
}
@Override
public void setLikeCount(int count) {
this.likeCount = count;
}
public String tagHashString() {
if (tagList == null)
return null;
List<String> hash = new ArrayList<>();
for (String s : tagList) {
hash.add("#" + s);
}
return TextUtils.join(", ", hash);
}
@Override
public MapPosition mapPosition() {
MapPosition p = new MapPosition();
p.latitude = latitude;
p.longitude = longitude;
p.label = tagHashString();
return p;
}
@Override
public JSONObject mixpanelObject() {
return toJson();
}
}