@Test public void getAdView_withNoAds_returnsNull() { assertThat(subject.getAdView(1, null, null)).isNull(); }
@Nullable public View getAdView(final int position, @Nullable final View convertView, @Nullable final ViewGroup parent) { final NativeAdData adData = mPlacementData.getPlacedAd(position); if (adData == null) { return null; } final MoPubAdRenderer adRenderer = adData.getAdRenderer(); final View view = (convertView != null) ? convertView : adRenderer.createAdView(mContext, parent); NativeResponse nativeResponse = adData.getAd(); WeakReference<View> mappedViewRef = mViewMap.get(nativeResponse); View mappedView = null; if (mappedViewRef != null) { mappedView = mappedViewRef.get(); } if (!view.equals(mappedView)) { clearNativeResponse(mappedView); clearNativeResponse(view); prepareNativeResponse(nativeResponse, view); adRenderer.renderAdView(view, nativeResponse); } return view; }
MoPubStreamAdPlacer { @Nullable public View getAdView(final int position, @Nullable final View convertView, @Nullable final ViewGroup parent) { final NativeAdData adData = mPlacementData.getPlacedAd(position); if (adData == null) { return null; } final MoPubAdRenderer adRenderer = adData.getAdRenderer(); final View view = (convertView != null) ? convertView : adRenderer.createAdView(mContext, parent); NativeResponse nativeResponse = adData.getAd(); WeakReference<View> mappedViewRef = mViewMap.get(nativeResponse); View mappedView = null; if (mappedViewRef != null) { mappedView = mappedViewRef.get(); } if (!view.equals(mappedView)) { clearNativeResponse(mappedView); clearNativeResponse(view); prepareNativeResponse(nativeResponse, view); adRenderer.renderAdView(view, nativeResponse); } return view; } }
MoPubStreamAdPlacer { @Nullable public View getAdView(final int position, @Nullable final View convertView, @Nullable final ViewGroup parent) { final NativeAdData adData = mPlacementData.getPlacedAd(position); if (adData == null) { return null; } final MoPubAdRenderer adRenderer = adData.getAdRenderer(); final View view = (convertView != null) ? convertView : adRenderer.createAdView(mContext, parent); NativeResponse nativeResponse = adData.getAd(); WeakReference<View> mappedViewRef = mViewMap.get(nativeResponse); View mappedView = null; if (mappedViewRef != null) { mappedView = mappedViewRef.get(); } if (!view.equals(mappedView)) { clearNativeResponse(mappedView); clearNativeResponse(view); prepareNativeResponse(nativeResponse, view); adRenderer.renderAdView(view, nativeResponse); } return view; } MoPubStreamAdPlacer(@NonNull final Context context);  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final MoPubServerPositioning adPositioning);  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final MoPubClientPositioning adPositioning); @VisibleForTesting  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final NativeAdSource adSource,
            @NonNull final ImpressionTracker impressionTracker,
            @NonNull final PositioningSource positioningSource); }
MoPubStreamAdPlacer { @Nullable public View getAdView(final int position, @Nullable final View convertView, @Nullable final ViewGroup parent) { final NativeAdData adData = mPlacementData.getPlacedAd(position); if (adData == null) { return null; } final MoPubAdRenderer adRenderer = adData.getAdRenderer(); final View view = (convertView != null) ? convertView : adRenderer.createAdView(mContext, parent); NativeResponse nativeResponse = adData.getAd(); WeakReference<View> mappedViewRef = mViewMap.get(nativeResponse); View mappedView = null; if (mappedViewRef != null) { mappedView = mappedViewRef.get(); } if (!view.equals(mappedView)) { clearNativeResponse(mappedView); clearNativeResponse(view); prepareNativeResponse(nativeResponse, view); adRenderer.renderAdView(view, nativeResponse); } return view; } MoPubStreamAdPlacer(@NonNull final Context context);  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final MoPubServerPositioning adPositioning);  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final MoPubClientPositioning adPositioning); @VisibleForTesting  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final NativeAdSource adSource,
            @NonNull final ImpressionTracker impressionTracker,
            @NonNull final PositioningSource positioningSource); void registerAdRenderer(@NonNull final MoPubAdRenderer adRenderer); void setAdLoadedListener(@Nullable final MoPubNativeAdLoadedListener listener); void loadAds(@NonNull final String adUnitId); void loadAds(@NonNull final String adUnitId,
            @Nullable final RequestParameters requestParameters); void placeAdsInRange(final int startPosition, final int endPosition); boolean isAd(final int position); void clearAds(); void destroy(); @Nullable Object getAdData(final int position); @Nullable View getAdView(final int position, @Nullable final View convertView,
            @Nullable final ViewGroup parent); int removeAdsInRange(int originalStartPosition, int originalEndPosition); int getAdViewTypeCount(); int getAdViewType(final int position); int getOriginalPosition(final int position); int getAdjustedPosition(final int originalPosition); int getOriginalCount(final int count); int getAdjustedCount(final int originalCount); void setItemCount(final int originalCount); void insertItem(final int originalPosition); void removeItem(final int originalPosition); void moveItem(final int originalPosition, final int newPosition); }
MoPubStreamAdPlacer { @Nullable public View getAdView(final int position, @Nullable final View convertView, @Nullable final ViewGroup parent) { final NativeAdData adData = mPlacementData.getPlacedAd(position); if (adData == null) { return null; } final MoPubAdRenderer adRenderer = adData.getAdRenderer(); final View view = (convertView != null) ? convertView : adRenderer.createAdView(mContext, parent); NativeResponse nativeResponse = adData.getAd(); WeakReference<View> mappedViewRef = mViewMap.get(nativeResponse); View mappedView = null; if (mappedViewRef != null) { mappedView = mappedViewRef.get(); } if (!view.equals(mappedView)) { clearNativeResponse(mappedView); clearNativeResponse(view); prepareNativeResponse(nativeResponse, view); adRenderer.renderAdView(view, nativeResponse); } return view; } MoPubStreamAdPlacer(@NonNull final Context context);  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final MoPubServerPositioning adPositioning);  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final MoPubClientPositioning adPositioning); @VisibleForTesting  MoPubStreamAdPlacer(@NonNull final Context context,
            @NonNull final NativeAdSource adSource,
            @NonNull final ImpressionTracker impressionTracker,
            @NonNull final PositioningSource positioningSource); void registerAdRenderer(@NonNull final MoPubAdRenderer adRenderer); void setAdLoadedListener(@Nullable final MoPubNativeAdLoadedListener listener); void loadAds(@NonNull final String adUnitId); void loadAds(@NonNull final String adUnitId,
            @Nullable final RequestParameters requestParameters); void placeAdsInRange(final int startPosition, final int endPosition); boolean isAd(final int position); void clearAds(); void destroy(); @Nullable Object getAdData(final int position); @Nullable View getAdView(final int position, @Nullable final View convertView,
            @Nullable final ViewGroup parent); int removeAdsInRange(int originalStartPosition, int originalEndPosition); int getAdViewTypeCount(); int getAdViewType(final int position); int getOriginalPosition(final int position); int getAdjustedPosition(final int originalPosition); int getOriginalCount(final int count); int getAdjustedCount(final int originalCount); void setItemCount(final int originalCount); void insertItem(final int originalPosition); void removeItem(final int originalPosition); void moveItem(final int originalPosition, final int newPosition); static final int CONTENT_VIEW_TYPE; }