2014-08-01 19:20:42 +02:00
|
|
|
package com.rarchives.ripme.ui;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
public class HistoryEntry {
|
|
|
|
|
2015-10-18 01:56:50 +02:00
|
|
|
public String url = "",
|
|
|
|
title = "",
|
|
|
|
dir = "";
|
|
|
|
public int count = 0;
|
|
|
|
public Date startDate = new Date(),
|
|
|
|
modifiedDate = new Date();
|
|
|
|
public boolean selected = false;
|
2014-08-01 19:20:42 +02:00
|
|
|
|
|
|
|
public HistoryEntry() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public HistoryEntry fromJSON(JSONObject json) {
|
|
|
|
this.url = json.getString("url");
|
|
|
|
this.startDate = new Date(json.getLong("startDate"));
|
|
|
|
this.modifiedDate = new Date(json.getLong("modifiedDate"));
|
2015-01-11 09:23:43 +01:00
|
|
|
if (json.has("title")) {
|
|
|
|
this.title = json.getString("title");
|
|
|
|
}
|
|
|
|
if (json.has("count")) {
|
|
|
|
this.count = json.getInt("count");
|
|
|
|
}
|
|
|
|
if (json.has("dir")) {
|
|
|
|
this.dir = json.getString("dir");
|
|
|
|
}
|
|
|
|
if (json.has("selected")) {
|
|
|
|
this.selected = json.getBoolean("selected");
|
|
|
|
}
|
2014-08-01 19:20:42 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public JSONObject toJSON() {
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("url", this.url);
|
|
|
|
json.put("startDate", this.startDate.getTime());
|
|
|
|
json.put("modifiedDate", this.modifiedDate.getTime());
|
2015-01-11 09:23:43 +01:00
|
|
|
json.put("title", this.title);
|
|
|
|
json.put("count", this.count);
|
|
|
|
json.put("selected", this.selected);
|
2014-08-01 19:20:42 +02:00
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
2017-05-09 23:02:24 +02:00
|
|
|
@Override
|
2014-08-01 19:20:42 +02:00
|
|
|
public String toString() {
|
|
|
|
return this.url;
|
|
|
|
}
|
|
|
|
}
|