aboutsummaryrefslogtreecommitdiff
path: root/WordPress/src/main/java/org/wordpress/android/ui/stats/models/FollowerModel.java
blob: 4efc3bb8cb817080c666c508472dfbb31e7ac5b1 (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
package org.wordpress.android.ui.stats.models;

import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;
import org.wordpress.android.util.JSONUtils;
import org.wordpress.android.util.UrlUtils;

import java.io.Serializable;

public class FollowerModel implements Serializable {
    private String mBlogId;
    private String mLabel;
    private String mAvatar;
    private String mUrl;
    private FollowDataModel mFollowData;
    private String mDateSubscribed;

    public FollowerModel(String mBlogId, JSONObject followerJSONData) throws JSONException{
        this.mBlogId = mBlogId;
        this.mLabel = followerJSONData.getString("label");

        setAvatar(JSONUtils.getString(followerJSONData, "avatar"));
        setURL(JSONUtils.getString(followerJSONData, "url"));

        this.mDateSubscribed = followerJSONData.getString("date_subscribed");

        JSONObject followData = followerJSONData.optJSONObject("follow_data");
        if (followData != null) {
            this.mFollowData = new FollowDataModel(followData);
        }
    }

    public String getBlogId() {
        return mBlogId;
    }

    public void setBlogId(String blogId) {
        this.mBlogId = blogId;
    }

    public String getLabel() {
        return mLabel;
    }

    public String getURL() {
        return mUrl;
    }

    private boolean setURL(String URL) {
        if (!TextUtils.isEmpty(URL) && UrlUtils.isValidUrlAndHostNotNull(URL)) {
            this.mUrl = URL;
            return true;
        }
        return false;
    }

    public FollowDataModel getFollowData() {
        return mFollowData;
    }

    public String getAvatar() {
        return mAvatar;
    }




    private void setAvatar(String icon) {
        this.mAvatar = icon;
    }

    public String getDateSubscribed() {
        return mDateSubscribed;
    }
}