/** AsyncTask complete handler for: - Novel Content saved in DB - External Chapter */
  @Override
  public void onCompleteCallback(ICallbackEventData message, AsyncTaskResult<?> result) {
    Exception e = result.getError();
    if (e == null) {
      if (result.getResultType() == NovelContentModel.class) {
        NovelContentModel loadedContent = (NovelContentModel) result.getResult();
        synchronized (this) {
          try {
            loadedContent.refreshPageModel(); // ensuring pageModel to be refreshed
            setContent(loadedContent);
          } catch (Exception e1) {
            Log.e(TAG, "Cannot load content.", e);
          }
        }
        Document imageDoc = Jsoup.parse(loadedContent.getContent());
        images = CommonParser.parseImagesFromContentPage(imageDoc);
      } else if (result.getResultType() == Boolean.class) {
        // Load WAC
        Toast.makeText(this, message.getMessage(), Toast.LENGTH_SHORT).show();
        boolean res = (Boolean) result.getResult();
        if (!res) {
          PageModel p = new PageModel(getIntent().getStringExtra(Constants.EXTRA_PAGE));
          loadExternalUrl(p, true);
        }

      } else {
        Log.w(TAG, "Unexpected result: " + result.getResultType().getName());
      }
    } else {
      Log.e(TAG, "Error when loading novel content: " + e.getMessage(), e);
      Toast.makeText(this, e.getClass().toString() + ": " + e.getMessage(), Toast.LENGTH_SHORT)
          .show();
    }
    toggleProgressBar(false);
  }
コード例 #2
0
 @Override
 public void setMessageDialog(ICallbackEventData message) {
   // if(dialog.isShowing())
   // dialog.setMessage(message.getMessage());
   if (loadingText.getVisibility() == TextView.VISIBLE) loadingText.setText(message.getMessage());
 }
コード例 #3
0
 public void onCallback(ICallbackEventData message) {
   publishProgress(message.getMessage());
 }
 // region Progress bar related
 @Override
 public void onProgressCallback(ICallbackEventData message) {
   toggleProgressBar(true);
   loadingText.setText(message.getMessage());
 }