public void doDownload() {
   if (mIsCancelled) {
     // if the download has been cancelled, do not download
     // this image, but start the next one
     if (!queuedDownLoaderRequests.isEmpty()
         && runningDownLoaderRequests.size() < maxDownloads) {
       LoaderRequest d = queuedDownLoaderRequests.remove(0);
       d.doDownload();
     }
     return;
   }
   ImageView imageView = mImageViewRef.get();
   if (imageView != null
       && imageView.getTag(DRAWABLE_DOWNLOAD_TAG) == this
       && URLUtil.isNetworkUrl(uri)) {
     mDrawableDownloaderTask = new ApptentiveDownloaderTask(imageView, this);
     try {
       ApptentiveLog.v("ApptentiveAttachmentLoader doDownload: " + uri);
       // Conversation token is needed if the download url is a redirect link from an Apptentive
       // endpoint
       String conversationToken =
           ApptentiveInternal.getInstance().getApptentiveConversationToken();
       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
         mDrawableDownloaderTask.executeOnExecutor(
             AsyncTask.THREAD_POOL_EXECUTOR, uri, diskCacheFilePath, conversationToken);
       } else {
         mDrawableDownloaderTask.execute(uri, diskCacheFilePath, conversationToken);
       }
     } catch (RejectedExecutionException e) {
     }
     runningDownLoaderRequests.add(this);
     filesBeingDownloaded.add(diskCacheFilePath);
   }
 }
  @Override
  public void doOnCreate(Activity activity, Bundle savedInstanceState) {
    // TODO: See if we can determine which app store the app was downloaded and go directly there.
    String errorMessage = activity.getString(R.string.apptentive_rating_error);
    boolean showingDialog = false;
    try {
      IRatingProvider ratingProvider = ApptentiveInternal.getRatingProvider();
      errorMessage = ratingProvider.activityNotFoundMessage(activity);

      String appDisplayName = Configuration.load(activity).getAppDisplayName();
      Map<String, String> ratingProviderArgs = ApptentiveInternal.getRatingProviderArgs();
      Map<String, String> finalRatingProviderArgs;
      if (ratingProviderArgs != null) {
        finalRatingProviderArgs = new HashMap<String, String>(ratingProviderArgs);
      } else {
        finalRatingProviderArgs = new HashMap<String, String>();
      }

      if (!finalRatingProviderArgs.containsKey("package")) {
        finalRatingProviderArgs.put("package", activity.getPackageName());
      }
      if (!finalRatingProviderArgs.containsKey("name")) {
        finalRatingProviderArgs.put("name", appDisplayName);
      }

      ratingProvider.startRating(activity, finalRatingProviderArgs);
    } catch (ActivityNotFoundException e) {
      showingDialog = true;
      displayError(activity, errorMessage);
    } catch (InsufficientRatingArgumentsException e) {
      // TODO: Log a message to apptentive to let the developer know that their custom rating
      // provider puked?
      showingDialog = true;
      Log.e(e.getMessage());
      displayError(activity, activity.getString(R.string.apptentive_rating_error));
    } finally {
      if (!showingDialog) {
        Log.d("Finishing Activity.");
        activity.finish();
      }
    }
  }