viewing paste Unknown #1606 | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/** General AsyncTask */
  private static abstract class MALUAPITask<Result> extends AsyncTask<Void, Void, Result> {
    /** The handler for the retrieved data */
    protected final ConnectionHandler<Result> handler;
    protected final String url;
    public MALUAPITask(ConnectionHandler<Result> handler, String url) {
      this.handler = handler;
      this.url = url;
    }
    @Override
    protected Result doInBackground(Void... params) {
      String result = getResponseString(url);
      if(result != null && ! isCancelled()){
        return doInBackground(result);
      }
      return null;
    }
   
    @Override
    protected void onPostExecute(Result result) {
      handler.onPostResult(result);
    }
   
    /** Called when doInBackground has gotten the wanted data from the Connection */
    protected abstract Result doInBackground(String results);
  }
 
  // NEXT CLASS
 
  /** Task to retrieve the wanted Manga */
  private static class GetMangaTask extends MALUAPITask<Manga> {
    public GetMangaTask(ConnectionHandler<Manga> handler, String url) { super(handler, url); }
   
    @Override
    protected Manga doInBackground(String results) {
      // TODO Make String to Manga
      return null;
    }
   
  }
Viewed 349 times, submitted by unknown.