|
|
|
@ -68,7 +68,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Post> readJson(JsonReader reader) { |
|
|
|
|
List<Post> list = new ArrayList<Post>(); |
|
|
|
|
List<Post> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
if (loadable.isBoardMode()) { |
|
|
|
|
list = loadBoard(reader); |
|
|
|
@ -100,7 +100,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Post> loadThread(JsonReader reader) { |
|
|
|
|
ArrayList<Post> list = new ArrayList<Post>(); |
|
|
|
|
ArrayList<Post> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
reader.beginObject(); |
|
|
|
@ -119,13 +119,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
reader.endObject(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} catch (IllegalStateException e) { |
|
|
|
|
} catch (IOException | IllegalStateException | NumberFormatException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} |
|
|
|
@ -134,7 +128,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Post> loadBoard(JsonReader reader) { |
|
|
|
|
ArrayList<Post> list = new ArrayList<Post>(); |
|
|
|
|
ArrayList<Post> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
reader.beginObject(); // Threads array
|
|
|
|
@ -168,13 +162,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reader.endObject(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} catch (IllegalStateException e) { |
|
|
|
|
} catch (IOException | IllegalStateException | NumberFormatException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} |
|
|
|
@ -183,7 +171,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<Post> loadCatalog(JsonReader reader) { |
|
|
|
|
ArrayList<Post> list = new ArrayList<Post>(); |
|
|
|
|
ArrayList<Post> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
reader.beginArray(); // Array of pages
|
|
|
|
@ -209,13 +197,7 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reader.endArray(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} catch (IllegalStateException e) { |
|
|
|
|
} catch (IOException | IllegalStateException | NumberFormatException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
setError(new ParseError(e)); |
|
|
|
|
} |
|
|
|
@ -231,59 +213,83 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> { |
|
|
|
|
while (reader.hasNext()) { |
|
|
|
|
String key = reader.nextName(); |
|
|
|
|
|
|
|
|
|
if (key.equals("no")) { |
|
|
|
|
// Post number
|
|
|
|
|
post.no = reader.nextInt(); |
|
|
|
|
switch (key) { |
|
|
|
|
case "no": |
|
|
|
|
// Post number
|
|
|
|
|
post.no = reader.nextInt(); |
|
|
|
|
/*} else if (key.equals("time")) { |
|
|
|
|
// Time
|
|
|
|
|
long time = reader.nextLong(); |
|
|
|
|
post.date = new Date(time * 1000);*/ |
|
|
|
|
} else if (key.equals("now")) { |
|
|
|
|
post.date = reader.nextString(); |
|
|
|
|
} else if (key.equals("name")) { |
|
|
|
|
post.name = reader.nextString(); |
|
|
|
|
} else if (key.equals("com")) { |
|
|
|
|
post.setComment(reader.nextString()); |
|
|
|
|
} else if (key.equals("tim")) { |
|
|
|
|
post.tim = reader.nextString(); |
|
|
|
|
} else if (key.equals("time")) { |
|
|
|
|
post.time = reader.nextLong(); |
|
|
|
|
} else if (key.equals("email")) { |
|
|
|
|
post.email = reader.nextString(); |
|
|
|
|
} else if (key.equals("ext")) { |
|
|
|
|
post.ext = reader.nextString().replace(".", ""); |
|
|
|
|
} else if (key.equals("resto")) { |
|
|
|
|
post.resto = reader.nextInt(); |
|
|
|
|
} else if (key.equals("w")) { |
|
|
|
|
post.imageWidth = reader.nextInt(); |
|
|
|
|
} else if (key.equals("h")) { |
|
|
|
|
post.imageHeight = reader.nextInt(); |
|
|
|
|
} else if (key.equals("fsize")) { |
|
|
|
|
post.fileSize = reader.nextInt(); |
|
|
|
|
} else if (key.equals("sub")) { |
|
|
|
|
post.subject = reader.nextString(); |
|
|
|
|
} else if (key.equals("replies")) { |
|
|
|
|
post.replies = reader.nextInt(); |
|
|
|
|
} else if (key.equals("filename")) { |
|
|
|
|
post.filename = reader.nextString(); |
|
|
|
|
} else if (key.equals("sticky")) { |
|
|
|
|
post.sticky = reader.nextInt() == 1; |
|
|
|
|
} else if (key.equals("closed")) { |
|
|
|
|
post.closed = reader.nextInt() == 1; |
|
|
|
|
} else if (key.equals("trip")) { |
|
|
|
|
post.tripcode = reader.nextString(); |
|
|
|
|
} else if (key.equals("country")) { |
|
|
|
|
post.country = reader.nextString(); |
|
|
|
|
} else if (key.equals("country_name")) { |
|
|
|
|
post.countryName = reader.nextString(); |
|
|
|
|
} else if (key.equals("id")) { |
|
|
|
|
post.id = reader.nextString(); |
|
|
|
|
} else if (key.equals("capcode")) { |
|
|
|
|
post.capcode = reader.nextString(); |
|
|
|
|
} else { |
|
|
|
|
// Unknown/ignored key
|
|
|
|
|
// log("Unknown/ignored key: " + key + ".");
|
|
|
|
|
reader.skipValue(); |
|
|
|
|
break; |
|
|
|
|
case "now": |
|
|
|
|
post.date = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "name": |
|
|
|
|
post.name = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "com": |
|
|
|
|
post.setComment(reader.nextString()); |
|
|
|
|
break; |
|
|
|
|
case "tim": |
|
|
|
|
post.tim = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "time": |
|
|
|
|
post.time = reader.nextLong(); |
|
|
|
|
break; |
|
|
|
|
case "email": |
|
|
|
|
post.email = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "ext": |
|
|
|
|
post.ext = reader.nextString().replace(".", ""); |
|
|
|
|
break; |
|
|
|
|
case "resto": |
|
|
|
|
post.resto = reader.nextInt(); |
|
|
|
|
break; |
|
|
|
|
case "w": |
|
|
|
|
post.imageWidth = reader.nextInt(); |
|
|
|
|
break; |
|
|
|
|
case "h": |
|
|
|
|
post.imageHeight = reader.nextInt(); |
|
|
|
|
break; |
|
|
|
|
case "fsize": |
|
|
|
|
post.fileSize = reader.nextInt(); |
|
|
|
|
break; |
|
|
|
|
case "sub": |
|
|
|
|
post.subject = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "replies": |
|
|
|
|
post.replies = reader.nextInt(); |
|
|
|
|
break; |
|
|
|
|
case "filename": |
|
|
|
|
post.filename = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "sticky": |
|
|
|
|
post.sticky = reader.nextInt() == 1; |
|
|
|
|
break; |
|
|
|
|
case "closed": |
|
|
|
|
post.closed = reader.nextInt() == 1; |
|
|
|
|
break; |
|
|
|
|
case "trip": |
|
|
|
|
post.tripcode = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "country": |
|
|
|
|
post.country = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "country_name": |
|
|
|
|
post.countryName = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "id": |
|
|
|
|
post.id = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
case "capcode": |
|
|
|
|
post.capcode = reader.nextString(); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
// Unknown/ignored key
|
|
|
|
|
// log("Unknown/ignored key: " + key + ".");
|
|
|
|
|
reader.skipValue(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
reader.endObject(); |
|
|
|
|