gt:                 if (discoverData.hasAvatarUrl()) {
context: package org.wordpress.android.ui.reader.adapters;
  
  import android.content.Context;
  import android.os.AsyncTask;
  import android.support.v7.widget.CardView;
  import android.support.v7.widget.RecyclerView;
  import android.text.TextUtils;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  import org.wordpress.android.R;
  import org.wordpress.android.analytics.AnalyticsTracker;
  import org.wordpress.android.datasets.ReaderPostTable;
  import org.wordpress.android.models.ReaderPost;
  import org.wordpress.android.models.ReaderPostDiscoverData;
  import org.wordpress.android.models.ReaderPostList;
  import org.wordpress.android.models.ReaderTag;
  import org.wordpress.android.ui.reader.ReaderActivityLauncher;
  import org.wordpress.android.ui.reader.ReaderAnim;
  import org.wordpress.android.ui.reader.ReaderConstants;
  import org.wordpress.android.ui.reader.ReaderInterfaces;
  import org.wordpress.android.ui.reader.ReaderTypes;
  import org.wordpress.android.ui.reader.actions.ReaderActions;
  import org.wordpress.android.ui.reader.actions.ReaderPostActions;
  import org.wordpress.android.ui.reader.models.ReaderBlogIdPostId;
  import org.wordpress.android.ui.reader.utils.ReaderUtils;
  import org.wordpress.android.ui.reader.utils.ReaderXPostUtils;
  import org.wordpress.android.ui.reader.views.ReaderBlogInfoView;
  import org.wordpress.android.ui.reader.views.ReaderGapMarkerView;
  import org.wordpress.android.ui.reader.views.ReaderIconCountView;
  import org.wordpress.android.ui.reader.views.ReaderTagInfoView;
  import org.wordpress.android.ui.reader.views.ReaderTagToolbar;
  import org.wordpress.android.util.AnalyticsUtils;
  import org.wordpress.android.util.AppLog;
  import org.wordpress.android.util.DateTimeUtils;
  import org.wordpress.android.util.DisplayUtils;
  import org.wordpress.android.util.GravatarUtils;
  import org.wordpress.android.util.NetworkUtils;
  import org.wordpress.android.util.ToastUtils;
  import org.wordpress.android.widgets.WPNetworkImageView;
  
  public class ReaderPostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
      private ReaderTag mCurrentTag;
      private long mCurrentBlogId;
      private long mCurrentFeedId;
      private int mGapMarkerPosition = -1;
  
      private final int mPhotonWidth;
      private final int mPhotonHeight;
      private final int mAvatarSzMedium;
      private final int mAvatarSzSmall;
      private final int mAvatarSzExtraSmall;
      private final int mMarginLarge;
  
      private final String mWordCountFmtStr;
      private final String mReadingTimeFmtStr;
  
      private boolean mCanRequestMorePosts;
      private final boolean mShowTagToolbar;
      private final boolean mIsLoggedOutReader;
  
      private final ReaderTypes.ReaderPostListType mPostListType;
      private final ReaderPostList mPosts = new ReaderPostList();
  
      private ReaderInterfaces.OnPostSelectedListener mPostSelectedListener;
      private ReaderInterfaces.OnTagSelectedListener mOnTagSelectedListener;
      private ReaderTagToolbar.OnTagChangedListener mOnTagChangedListener;
      private ReaderInterfaces.OnPostPopupListener mOnPostPopupListener;
      private ReaderInterfaces.DataLoadedListener mDataLoadedListener;
      private ReaderActions.DataRequestedListener mDataRequestedListener;
      private ReaderBlogInfoView.OnBlogInfoLoadedListener mBlogInfoLoadedListener;
  
      // the large "tbl_posts.text" column is unused here, so skip it when querying
      private static final boolean EXCLUDE_TEXT_COLUMN = true;
      private static final int MAX_ROWS = ReaderConstants.READER_MAX_POSTS_TO_DISPLAY;
  
      // Longreads says that people can read 250 words per minute
      private static final int READING_WORDS_PER_MINUTE = 250;
      private static final int MIN_READING_TIME_MINUTES = 2;
  
      private static final int VIEW_TYPE_POST        = 0;
      private static final int VIEW_TYPE_XPOST       = 1;
      private static final int VIEW_TYPE_BLOG_INFO   = 2;
      private static final int VIEW_TYPE_TAG_INFO    = 3;
      private static final int VIEW_TYPE_TAG_TOOLBAR = 4;
      private static final int VIEW_TYPE_GAP_MARKER  = 5;
  
      private static final long ITEM_ID_CUSTOM_VIEW = -1L;
  
      /*
       * cross-post
       */
      class ReaderXPostViewHolder extends RecyclerView.ViewHolder {
          private final CardView cardView;
          private final WPNetworkImageView imgAvatar;
          private final WPNetworkImageView imgBlavatar;
          private final TextView txtTitle;
          private final TextView txtSubtitle;
  
          public ReaderXPostViewHolder(View itemView) {
              super(itemView);
              cardView = (CardView) itemView.findViewById(R.id.card_view);
              imgAvatar = (WPNetworkImageView) itemView.findViewById(R.id.image_avatar);
              imgBlavatar = (WPNetworkImageView) itemView.findViewById(R.id.image_blavatar);
              txtTitle = (TextView) itemView.findViewById(R.id.text_title);
              txtSubtitle = (TextView) itemView.findViewById(R.id.text_subtitle);
          }
      }
  
      /*
       * full post
       */
      class ReaderPostViewHolder extends RecyclerView.ViewHolder {
          private final CardView cardView;
  
          private final TextView txtTitle;
          private final TextView txtText;
          private final TextView txtBlogName;
          private final TextView txtDate;
          private final TextView txtTag;
          private final TextView txtWordCount;
  
          private final ReaderIconCountView commentCount;
          private final ReaderIconCountView likeCount;
  
          private final ImageView imgMore;
  
          private final WPNetworkImageView imgFeatured;
          private final WPNetworkImageView imgAvatar;
  
          private final ViewGroup layoutPostHeader;
  
          private final ViewGroup layoutDiscover;
          private final WPNetworkImageView imgDiscoverAvatar;
          private final TextView txtDiscover;
  
          public ReaderPostViewHolder(View itemView) {
              super(itemView);
  
              cardView = (CardView) itemView.findViewById(R.id.card_view);
  
              txtTitle = (TextView) itemView.findViewById(R.id.text_title);
              txtText = (TextView) itemView.findViewById(R.id.text_excerpt);
              txtBlogName = (TextView) itemView.findViewById(R.id.text_blog_name);
              txtDate = (TextView) itemView.findViewById(R.id.text_date);
              txtTag = (TextView) itemView.findViewById(R.id.text_tag);
              txtWordCount = (TextView) itemView.findViewById(R.id.text_word_count);
  
              commentCount = (ReaderIconCountView) itemView.findViewById(R.id.count_comments);
              likeCount = (ReaderIconCountView) itemView.findViewById(R.id.count_likes);
  
              imgFeatured = (WPNetworkImageView) itemView.findViewById(R.id.image_featured);
              imgAvatar = (WPNetworkImageView) itemView.findViewById(R.id.image_avatar);
              imgMore = (ImageView) itemView.findViewById(R.id.image_more);
  
              layoutDiscover = (ViewGroup) itemView.findViewById(R.id.layout_discover);
              imgDiscoverAvatar = (WPNetworkImageView) layoutDiscover.findViewById(R.id.image_discover_avatar);
              txtDiscover = (TextView) layoutDiscover.findViewById(R.id.text_discover);
  
              layoutPostHeader = (ViewGroup) itemView.findViewById(R.id.layout_post_header);
  
              // adjust the right padding of the post header to allow right padding of the  "..." icon
              // https://github.com/wordpress-mobile/WordPress-Android/issues/3078
              layoutPostHeader.setPadding(
                      layoutPostHeader.getPaddingLeft(),
                      layoutPostHeader.getPaddingTop(),
                      layoutPostHeader.getPaddingRight() - imgMore.getPaddingRight(),
                      layoutPostHeader.getPaddingBottom());
  
              ReaderUtils.setBackgroundToRoundRipple(imgMore);
          }
      }
  
      class TagToolbarViewHolder extends RecyclerView.ViewHolder {
          private final ReaderTagToolbar mTagToolbar;
          public TagToolbarViewHolder(View itemView) {
              super(itemView);
              mTagToolbar = (ReaderTagToolbar) itemView;
          }
      }
  
      class BlogInfoViewHolder extends RecyclerView.ViewHolder {
          private final ReaderBlogInfoView mBlogInfoView;
          public BlogInfoViewHolder(View itemView) {
              super(itemView);
              mBlogInfoView = (ReaderBlogInfoView) itemView;
          }
      }
  
      class TagInfoViewHolder extends RecyclerView.ViewHolder {
          private final ReaderTagInfoView mTagInfoView;
          public TagInfoViewHolder(View itemView) {
              super(itemView);
              mTagInfoView = (ReaderTagInfoView) itemView;
          }
      }
  
      class GapMarkerViewHolder extends RecyclerView.ViewHolder {
          private final ReaderGapMarkerView mGapMarkerView;
          public GapMarkerViewHolder(View itemView) {
              super(itemView);
              mGapMarkerView = (ReaderGapMarkerView) itemView;
          }
      }
  
      @Override
      public int getItemViewType(int position) {
          if (position == 0 && mShowTagToolbar) {
              // first item is a pseudo-toolbar enabling changing the current tag
              return VIEW_TYPE_TAG_TOOLBAR;
          } else if (position == 0 && isBlogPreview()) {
              // first item is a ReaderBlogInfoView
              return VIEW_TYPE_BLOG_INFO;
          } else if (position == 0 && isTagPreview()) {
              // first item is a ReaderTagInfoView
              return VIEW_TYPE_TAG_INFO;
          } else if (position == mGapMarkerPosition) {
              return VIEW_TYPE_GAP_MARKER;
          } else if (getItem(position).isXpost()) {
              return VIEW_TYPE_XPOST;
          } else {
              return VIEW_TYPE_POST;
          }
      }
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          Context context = parent.getContext();
          switch (viewType) {
              case VIEW_TYPE_TAG_TOOLBAR:
                  return new TagToolbarViewHolder(new ReaderTagToolbar(context));
  
              case VIEW_TYPE_BLOG_INFO:
                  return new BlogInfoViewHolder(new ReaderBlogInfoView(context));
  
              case VIEW_TYPE_TAG_INFO:
                  return new TagInfoViewHolder(new ReaderTagInfoView(context));
  
              case VIEW_TYPE_GAP_MARKER:
                  return new GapMarkerViewHolder(new ReaderGapMarkerView(context));
  
              case VIEW_TYPE_XPOST:
                  View xpostView = LayoutInflater.from(context).inflate(R.layout.reader_cardview_xpost, parent, false);
                  return new ReaderXPostViewHolder(xpostView);
  
              default:
                  View postView = LayoutInflater.from(context).inflate(R.layout.reader_cardview_post, parent, false);
                  return new ReaderPostViewHolder(postView);
          }
      }
  
      @Override
      public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
          if (holder instanceof ReaderPostViewHolder) {
              renderPost(position, (ReaderPostViewHolder) holder);
          } else if (holder instanceof ReaderXPostViewHolder) {
              renderXPost(position, (ReaderXPostViewHolder) holder);
          } else if (holder instanceof BlogInfoViewHolder) {
              BlogInfoViewHolder blogHolder = (BlogInfoViewHolder) holder;
              blogHolder.mBlogInfoView.setOnBlogInfoLoadedListener(mBlogInfoLoadedListener);
              blogHolder.mBlogInfoView.loadBlogInfo(mCurrentBlogId, mCurrentFeedId);
          } else if (holder instanceof TagInfoViewHolder) {
              TagInfoViewHolder tagHolder = (TagInfoViewHolder) holder;
              tagHolder.mTagInfoView.setCurrentTag(mCurrentTag);
          } else if (holder instanceof TagToolbarViewHolder) {
              TagToolbarViewHolder toolbarHolder = (TagToolbarViewHolder) holder;
              toolbarHolder.mTagToolbar.setCurrentTag(mCurrentTag);
              toolbarHolder.mTagToolbar.setOnTagChangedListener(mOnTagChangedListener);
          } else if (holder instanceof GapMarkerViewHolder) {
              GapMarkerViewHolder gapHolder = (GapMarkerViewHolder) holder;
              gapHolder.mGapMarkerView.setCurrentTag(mCurrentTag);
          }
      }
  
      private void renderXPost(int position, ReaderXPostViewHolder holder) {
          final ReaderPost post = getItem(position);
  
          if (post.hasPostAvatar()) {
              holder.imgAvatar.setImageUrl(
                      post.getPostAvatarForDisplay(mAvatarSzSmall), WPNetworkImageView.ImageType.AVATAR);
          } else {
              holder.imgAvatar.showDefaultGravatarImage();
          }
  
          if (post.hasBlogUrl()) {
              holder.imgBlavatar.setImageUrl(
                      post.getPostBlavatarForDisplay(mAvatarSzMedium), WPNetworkImageView.ImageType.BLAVATAR);
          } else {
              holder.imgBlavatar.showDefaultBlavatarImage();
          }
  
          holder.txtTitle.setText(ReaderXPostUtils.getXPostTitle(post));
          holder.txtSubtitle.setText(ReaderXPostUtils.getXPostSubtitleHtml(post));
  
          holder.cardView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (mPostSelectedListener != null) {
                      mPostSelectedListener.onPostSelected(post);
                  }
              }
          });
  
          checkLoadMore(position);
      }
  
      private void renderPost(final int position, ReaderPostViewHolder holder) {
          final ReaderPost post = getItem(position);
          ReaderTypes.ReaderPostListType postListType = getPostListType();
  
          holder.txtTitle.setText(post.getTitle());
  
          // dateline includes author name if different than blog name
          String dateLine;
          if (post.hasAuthorName() && !post.getAuthorName().equalsIgnoreCase(post.getBlogName())) {
              dateLine = post.getAuthorName() + " \u2022 " + DateTimeUtils.javaDateToTimeSpan(post.getDatePublished());
          } else {
              dateLine = DateTimeUtils.javaDateToTimeSpan(post.getDatePublished());
          }
          holder.txtDate.setText(dateLine);
  
          if (post.hasBlogUrl()) {
              String imageUrl = GravatarUtils.blavatarFromUrl(post.getUrl(), mAvatarSzMedium);
              holder.imgAvatar.setImageUrl(imageUrl, WPNetworkImageView.ImageType.BLAVATAR);
          } else {
              holder.imgAvatar.setImageUrl(post.getPostAvatarForDisplay(mAvatarSzMedium), WPNetworkImageView.ImageType.AVATAR);
          }
          if (post.hasBlogName()) {
              holder.txtBlogName.setText(post.getBlogName());
          } else if (post.hasAuthorName()) {
              holder.txtBlogName.setText(post.getAuthorName());
          } else {
              holder.txtBlogName.setText(null);
          }
  
          // show blog preview when post header is tapped unless this already is blog preview
          if (!isBlogPreview()) {
              holder.layoutPostHeader.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      ReaderActivityLauncher.showReaderBlogPreview(view.getContext(), post);
                  }
              });
          }
  
          if (post.hasExcerpt()) {
              holder.txtText.setVisibility(View.VISIBLE);
              holder.txtText.setText(post.getExcerpt());
          } else {
              holder.txtText.setVisibility(View.GONE);
          }
  
          final int titleMargin;
          if (post.hasFeaturedImage()) {
              final String imageUrl = post.getFeaturedImageForDisplay(mPhotonWidth, mPhotonHeight);
              holder.imgFeatured.setImageUrl(imageUrl, WPNetworkImageView.ImageType.PHOTO);
              holder.imgFeatured.setVisibility(View.VISIBLE);
              titleMargin = mMarginLarge;
          } else if (post.hasFeaturedVideo() && WPNetworkImageView.canShowVideoThumbnail(post.getFeaturedVideo())) {
              holder.imgFeatured.setVideoUrl(post.postId, post.getFeaturedVideo());
              holder.imgFeatured.setVisibility(View.VISIBLE);
              titleMargin = mMarginLarge;
          } else {
              holder.imgFeatured.setVisibility(View.GONE);
              titleMargin = (holder.layoutPostHeader.getVisibility() == View.VISIBLE ? 0 : mMarginLarge);
          }
  
          // set the top margin of the title based on whether there's a featured image and post header
          LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.txtTitle.getLayoutParams();
          params.topMargin = titleMargin;
  
          // show word count when appropriate, include reading time if at least two minutes
          if (post.wordCount > 0 && !post.isDiscoverPost()) {
              String wordCountStr = String.format(mWordCountFmtStr, post.wordCount);
              int readingTimeInMinutes = post.wordCount / READING_WORDS_PER_MINUTE;
              if (readingTimeInMinutes >= MIN_READING_TIME_MINUTES) {
                  wordCountStr += " (~" + String.format(mReadingTimeFmtStr, readingTimeInMinutes) + ")";
              }
              holder.txtWordCount.setText(wordCountStr);
              holder.txtWordCount.setVisibility(View.VISIBLE);
          } else {
              holder.txtWordCount.setVisibility(View.GONE);
          }
  
          // show the best tag for this post
          final String tagToDisplay = (mCurrentTag != null ? post.getTagForDisplay(mCurrentTag.getTagName()) : null);
          if (!TextUtils.isEmpty(tagToDisplay)) {
              holder.txtTag.setText(ReaderUtils.makeHashTag(tagToDisplay));
              holder.txtTag.setVisibility(View.VISIBLE);
              holder.txtTag.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      if (mOnTagSelectedListener != null) {
                          mOnTagSelectedListener.onTagSelected(tagToDisplay);
                      }
                  }
              });
          } else {
              holder.txtTag.setVisibility(View.GONE);
              holder.txtTag.setOnClickListener(null);
          }
  
          showLikes(holder, post);
          showComments(holder, post);
  
          // more menu only shows for followed tags
          if (!mIsLoggedOutReader && postListType == ReaderTypes.ReaderPostListType.TAG_FOLLOWED) {
              holder.imgMore.setVisibility(View.VISIBLE);
              holder.imgMore.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      if (mOnPostPopupListener != null) {
                          mOnPostPopupListener.onShowPostPopup(view, post);
                      }
                  }
              });
          } else {
              holder.imgMore.setVisibility(View.GONE);
              holder.imgMore.setOnClickListener(null);
          }
  
          // attribution section for discover posts
          if (post.isDiscoverPost()) {
              showDiscoverData(holder, post);
          } else {
              holder.layoutDiscover.setVisibility(View.GONE);
          }
  
          holder.cardView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (mPostSelectedListener != null) {
                      mPostSelectedListener.onPostSelected(post);
                  }
              }
          });
  
          checkLoadMore(position);
      }
  
      /*
       * if we're nearing the end of the posts, fire request to load more
       */
      private void checkLoadMore(int position) {
          if (mCanRequestMorePosts
                  && mDataRequestedListener != null
                  && (position >= getItemCount() - 1)) {
              mDataRequestedListener.onRequestData();
          }
      }
  
      private void showDiscoverData(final ReaderPostViewHolder postHolder,
                                    final ReaderPost post) {
          final ReaderPostDiscoverData discoverData = post.getDiscoverData();
          if (discoverData == null) {
              postHolder.layoutDiscover.setVisibility(View.GONE);
              return;
          }
  
          postHolder.layoutDiscover.setVisibility(View.VISIBLE);
          postHolder.txtDiscover.setText(discoverData.getAttributionHtml());
  
          switch (discoverData.getDiscoverType()) {
              case EDITOR_PICK:
  