コード例 #1
0
  public static ChanReaderRequest newInstance(
      Loadable loadable,
      List<Post> cached,
      Listener<List<Post>> listener,
      ErrorListener errorListener) {
    String url;

    if (loadable.isBoardMode()) {
      url = ChanUrls.getPageUrl(loadable.board, loadable.no);
    } else if (loadable.isThreadMode()) {
      url = ChanUrls.getThreadUrl(loadable.board, loadable.no);
    } else if (loadable.isCatalogMode()) {
      url = ChanUrls.getCatalogUrl(loadable.board);
    } else {
      throw new IllegalArgumentException("Unknown mode");
    }

    ChanReaderRequest request = new ChanReaderRequest(url, listener, errorListener);

    // Copy the loadable and cached list. The cached array may changed/cleared by other threads.
    request.loadable = loadable.copy();
    request.cached = new ArrayList<>(cached);

    return request;
  }