// Path: app/src/main/java/com/hexforhn/hex/HexApplication.java
// public class HexApplication extends Application {
// 
//     private RequestQueue mRequestQueue;
// 
//     public final String apiBaseUrl = "https://hex-api.herokuapp.com";
// 
//     public void onCreate() {
//         super.onCreate();
//         setupAnalytics();
//     }
// 
//     public RequestQueue getRequestQueue() {
//         if (mRequestQueue == null) {
//             int MEGABYTE = 1024 * 1024;
//             Cache cache = new DiskBasedCache(getCacheDir(), MEGABYTE);
//             Network network = new BasicNetwork(new HurlStack());
//             mRequestQueue = new RequestQueue(cache, network);
//             mRequestQueue.start();
//         }
// 
//         return mRequestQueue;
//     }
// 
//     private void setupAnalytics() {
//         GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
//         Tracker tracker = analytics.newTracker(R.xml.global_tracker);
//         tracker.enableAutoActivityTracking(true);
//         tracker.enableExceptionReporting(true);
//     }
// }
// 
// 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/StoryService.java
// public class StoryService {
// 
//     private final RequestQueue mRequestQueue;
//     private final String mApiBaseUrl;
// 
//     public StoryService(RequestQueue requestQueue, String apiUrl) {
//         this.mRequestQueue = requestQueue;
//         mApiBaseUrl = apiUrl;
//     }
// 
//     public Story getStory(String storyId) {
//         String STORY_PATH = "/story";
//         String storyPath = mApiBaseUrl + STORY_PATH + "/" + storyId;
// 
//         RequestFuture<JSONObject> future = RequestFuture.newFuture();
//         JsonObjectRequest request = new JsonObjectRequest(storyPath, future, future);
//         request.setRetryPolicy(RetryPolicyFactory.build());
//         mRequestQueue.add(request);
// 
//         try {
//             JSONObject response = future.get();
//             return StoryMarshaller.marshall(response);
//         } catch (Exception e) {
//             return null;
//         }
//     }
// }


import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.TextView;
import com.hexforhn.hex.HexApplication;
import com.hexforhn.hex.R;
import com.hexforhn.hex.model.Story;
import com.hexforhn.hex.net.hexapi.StoryService;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import java.util.concurrent.Callable;
            @Override
            public void onClick(View v) {
                loadArticle();
                mSwipeRefreshLayout.setRefreshing(true);
            }
        });
    }

    private String getStoryId() {
        return this.getArguments().getString("STORY_ID");
    }

    private void showArticleUnavailable() {
        View view = getView();

        view.findViewById(R.id.webView).setVisibility(View.GONE);
        view.findViewById(R.id.content_unavailable).setVisibility(View.VISIBLE);
    }

    private void hideArticleUnavailable() {
        View view = getView();

        view.findViewById(R.id.webView).setVisibility(View.VISIBLE);
        view.findViewById(R.id.content_unavailable).setVisibility(View.GONE);
    }

    private Single getStory() {
        return Single.fromCallable(new Callable<Story>() {
            @Override
            public Story call() {
// Path: app/src/main/java/com/hexforhn/hex/HexApplication.java
// public class HexApplication extends Application {
// 
//     private RequestQueue mRequestQueue;
// 
//     public final String apiBaseUrl = "https://hex-api.herokuapp.com";
// 
//     public void onCreate() {
//         super.onCreate();
//         setupAnalytics();
//     }
// 
//     public RequestQueue getRequestQueue() {
//         if (mRequestQueue == null) {
//             int MEGABYTE = 1024 * 1024;
//             Cache cache = new DiskBasedCache(getCacheDir(), MEGABYTE);
//             Network network = new BasicNetwork(new HurlStack());
//             mRequestQueue = new RequestQueue(cache, network);
//             mRequestQueue.start();
//         }
// 
//         return mRequestQueue;
//     }
// 
//     private void setupAnalytics() {
//         GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
//         Tracker tracker = analytics.newTracker(R.xml.global_tracker);
//         tracker.enableAutoActivityTracking(true);
//         tracker.enableExceptionReporting(true);
//     }
// }
// 
// 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/StoryService.java
// public class StoryService {
// 
//     private final RequestQueue mRequestQueue;
//     private final String mApiBaseUrl;
// 
//     public StoryService(RequestQueue requestQueue, String apiUrl) {
//         this.mRequestQueue = requestQueue;
//         mApiBaseUrl = apiUrl;
//     }
// 
//     public Story getStory(String storyId) {
//         String STORY_PATH = "/story";
//         String storyPath = mApiBaseUrl + STORY_PATH + "/" + storyId;
// 
//         RequestFuture<JSONObject> future = RequestFuture.newFuture();
//         JsonObjectRequest request = new JsonObjectRequest(storyPath, future, future);
//         request.setRetryPolicy(RetryPolicyFactory.build());
//         mRequestQueue.add(request);
// 
//         try {
//             JSONObject response = future.get();
//             return StoryMarshaller.marshall(response);
//         } catch (Exception e) {
//             return null;
//         }
//     }
// }


// Path: app/src/main/java/com/hexforhn/hex/fragment/ArticleFragment.java
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.TextView;
import com.hexforhn.hex.HexApplication;
import com.hexforhn.hex.R;
import com.hexforhn.hex.model.Story;
import com.hexforhn.hex.net.hexapi.StoryService;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import java.util.concurrent.Callable;

            @Override
            public void onClick(View v) {
                loadArticle();
                mSwipeRefreshLayout.setRefreshing(true);
            }
        });
    }

    private String getStoryId() {
        return this.getArguments().getString("STORY_ID");
    }

    private void showArticleUnavailable() {
        View view = getView();

        view.findViewById(R.id.webView).setVisibility(View.GONE);
        view.findViewById(R.id.content_unavailable).setVisibility(View.VISIBLE);
    }

    private void hideArticleUnavailable() {
        View view = getView();

        view.findViewById(R.id.webView).setVisibility(View.VISIBLE);
        view.findViewById(R.id.content_unavailable).setVisibility(View.GONE);
    }

    private Single getStory() {
        return Single.fromCallable(new Callable<Story>() {
            @Override
            public Story call() {
                HexApplication application = (HexApplication) getActivity().getApplication();