// Path: app/src/main/java/com/hexforhn/hex/model/Story.java
// public class Story implements Item {
// 
//     private final String mId;
//     private final String mTitle;
//     private final String mUrl;
//     private final String mCommentsUrl;
//     private final String mUser;
//     private final String mDomain;
//     private final int mScore;
//     private final int mCommentCount;
//     private final Date mDate;
//     private final List<Comment> mComments;
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = new ArrayList<>();
//     }
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date, List<Comment> comments) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = comments;
//     }
// 
//     public String getId() {
//         return this.mId;
//     }
// 
//     public String getTitle() {
//         return this.mTitle;
//     }
// 
//     public String getUrl() {
//         return this.mUrl;
//     }
// 
//     public String getCommentsUrl() {
//         return this.mCommentsUrl;
//     }
// 
//     public String getUser() {
//         return this.mUser;
//     }
// 
//     public String getDomain() {
//         return this.mDomain;
//     }
// 
//     public int getScore() {
//         return this.mScore;
//     }
// 
//     public int getCommentCount() {
//         return this.mCommentCount;
//     }
// 
//     public Date getDate() {
//         return this.mDate;
//     }
// 
//     public List<Comment> getComments() {
//         return this.mComments;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/marshall/StoryMarshaller.java
// public class StoryMarshaller {
// 
//     public static Story marshall(JSONObject rawStory) {
//         try {
//             String id = rawStory.getString("id");
//             String title = rawStory.getString("title");
//             String url = rawStory.getString("url");
//             String commentsUrl = rawStory.getString("commentsUrl");
//             String author = rawStory.getString("author");
//             String domain = rawStory.getString("domain");
//             int score = rawStory.getInt("score");
//             int commentCount = rawStory.getInt("commentCount");
//             Date date = new DateTime(rawStory.getString("time")).toDate();
// 
//             JSONArray rawComments = rawStory.has("comments") ? rawStory.getJSONArray("comments") : null;
//             List<Comment> comments =  new ArrayList<>();
//             if (rawComments != null) {
//                 comments = marshallComments(rawComments);
//             }
// 
//             return new Story(id, title, url, commentsUrl, author, domain, score, commentCount, date, comments);
//         } catch (Exception e) {
//             e.printStackTrace();
//             return null;
//         }
//     }
// 
//     private static List<Comment> marshallComments(JSONArray rawComments) {
//         List<Comment> comments = new ArrayList<>();
// 
//         for (int i = 0; i < rawComments.length(); i++) {
//             try {
//                 JSONObject rawComment = rawComments.getJSONObject(i);
//                 List<Comment> childComments = new ArrayList<>();
//                 JSONArray rawChildComments = rawComment.getJSONArray("comments");
// 
//                 if (rawChildComments != null) {
//                     childComments = marshallComments(rawComment.getJSONArray("comments"));
//                 }
// 
//                 String text = rawComment.getString("text");
//                 String author = rawComment.getString("author");
//                 int commentCount = rawComment.getInt("commentCount");
//                 Date date = new DateTime(rawComment.getString("time")).toDate();
//                 comments.add(new Comment(text, author, childComments, commentCount, date));
//             } catch (Exception e) {
//                 e.printStackTrace();
//             }
//         }
// 
//         return comments;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/util/RetryPolicyFactory.java
// public class RetryPolicyFactory {
//     private static final int SOCKET_TIMEOUT_MS = 2500;
//     private static final int MAX_RETRIES = 3;
//     private static final int BACKOFF_MULTIPLIER = 2;
// 
//     public static RetryPolicy build() {
//         return new DefaultRetryPolicy(SOCKET_TIMEOUT_MS, MAX_RETRIES, BACKOFF_MULTIPLIER);
//     }
// }


import com.android.volley.RequestQueue;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.RequestFuture;
import com.hexforhn.hex.model.Story;
import com.hexforhn.hex.net.hexapi.marshall.StoryMarshaller;
import com.hexforhn.hex.net.hexapi.util.RetryPolicyFactory;
import org.json.JSONObject;
package com.hexforhn.hex.net.hexapi;




public class StoryService {

