Example #1
0
  private void showBannerAd(final String adId, final String adPosition) {
    removeBannerAd();
    if (adId.length() > 0) {
      bannerAd = new AdView(context, adId);
    } else {
      bannerAd = new AdView(context);
    }
    bannerAd.setPublisherId(appId);

    if (adPosition.compareToIgnoreCase("bottom") == 0) {
      RelativeLayout relativeLayout = new RelativeLayout(context);
      RelativeLayout.LayoutParams relativeParams =
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      relativeParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
      context.addContentView(
          relativeLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      relativeLayout.addView(bannerAd, relativeParams);
      relativeLayout.setFocusable(false);
    } else {
      LinearLayout bannerAdLayout = new LinearLayout(context);
      bannerAdLayout.setOrientation(LinearLayout.VERTICAL);
      context.addContentView(
          bannerAdLayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      bannerAdLayout.addView(bannerAd);
      bannerAdLayout.setFocusable(false);
    }

    ViewGroup group = (ViewGroup) bannerAd.getParent().getParent();
    group.findViewById(Cocos2dxActivity.GLVIEW_ID).requestFocus();

    bannerAd.setFocusable(false);
    bannerAd.setAdListener(this);
    bannerAd.loadAd(new AdRequest());
  }
  @Override
  public void populateView(Displayable displayable) {
    HeaderRow row = (HeaderRow) displayable;
    title.setText(row.getLabel());
    if (row.isHasMore()) {
      more.setVisibility(View.VISIBLE);
      if (storeName == null || TextUtils.isEmpty(storeName)) {
        if (storeId == 0) {
          more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme));
          moreLayout.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme));
        } else {
          more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme, storeId));
          moreLayout.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeId));
        }
      } else {
        if (storeId == 0) {
          more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName));
          moreLayout.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName));
        } else {
          more.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName, storeId));
          moreLayout.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName, storeId));
        }
      }
    } else {
      more.setVisibility(View.GONE);
      moreLayout.setClickable(false);
      moreLayout.setFocusable(false);
    }

    if (theme != null) {
      @ColorInt int color = itemView.getContext().getResources().getColor(theme.getStoreHeader());
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        more.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
      } else {

        // put this in Utils when you need to tint a Button background
        Drawable wrapDrawable = DrawableCompat.wrap(more.getBackground());
        DrawableCompat.setTint(
            wrapDrawable, itemView.getContext().getResources().getColor(theme.getStoreHeader()));
        more.setBackgroundDrawable(DrawableCompat.unwrap(wrapDrawable));
      }
    }
  }
  private RelativeLayout buildPagingControl(Context context) {
    RelativeLayout layout = new RelativeLayout(context);
    layout.setFocusable(false);
    layout.setFocusableInTouchMode(false);

    TiArrowView left = new TiArrowView(context);
    left.setVisibility(View.INVISIBLE);
    left.setId(PAGE_LEFT);
    left.setMinimumWidth(80); // TODO density?
    left.setMinimumHeight(80);
    left.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            movePrevious();
          }
        });
    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(left, params);

    TiArrowView right = new TiArrowView(context);
    right.setLeft(false);
    right.setVisibility(View.INVISIBLE);
    right.setId(PAGE_RIGHT);
    right.setMinimumWidth(80); // TODO density?
    right.setMinimumHeight(80);
    right.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            moveNext();
          }
        });
    params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(right, params);

    layout.setVisibility(View.GONE);

    return layout;
  }
  public EBounceViewHeader(Context context, int type) {
    super(context);
    setWillNotDraw(true);
    setBackgroundColor(0);
    setFocusable(false);
    ESystemInfo intence = ESystemInfo.getIntence();
    int height = intence.mDefaultBounceHeight;
    RelativeLayout wapper = new RelativeLayout(context);
    wapper.setWillNotDraw(true);
    wapper.setBackgroundColor(0);
    wapper.setFocusable(false);
    RelativeLayout.LayoutParams wParm = new LayoutParams(-1, height);
    if (type == EViewEntry.F_BOUNCE_TYPE_TOP) {
      wParm.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    } else {
      wParm.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    }
    wapper.setLayoutParams(wParm);
    addView(wapper);

    wap = new RelativeLayout(context);
    wap.setId(F_WAP_ID);
    RelativeLayout.LayoutParams wm = new LayoutParams(-2, height);
    wm.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    wm.leftMargin = 30;
    wap.setLayoutParams(wm);

    mContent = new TextView(context);
    mContent.setId(F_CONTENT_ID);
    RelativeLayout.LayoutParams parmMsg = new LayoutParams(-2, -2);
    parmMsg.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mContent.setLayoutParams(parmMsg);
    mContent.setTextColor(textColor);
    mContent.setText(pullToReloadText);
    mContent.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize));
    mContent.setVisibility(GONE);
    wap.addView(mContent);

    mLevelContent = new TextView(context);
    RelativeLayout.LayoutParams parml = new LayoutParams(-2, -2);
    parml.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
    parml.addRule(RelativeLayout.BELOW, F_CONTENT_ID);
    mLevelContent.setLayoutParams(parml);
    mLevelContent.setTextColor(textColor);
    mLevelContent.setTextSize(
        TypedValue.COMPLEX_UNIT_DIP, (float) (intence.mDefaultNatvieFontSize * 0.6));
    mLevelContent.setVisibility(GONE);
    wap.addView(mLevelContent);

    wapper.addView(wap);

    mProgress = new ProgressBar(context);
    mProgress.setIndeterminate(true);
    int use = height - 12;
    RelativeLayout.LayoutParams parmPro = new LayoutParams(use, use);
    parmPro.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmPro.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mProgress.setLayoutParams(parmPro);
    mProgress.setVisibility(GONE);
    wapper.addView(mProgress);

    mYAxisProgress = new YAxisImageView(context);
    int useY = height - 12;
    RelativeLayout.LayoutParams parmProY = new LayoutParams(useY, useY);
    parmProY.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmProY.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mYAxisProgress.setLayoutParams(parmProY);
    mYAxisProgress.setVisibility(GONE);
    wapper.addView(mYAxisProgress);

    mArrowImage = new ImageView(context);
    int useA = height - 12;
    RelativeLayout.LayoutParams parmImage = new LayoutParams(useA, useA);
    parmImage.addRule(RelativeLayout.LEFT_OF, F_WAP_ID);
    parmImage.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    mArrowImage.setLayoutParams(parmImage);
    Drawable icon =
        context.getResources().getDrawable(EResources.platform_myspace_pulltorefresh_arrow);
    mArrowImage.setImageDrawable(icon);
    mArrowImage.setVisibility(GONE);
    wapper.addView(mArrowImage);

    mAnimationUp =
        new RotateAnimation(
            0,
            -180,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    mAnimationUp.setInterpolator(new AccelerateInterpolator());
    mAnimationUp.setDuration(250);
    mAnimationUp.setFillAfter(true);

    mAnimationDown =
        new RotateAnimation(
            -180,
            0,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f,
            RotateAnimation.RELATIVE_TO_SELF,
            0.5f);
    mAnimationDown.setInterpolator(new AccelerateInterpolator());
    mAnimationDown.setDuration(250);
    mAnimationDown.setFillAfter(true);
  }
