예제 #1
0
  @Override
  public void onPreExecute() {
    if (mThreadId == null) {
      if (Constants.LOGGING) Log.e(TAG, "mSettings.threadId == null");
      this.cancel(true);
      return;
    }
    synchronized (mCurrentDownloadCommentsTaskLock) {
      if (mCurrentDownloadCommentsTask != null) {
        this.cancel(true);
        return;
      }
      mCurrentDownloadCommentsTask = this;
    }

    if (isInsertingEntireThread()) {
      if (mActivity.mCommentsAdapter != null) mActivity.mCommentsAdapter.clear();
      else mActivity.resetUI(null);

      // Do loading screen when loading new thread; otherwise when "loading more comments" don't
      // show it
      mActivity.enableLoadingScreen();
    }

    if (mContentLength == -1)
      mActivity
          .getWindow()
          .setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_INDETERMINATE_ON);

    if (mThreadTitle != null) mActivity.setTitle(mThreadTitle + " : " + mSubreddit);
  }
예제 #2
0
  @Override
  public void onPostExecute(Boolean success) {
    if (isInsertingEntireThread()) {
      insertCommentsUI();
      if (isFoundJumpTargetComment())
        mActivity.getListView().setSelection(mJumpToCommentFoundIndex);
    } else if (!mDeferredReplacementList.isEmpty()) {
      replaceCommentsAtPositionUI(mDeferredReplacementList, mPositionOffset);
    }

    // have to wait till onPostExecute to do this, to ensure they've been inserted by UI thread
    processDeferredComments();

    if (Common.shouldLoadThumbnails(mActivity, mSettings)) showOPThumbnail();

    if (mContentLength == -1)
      mActivity
          .getWindow()
          .setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_INDETERMINATE_OFF);
    else mActivity.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_END);

    if (success) {
      // We should clear any replies the user was composing.
      mActivity.setShouldClearReply(true);

      // Set title in android titlebar
      if (mThreadTitle != null) mActivity.setTitle(mThreadTitle + " : " + mSubreddit);
    } else {
      if (!isCancelled()) {
        Common.showErrorToast(
            "Error downloading comments. Please try again.", Toast.LENGTH_LONG, mActivity);
        mActivity.resetUI(null);
      }
    }

    synchronized (mCurrentDownloadCommentsTaskLock) {
      mCurrentDownloadCommentsTask = null;
    }
  }