1
0
mirror of https://github.com/akaessens/NoFbEventScraper synced 2025-06-05 23:29:13 +02:00

make fbevent properties immutable

This commit is contained in:
akaessens
2020-08-28 16:19:08 +02:00
parent 16d390094e
commit 6c0c2d23fe
2 changed files with 19 additions and 19 deletions

View File

@ -6,19 +6,18 @@ import java.time.format.FormatStyle;
public class FbEvent { public class FbEvent {
public String url; public final String url;
public String name; public final String name;
public ZonedDateTime start_date; public final ZonedDateTime start_date;
public ZonedDateTime end_date; public final ZonedDateTime end_date;
public String description; public final String description;
public String location; public final String location;
public String image_url; public final String image_url;
public FbEvent() {
} public FbEvent(String url, String name, ZonedDateTime start_date, ZonedDateTime end_date,
String description, String location, String image_url) {
public FbEvent(String name, ZonedDateTime start_date, ZonedDateTime end_date, String description, String location, String image_url) { this.url = url;
this.name = name; this.name = name;
this.start_date = start_date; this.start_date = start_date;
this.end_date = end_date; this.end_date = end_date;

View File

@ -135,14 +135,15 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
JSONObject reader = new JSONObject(json); JSONObject reader = new JSONObject(json);
event = new FbEvent(); event = new FbEvent(
event.url = url; url,
event.name = readFromJson(reader, "name"); readFromJson(reader, "name"),
event.start_date = toZonedDateTime(readFromJson(reader, "startDate")); toZonedDateTime(readFromJson(reader, "startDate")),
event.end_date = toZonedDateTime(readFromJson(reader, "endDate")); toZonedDateTime(readFromJson(reader, "endDate")),
event.description = fixDescriptionLinks(readFromJson(reader, "description")); fixDescriptionLinks(readFromJson(reader, "description")),
event.location = fixLocation(readFromJson(reader, "location")); fixLocation(readFromJson(reader, "location")),
event.image_url = readFromJson(reader, "image"); readFromJson(reader, "image")
);
} catch (URISyntaxException | MalformedURLException e) { } catch (URISyntaxException | MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();