Example #5
0
  /**
   * Instantiates a new ab slider button.
   *
   * @param context the context
   * @param attrs the attrs
   */
  public AbSlidingButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    btnWidth = 40;
    btnHeight = 40;
    // 移动的距离
    moveWidth = 45;
    // 每次移动的距离
    movePDis = 5;
    // 覆盖按钮的宽
    WidthOffset = 5;

    WindowManager wManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wManager.getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();

    /*
     2 px = 3 dip if dpi == 80(ldpi), 320x240 screen
     1 px = 1 dip if dpi == 160(mdpi), 480x320 screen
     3 px = 2 dip if dpi == 240(hdpi), 840x480 screen
    */

    if (width < 320) {
      btnWidth = btnWidth - 10;
      btnHeight = btnHeight - 10;
      moveWidth = moveWidth - 10;
    } else if (width > 320 && width < 450) {
      btnWidth = btnWidth + 10;
      btnHeight = btnHeight + 10;
      moveWidth = moveWidth + 10;
    } else if (width >= 450) {
      btnWidth = btnWidth + 20;
      btnHeight = btnHeight + 20;
      moveWidth = moveWidth + 20;
    }

    detector = new GestureDetector(this);

    mRelativeLayout = new RelativeLayout(context);

    ImageButton btnOn = new ImageButton(context);
    ImageButton btnOff = new ImageButton(context);
    btnLeft = new ImageButton(context);
    btnRight = new ImageButton(context);

    btnOn.setFocusable(false);
    btnOff.setFocusable(false);
    btnLeft.setFocusable(false);
    btnRight.setFocusable(false);

    Bitmap onImage = AbFileUtil.getBitmapFormSrc("image/button_on_bg.png");
    Bitmap offImage = AbFileUtil.getBitmapFormSrc("image/button_off_bg.png");
    Bitmap blockImage = AbFileUtil.getBitmapFormSrc("image/button_block.png");

    btnOn.setId(ID_BTN1);
    // btnOn.setImageBitmap(onImage);
    btnOn.setMinimumWidth(btnWidth);
    btnOn.setMinimumHeight(btnHeight);
    btnOn.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(onImage));

    btnOff.setId(ID_BTN2);
    btnOff.setMinimumWidth(btnWidth);
    btnOff.setMinimumHeight(btnHeight);
    // btnOff.setImageBitmap(offImage);
    btnOff.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(offImage));

    btnLeft.setId(ID_BTN3);
    btnLeft.setMinimumWidth(btnWidth + WidthOffset);
    btnLeft.setMinimumHeight(btnHeight);
    // btnLeft.setImageBitmap(blockImage);
    btnLeft.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(blockImage));

    btnRight.setId(ID_BTN4);
    btnRight.setMinimumWidth(btnWidth + WidthOffset);
    btnRight.setMinimumHeight(btnHeight);
    // btnRight.setImageBitmap(blockImage);
    btnRight.setBackgroundDrawable(AbImageUtil.bitmapToDrawable(blockImage));

    mRelativeLayout.addView(btnOn);
    mRelativeLayout.setFocusable(false);

    RelativeLayout.LayoutParams lp2 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp2.addRule(RelativeLayout.RIGHT_OF, ID_BTN1);
    mRelativeLayout.addView(btnOff, lp2);

    RelativeLayout.LayoutParams lp3 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp3.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    mRelativeLayout.addView(btnLeft, lp3);

    RelativeLayout.LayoutParams lp4 =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
    mRelativeLayout.addView(btnRight, lp4);

    addView(mRelativeLayout);

    mSwitcherChangeListener =
        new AbOnChangeListener() {

          @Override
          public void onChange(int position) {}
        };
  }
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
      mShowTvdbId = cursor.getInt(DetailsQuery.REF_SHOW_ID);
      mSeasonNumber = cursor.getInt(DetailsQuery.SEASON);
      mEpisodeNumber = cursor.getInt(DetailsQuery.NUMBER);
      final String showTitle = cursor.getString(DetailsQuery.SHOW_TITLE);
      final String episodeTitle = cursor.getString(DetailsQuery.TITLE);
      final long airTime = cursor.getLong(DetailsQuery.FIRSTAIREDMS);

      // Title and description
      ((TextView) view.findViewById(R.id.title)).setText(cursor.getString(DetailsQuery.TITLE));
      ((TextView) view.findViewById(R.id.description))
          .setText(cursor.getString(DetailsQuery.OVERVIEW));

      // Show title button
      TextView showtitle = (TextView) view.findViewById(R.id.showTitle);
      if (!isShowingShowLink()) {
        showtitle.setVisibility(View.GONE);
      } else {
        showtitle.setVisibility(View.VISIBLE);
        showtitle.setText(showTitle);
        showtitle.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                Intent upIntent = new Intent(getActivity(), OverviewActivity.class);
                upIntent.putExtra(OverviewFragment.InitBundle.SHOW_TVDBID, mShowTvdbId);
                upIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(upIntent);
                getActivity()
                    .overridePendingTransition(
                        R.anim.fragment_slide_right_enter, R.anim.fragment_slide_right_exit);
                getActivity().finish();
              }
            });
      }

      // Show poster background
      if (getArguments().getBoolean("showposter")) {
        final ImageView background =
            (ImageView) getActivity().findViewById(R.id.episodedetails_background);
        Utils.setPosterBackground(
            background, cursor.getString(DetailsQuery.SHOW_POSTER), getActivity());
      }

      SpannableStringBuilder airTimeAndNumberText = new SpannableStringBuilder();
      // Air day and time
      TextView airdateText = (TextView) view.findViewById(R.id.airDay);
      TextView airtimeText = (TextView) view.findViewById(R.id.airTime);
      if (airTime != -1) {
        airdateText.setText(Utils.formatToDate(airTime, getActivity()));
        String[] dayAndTime = Utils.formatToTimeAndDay(airTime, getActivity());
        airTimeAndNumberText
            .append(
                getString(R.string.release_date_and_day, dayAndTime[2], dayAndTime[1])
                    .toUpperCase(Locale.getDefault()))
            .append("  ");
      } else {
        airdateText.setText(R.string.unknown);
      }

      // number
      int numberStartIndex = airTimeAndNumberText.length();
      airTimeAndNumberText.append(
          getString(R.string.season_number, mSeasonNumber).toUpperCase(Locale.getDefault()));
      airTimeAndNumberText.append(" ");
      airTimeAndNumberText.append(
          getString(R.string.episode_number, mEpisodeNumber).toUpperCase(Locale.getDefault()));
      final int episodeAbsoluteNumber = cursor.getInt(DetailsQuery.ABSOLUTE_NUMBER);
      if (episodeAbsoluteNumber > 0 && episodeAbsoluteNumber != mEpisodeNumber) {
        airTimeAndNumberText.append(" (").append(String.valueOf(episodeAbsoluteNumber)).append(")");
      }
      airTimeAndNumberText.setSpan(
          new TextAppearanceSpan(mContext, R.style.TextAppearance_Small_Dim),
          numberStartIndex,
          airTimeAndNumberText.length(),
          Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      airtimeText.setText(airTimeAndNumberText);

      // Last edit date
      TextView lastEdit = (TextView) view.findViewById(R.id.lastEdit);
      long lastEditRaw = cursor.getLong(DetailsQuery.LASTEDIT);
      if (lastEditRaw > 0) {
        lastEdit.setText(
            DateUtils.formatDateTime(
                context,
                lastEditRaw * 1000,
                DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME));
      } else {
        lastEdit.setText(R.string.unknown);
      }

      // Guest stars
      Utils.setLabelValueOrHide(
          view.findViewById(R.id.labelGuestStars),
          (TextView) view.findViewById(R.id.guestStars),
          Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.GUESTSTARS)));
      // DVD episode number
      Utils.setLabelValueOrHide(
          view.findViewById(R.id.labelDvd),
          (TextView) view.findViewById(R.id.dvdNumber),
          cursor.getDouble(DetailsQuery.DVDNUMBER));
      // Directors
      String directors = Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.DIRECTORS));
      Utils.setValueOrPlaceholder(view.findViewById(R.id.directors), directors);
      // Writers
      String writers = Utils.splitAndKitTVDBStrings(cursor.getString(DetailsQuery.WRITERS));
      Utils.setValueOrPlaceholder(view.findViewById(R.id.writers), writers);

      // Episode image
      FrameLayout imageContainer = (FrameLayout) view.findViewById(R.id.imageContainer);
      final String imagePath = cursor.getString(DetailsQuery.IMAGE);
      onLoadImage(imagePath, imageContainer);
      imageContainer.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent fullscreen = new Intent(getActivity(), FullscreenImageActivity.class);
              fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_PATH, imagePath);
              fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_TITLE, showTitle);
              fullscreen.putExtra(FullscreenImageActivity.InitBundle.IMAGE_SUBTITLE, episodeTitle);
              ActivityCompat.startActivity(
                  getActivity(),
                  fullscreen,
                  ActivityOptionsCompat.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight())
                      .toBundle());
            }
          });

      mEpisodeFlag = cursor.getInt(DetailsQuery.WATCHED);
      // Watched button
      boolean isWatched = EpisodeTools.isWatched(mEpisodeFlag);
      ImageButton seenButton = (ImageButton) view.findViewById(R.id.imageButtonBarWatched);
      seenButton.setImageResource(
          isWatched
              ? R.drawable.ic_ticked
              : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch));
      seenButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              onToggleWatched();
              fireTrackerEvent("Toggle watched");
            }
          });
      CheatSheet.setup(seenButton, isWatched ? R.string.unmark_episode : R.string.mark_episode);

      // skip button
      boolean isSkipped = EpisodeTools.isSkipped(mEpisodeFlag);
      ImageButton skipButton = (ImageButton) view.findViewById(R.id.imageButtonBarSkip);
      skipButton.setVisibility(
          isWatched ? View.GONE : View.VISIBLE); // if watched do not allow skipping
      skipButton.setImageResource(
          isSkipped
              ? R.drawable.ic_action_playback_next_highlight
              : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableSkip));
      skipButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              onToggleSkipped();
              fireTrackerEvent("Toggle skipped");
            }
          });
      CheatSheet.setup(skipButton, isSkipped ? R.string.action_dont_skip : R.string.action_skip);

      // Collected button
      mCollected = cursor.getInt(DetailsQuery.COLLECTED) == 1;
      ImageButton collectedButton = (ImageButton) view.findViewById(R.id.imageButtonBarCollected);
      collectedButton.setImageResource(
          mCollected
              ? R.drawable.ic_collected
              : Utils.resolveAttributeToResourceId(
                  getActivity().getTheme(), R.attr.drawableCollect));
      collectedButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              onToggleCollected();
              fireTrackerEvent("Toggle collected");
            }
          });
      CheatSheet.setup(collectedButton, mCollected ? R.string.uncollect : R.string.collect);

      // menu button
      View menuButton = view.findViewById(R.id.imageButtonBarMenu);
      registerForContextMenu(menuButton);
      menuButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              getActivity().openContextMenu(v);
            }
          });

      // TVDb rating
      RelativeLayout ratings = (RelativeLayout) view.findViewById(R.id.ratingbar);
      String ratingText = cursor.getString(DetailsQuery.RATING);
      if (ratingText != null && ratingText.length() != 0) {
        TextView ratingValue = (TextView) ratings.findViewById(R.id.textViewRatingsTvdbValue);
        ratingValue.setText(ratingText);
      }
      ratings.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              onRateOnTrakt();
            }
          });
      ratings.setFocusable(true);
      CheatSheet.setup(ratings, R.string.menu_rate_episode);

      // fetch trakt ratings
      onLoadTraktRatings(ratings, true);

      // Google Play button
      View playButton = view.findViewById(R.id.buttonGooglePlay);
      ServiceUtils.setUpGooglePlayButton(showTitle + " " + episodeTitle, playButton, TAG);

      // Amazon button
      View amazonButton = view.findViewById(R.id.buttonAmazon);
      ServiceUtils.setUpAmazonButton(showTitle + " " + episodeTitle, amazonButton, TAG);

      // YouTube button
      View youtubeButton = view.findViewById(R.id.buttonYouTube);
      ServiceUtils.setUpYouTubeButton(showTitle + " " + episodeTitle, youtubeButton, TAG);

      // IMDb button
      String imdbId = cursor.getString(DetailsQuery.IMDBID);
      if (TextUtils.isEmpty(imdbId)) {
        // fall back to show IMDb id
        imdbId = cursor.getString(DetailsQuery.SHOW_IMDBID);
      }
      ServiceUtils.setUpImdbButton(
          imdbId, view.findViewById(R.id.buttonShowInfoIMDB), TAG, getActivity());

      // TVDb button
      final int seasonTvdbId = cursor.getInt(DetailsQuery.REF_SEASON_ID);
      ServiceUtils.setUpTvdbButton(
          mShowTvdbId, seasonTvdbId, getEpisodeTvdbId(), view.findViewById(R.id.buttonTVDB), TAG);

      // trakt button
      ServiceUtils.setUpTraktButton(
          mShowTvdbId, mSeasonNumber, mEpisodeNumber, view.findViewById(R.id.buttonTrakt), TAG);

      // Web search button
      View webSearch = view.findViewById(R.id.buttonWebSearch);
      ServiceUtils.setUpWebSearchButton(showTitle + " " + episodeTitle, webSearch, TAG);

      // trakt shouts button
      view.findViewById(R.id.buttonShouts)
          .setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  Intent intent = new Intent(getActivity(), TraktShoutsActivity.class);
                  intent.putExtras(
                      TraktShoutsActivity.createInitBundleEpisode(
                          mShowTvdbId, mSeasonNumber, mEpisodeNumber, episodeTitle));
                  startActivity(intent);
                  fireTrackerEvent("Comments");
                }
              });

      // Check in button
      final int episodeTvdbId = cursor.getInt(DetailsQuery._ID);
      View checkinButton = view.findViewById(R.id.imageButtonBarCheckin);
      checkinButton.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              // display a check-in dialog
              CheckInDialogFragment f =
                  CheckInDialogFragment.newInstance(getActivity(), episodeTvdbId);
              f.show(getFragmentManager(), "checkin-dialog");
              fireTrackerEvent("Check-In");
            }
          });
      CheatSheet.setup(checkinButton);
    }