private void onLoadTraktRatings(View ratingBar, boolean isUseCachedValues) {
   if (mAdapter.getCursor() != null
       && (mTraktTask == null || mTraktTask.getStatus() != AsyncTask.Status.RUNNING)) {
     mTraktTask =
         new TraktSummaryTask(getSherlockActivity(), ratingBar, isUseCachedValues)
             .episode(mShowTvdbId, mSeasonNumber, mEpisodeNumber);
     AndroidUtils.executeAsyncTask(mTraktTask);
   }
 }
  @Override
  protected void onTraktCheckIn(String message) {
    final int season = getArguments().getInt(InitBundle.SEASON);
    final int episode = getArguments().getInt(InitBundle.EPISODE);

    AndroidUtils.executeAsyncTask(
        new TraktTask(getActivity(), mListener)
            .checkInEpisode(mShowTvdbId, season, episode, message),
        new Void[] {null});
  }
  protected void search() {
    // nag about no connectivity
    if (!AndroidUtils.isNetworkConnected(getSherlockActivity())) {
      Toast.makeText(getSherlockActivity(), R.string.offline, Toast.LENGTH_LONG).show();
      return;
    }

    String query = mSearchBox.getText().toString().trim();
    if (query.length() == 0) {
      return;
    }
    if (mSearchTask == null || mSearchTask.getStatus() == AsyncTask.Status.FINISHED) {
      mSearchTask = new SearchTask(getActivity());
      AndroidUtils.executeAsyncTask(mSearchTask, query);
    }
  }
  @Override
  protected boolean onGetGlueCheckin(String title, String message) {
    boolean isAbortingCheckIn = false;

    // require GetGlue authentication
    if (!GetGlueSettings.isAuthenticated(getActivity())) {
      isAbortingCheckIn = true;
    }

    // always get the latest GetGlue id
    final Cursor show =
        getActivity()
            .getContentResolver()
            .query(
                Shows.buildShowUri(String.valueOf(mShowTvdbId)),
                new String[] {Shows._ID, Shows.GETGLUEID},
                null,
                null,
                null);
    if (show != null) {
      show.moveToFirst();
      mGetGlueId = show.getString(1);
      show.close();
    }

    // check for GetGlue id
    if (TextUtils.isEmpty(mGetGlueId)) {
      isAbortingCheckIn = true;
    }

    if (isAbortingCheckIn) {
      mToggleGetGlueButton.setChecked(false);
      mGetGlueChecked = false;
      updateCheckInButtonState();
    } else {
      // check in, use task on thread pool
      AndroidUtils.executeAsyncTask(
          new CheckInTask(mGetGlueId, message, getActivity()), new Void[] {});
    }

    return isAbortingCheckIn;
  }
  @TargetApi(11)
  private void fillData() {
    TextView seriesname = (TextView) findViewById(R.id.title);
    TextView overview = (TextView) findViewById(R.id.TextViewShowInfoOverview);
    TextView airstime = (TextView) findViewById(R.id.TextViewShowInfoAirtime);
    TextView network = (TextView) findViewById(R.id.TextViewShowInfoNetwork);
    TextView status = (TextView) findViewById(R.id.TextViewShowInfoStatus);

    final Series show = DBUtils.getShow(this, String.valueOf(getShowId()));
    if (show == null) {
      finish();
      return;
    }

    // Name
    seriesname.setText(show.getSeriesName());

    // Overview
    if (show.getOverview().length() == 0) {
      overview.setText("");
    } else {
      overview.setText(show.getOverview());
    }

    // Airtimes
    if (show.getAirsDayOfWeek().length() == 0 || show.getAirsTime() == -1) {
      airstime.setText(getString(R.string.show_noairtime));
    } else {
      String[] values =
          Utils.parseMillisecondsToTime(
              show.getAirsTime(), show.getAirsDayOfWeek(), getApplicationContext());
      airstime.setText(getString(R.string.show_airs) + " " + values[1] + " " + values[0]);
    }

    // Network
    if (show.getNetwork().length() == 0) {
      network.setText("");
    } else {
      network.setText(getString(R.string.show_network) + " " + show.getNetwork());
    }

    // Running state
    if (show.getStatus() == 1) {
      status.setTextColor(Color.GREEN);
      status.setText(getString(R.string.show_isalive));
    } else if (show.getStatus() == 0) {
      status.setTextColor(Color.GRAY);
      status.setText(getString(R.string.show_isnotalive));
    }

    // first airdate
    long airtime = Utils.buildEpisodeAirtime(show.getFirstAired(), show.getAirsTime());
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoFirstAirdate), Utils.formatToDate(airtime, this));

    // Others
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoActors), Utils.splitAndKitTVDBStrings(show.getActors()));
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoContentRating), show.getContentRating());
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoGenres), Utils.splitAndKitTVDBStrings(show.getGenres()));
    Utils.setValueOrPlaceholder(
        findViewById(R.id.TextViewShowInfoRuntime),
        show.getRuntime() + " " + getString(R.string.show_airtimeunit));

    // TVDb rating
    String ratingText = show.getRating();
    if (ratingText != null && ratingText.length() != 0) {
      RatingBar ratingBar = (RatingBar) findViewById(R.id.bar);
      ratingBar.setProgress((int) (Double.valueOf(ratingText) / 0.1));
      TextView rating = (TextView) findViewById(R.id.value);
      rating.setText(ratingText + "/10");
    }

    // IMDb button
    View imdbButton = (View) findViewById(R.id.buttonShowInfoIMDB);
    final String imdbid = show.getImdbId();
    if (imdbButton != null) {
      imdbButton.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              fireTrackerEvent("Show IMDb page");

              if (imdbid.length() != 0) {
                Intent myIntent =
                    new Intent(Intent.ACTION_VIEW, Uri.parse("imdb:///title/" + imdbid + "/"));
                try {
                  startActivity(myIntent);
                } catch (ActivityNotFoundException e) {
                  myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(IMDB_TITLE_URL + imdbid));
                  startActivity(myIntent);
                }
              } else {
                Toast.makeText(
                        getApplicationContext(),
                        getString(R.string.show_noimdbentry),
                        Toast.LENGTH_LONG)
                    .show();
              }
            }
          });
    }

    // TVDb button
    View tvdbButton = (View) findViewById(R.id.buttonTVDB);
    final String tvdbId = show.getId();
    if (tvdbButton != null) {
      tvdbButton.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              fireTrackerEvent("Show TVDb page");
              Intent i =
                  new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.TVDB_SHOW_URL + tvdbId));
              startActivity(i);
            }
          });
    }

    // Shout button
    findViewById(R.id.buttonShouts)
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                fireTrackerEvent("Show Trakt Shouts");
                TraktShoutsFragment newFragment =
                    TraktShoutsFragment.newInstance(show.getSeriesName(), Integer.valueOf(tvdbId));

                newFragment.show(getSupportFragmentManager(), "shouts-dialog");
              }
            });

    // Share intent
    mShareIntentBuilder =
        ShareCompat.IntentBuilder.from(this)
            .setChooserTitle(R.string.share)
            .setText(
                getString(R.string.share_checkout)
                    + " \""
                    + show.getSeriesName()
                    + "\" via @SeriesGuide "
                    + ShowInfoActivity.IMDB_TITLE_URL
                    + imdbid)
            .setType("text/plain");

    // Poster
    final ImageView poster = (ImageView) findViewById(R.id.ImageViewShowInfoPoster);
    ImageProvider.getInstance(this).loadImage(poster, show.getPoster(), false);

    // trakt ratings
    TraktSummaryTask task = new TraktSummaryTask(this, findViewById(R.id.ratingbar)).show(tvdbId);
    AndroidUtils.executeAsyncTask(task, new Void[] {null});
  }
 protected void onLoadImage(String imagePath, FrameLayout container) {
   if (mArtTask == null || mArtTask.getStatus() == AsyncTask.Status.FINISHED) {
     mArtTask = new FetchArtTask(imagePath, container, getActivity());
     AndroidUtils.executeAsyncTask(mArtTask, new Void[] {null});
   }
 }