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

import android.webkit.URLUtil;

import org.wordpress.android.ui.stats.StatsUtils;

import java.io.Serializable;

/*
* A model to represent a SINGLE stats item
*/
public class SingleItemModel implements Serializable {
    private final String mBlogID;
    private final String mItemID;
    private final long mDate;
    private final String mTitle;
    private final int mTotals;
    private final String mUrl;
    private final String mIcon;

    public SingleItemModel(String blogId, String date, String itemID, String title, int totals, String url, String icon) {
       this(blogId, StatsUtils.toMs(date), itemID, title, totals, url, icon);
    }

    SingleItemModel(String blogId, long date, String itemID, String title, int totals, String url, String icon) {
        this.mBlogID = blogId;
        this.mItemID = itemID;
        this.mTitle = title;
        this.mTotals = totals;

        // We could get invalid data back from the server. Check that URL is OK.
        if (!URLUtil.isValidUrl(url)) {
            this.mUrl = "";
        } else {
            this.mUrl = url;
        }

        this.mDate = date;
        this.mIcon = icon;
    }

    public String getBlogID() {
        return mBlogID;
    }

    public String getItemID() {
        return mItemID;
    }

    public String getTitle() {
        return mTitle;
    }

    public int getTotals() {
        return mTotals;
    }

    public String getUrl() {
        return mUrl;
    }

    public String getIcon() {
        return mIcon;
    }

    public long getDate() {
        return mDate;
    }

}