    private final RequestQueue mRequestQueue;
// Path: app/src/main/java/com/hexforhn/hex/model/Story.java
// public class Story implements Item {
// 
//     private final String mId;
//     private final String mTitle;
//     private final String mUrl;
//     private final String mCommentsUrl;
//     private final String mUser;
//     private final String mDomain;
//     private final int mScore;
//     private final int mCommentCount;
//     private final Date mDate;
//     private final List<Comment> mComments;
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = new ArrayList<>();
//     }
// 
//     public Story(String id, String title, String url, String commentsUrl, String user, String domain,
//                  int score, int commentCount, Date date, List<Comment> comments) {
//         this.mId = id;
//         this.mTitle = title;
//         this.mUrl = url;
//         this.mCommentsUrl = commentsUrl;
//         this.mUser = user;
//         this.mDomain = domain;
//         this.mScore = score;
//         this.mCommentCount = commentCount;
//         this.mDate = date;
//         this.mComments = comments;
//     }
// 
//     public String getId() {
//         return this.mId;
//     }
// 
//     public String getTitle() {
//         return this.mTitle;
//     }
// 
//     public String getUrl() {
//         return this.mUrl;
//     }
// 
//     public String getCommentsUrl() {
//         return this.mCommentsUrl;
//     }
// 
//     public String getUser() {
//         return this.mUser;
//     }
// 
//     public String getDomain() {
//         return this.mDomain;
//     }
// 
//     public int getScore() {
//         return this.mScore;
//     }
// 
//     public int getCommentCount() {
//         return this.mCommentCount;
//     }
// 
//     public Date getDate() {
//         return this.mDate;
//     }
// 
//     public List<Comment> getComments() {
//         return this.mComments;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/marshall/StoryMarshaller.java
// public class StoryMarshaller {
// 
//     public static Story marshall(JSONObject rawStory) {
//         try {
//             String id = rawStory.getString("id");
//             String title = rawStory.getString("title");
//             String url = rawStory.getString("url");
//             String commentsUrl = rawStory.getString("commentsUrl");
//             String author = rawStory.getString("author");
//             String domain = rawStory.getString("domain");
//             int score = rawStory.getInt("score");
//             int commentCount = rawStory.getInt("commentCount");
//             Date date = new DateTime(rawStory.getString("time")).toDate();
// 
//             JSONArray rawComments = rawStory.has("comments") ? rawStory.getJSONArray("comments") : null;
//             List<Comment> comments =  new ArrayList<>();
//             if (rawComments != null) {
//                 comments = marshallComments(rawComments);
//             }
// 
//             return new Story(id, title, url, commentsUrl, author, domain, score, commentCount, date, comments);
//         } catch (Exception e) {
//             e.printStackTrace();
//             return null;
//         }
//     }
// 
//     private static List<Comment> marshallComments(JSONArray rawComments) {
//         List<Comment> comments = new ArrayList<>();
// 
//         for (int i = 0; i < rawComments.length(); i++) {
//             try {
//                 JSONObject rawComment = rawComments.getJSONObject(i);
//                 List<Comment> childComments = new ArrayList<>();
//                 JSONArray rawChildComments = rawComment.getJSONArray("comments");
// 
//                 if (rawChildComments != null) {
//                     childComments = marshallComments(rawComment.getJSONArray("comments"));
//                 }
// 
//                 String text = rawComment.getString("text");
//                 String author = rawComment.getString("author");
//                 int commentCount = rawComment.getInt("commentCount");
//                 Date date = new DateTime(rawComment.getString("time")).toDate();
//                 comments.add(new Comment(text, author, childComments, commentCount, date));
//             } catch (Exception e) {
//                 e.printStackTrace();
//             }
//         }
// 
//         return comments;
//     }
// }
// 
// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/util/RetryPolicyFactory.java
// public class RetryPolicyFactory {
//     private static final int SOCKET_TIMEOUT_MS = 2500;
//     private static final int MAX_RETRIES = 3;
//     private static final int BACKOFF_MULTIPLIER = 2;
// 
//     public static RetryPolicy build() {
//         return new DefaultRetryPolicy(SOCKET_TIMEOUT_MS, MAX_RETRIES, BACKOFF_MULTIPLIER);
//     }
// }


// Path: app/src/main/java/com/hexforhn/hex/net/hexapi/StoryService.java
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.RequestFuture;
import com.hexforhn.hex.model.Story;
import com.hexforhn.hex.net.hexapi.marshall.StoryMarshaller;
import com.hexforhn.hex.net.hexapi.util.RetryPolicyFactory;
import org.json.JSONObject;

package com.hexforhn.hex.net.hexapi;




public class StoryService {

    private final RequestQueue mRequestQueue;
    private final String mApiBaseUrl;