@Test public void setOnItemClickListener_withNonAdPosition_shouldCallListener() { subject.setOnClickListener(mockListView, mockOnItemClickListener); ArgumentCaptor<OnItemClickListener> listenerCaptor = ArgumentCaptor.forClass(OnItemClickListener.class); verify(mockListView).setOnItemClickListener(listenerCaptor.capture()); OnItemClickListener listener = listenerCaptor.getValue(); listener.onItemClick(mockListView, mockItemView, AD_POSITION + 1, 0); verify(mockOnItemClickListener).onItemClick( mockListView, mockItemView, AD_POSITION, 0); }
public void setOnClickListener(@NonNull final ListView listView, @Nullable final OnItemClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter.setOnClickListener with a" + " null ListView")) { return; } if (listener == null) { listView.setOnItemClickListener(null); return; } listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { if (!mStreamAdPlacer.isAd(position)) { listener.onItemClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } } }); }
MoPubAdAdapter extends BaseAdapter { public void setOnClickListener(@NonNull final ListView listView, @Nullable final OnItemClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter.setOnClickListener with a" + " null ListView")) { return; } if (listener == null) { listView.setOnItemClickListener(null); return; } listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { if (!mStreamAdPlacer.isAd(position)) { listener.onItemClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } } }); } }
MoPubAdAdapter extends BaseAdapter { public void setOnClickListener(@NonNull final ListView listView, @Nullable final OnItemClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter.setOnClickListener with a" + " null ListView")) { return; } if (listener == null) { listView.setOnItemClickListener(null); return; } listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { if (!mStreamAdPlacer.isAd(position)) { listener.onItemClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } } }); } MoPubAdAdapter(@NonNull final Context context, @NonNull final Adapter originalAdapter);  MoPubAdAdapter(@NonNull final Context context,
            @NonNull final Adapter originalAdapter,
            @NonNull final MoPubServerPositioning adPositioning);  MoPubAdAdapter(@NonNull final Context context,
            @NonNull final Adapter originalAdapter,
            @NonNull final MoPubClientPositioning adPositioning); @VisibleForTesting  MoPubAdAdapter(@NonNull final MoPubStreamAdPlacer streamAdPlacer,
            @NonNull final Adapter originalAdapter,
            @NonNull final VisibilityTracker visibilityTracker); }
MoPubAdAdapter extends BaseAdapter { public void setOnClickListener(@NonNull final ListView listView, @Nullable final OnItemClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter.setOnClickListener with a" + " null ListView")) { return; } if (listener == null) { listView.setOnItemClickListener(null); return; } listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { if (!mStreamAdPlacer.isAd(position)) { listener.onItemClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } } }); } MoPubAdAdapter(@NonNull final Context context, @NonNull final Adapter originalAdapter);  MoPubAdAdapter(@NonNull final Context context,
            @NonNull final Adapter originalAdapter,
            @NonNull final MoPubServerPositioning adPositioning);  MoPubAdAdapter(@NonNull final Context context,
            @NonNull final Adapter originalAdapter,
            @NonNull final MoPubClientPositioning adPositioning); @VisibleForTesting  MoPubAdAdapter(@NonNull final MoPubStreamAdPlacer streamAdPlacer,
            @NonNull final Adapter originalAdapter,
            @NonNull final VisibilityTracker visibilityTracker); final void registerAdRenderer(@NonNull final MoPubAdRenderer adRenderer); final void setAdLoadedListener(@Nullable final MoPubNativeAdLoadedListener listener); void loadAds(@NonNull final String adUnitId); void loadAds(@NonNull final String adUnitId,
            @Nullable final RequestParameters requestParameters); boolean isAd(final int position); void clearAds(); void destroy(); @Override boolean areAllItemsEnabled(); @Override boolean isEnabled(final int position); @Override int getCount(); @Nullable @Override Object getItem(final int position); @Override long getItemId(final int position); @Override boolean hasStableIds(); @Nullable @Override View getView(final int position, final View view, final ViewGroup viewGroup); @Override int getItemViewType(final int position); @Override int getViewTypeCount(); @Override boolean isEmpty(); int getOriginalPosition(final int position); int getAdjustedPosition(final int originalPosition); void insertItem(final int originalPosition); void removeItem(final int originalPosition); void setOnClickListener(@NonNull final ListView listView,
            @Nullable final OnItemClickListener listener); void setOnItemLongClickListener(@NonNull final ListView listView,
            @Nullable final OnItemLongClickListener listener); void setOnItemSelectedListener(@NonNull final ListView listView,
            @Nullable final OnItemSelectedListener listener); void setSelection(@NonNull final ListView listView, final int originalPosition); void smoothScrollToPosition(@NonNull final ListView listView,
            final int originalPosition); void refreshAds(@NonNull final ListView listView, @NonNull String adUnitId); void refreshAds(@NonNull final ListView listView,
            @NonNull String adUnitId, @Nullable RequestParameters requestParameters); }
MoPubAdAdapter extends BaseAdapter { public void setOnClickListener(@NonNull final ListView listView, @Nullable final OnItemClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter.setOnClickListener with a" + " null ListView")) { return; } if (listener == null) { listView.setOnItemClickListener(null); return; } listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { if (!mStreamAdPlacer.isAd(position)) { listener.onItemClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } } }); } MoPubAdAdapter(@NonNull final Context context, @NonNull final Adapter originalAdapter);  MoPubAdAdapter(@NonNull final Context context,
            @NonNull final Adapter originalAdapter,
            @NonNull final MoPubServerPositioning adPositioning);  MoPubAdAdapter(@NonNull final Context context,
            @NonNull final Adapter originalAdapter,
            @NonNull final MoPubClientPositioning adPositioning); @VisibleForTesting  MoPubAdAdapter(@NonNull final MoPubStreamAdPlacer streamAdPlacer,
            @NonNull final Adapter originalAdapter,
            @NonNull final VisibilityTracker visibilityTracker); final void registerAdRenderer(@NonNull final MoPubAdRenderer adRenderer); final void setAdLoadedListener(@Nullable final MoPubNativeAdLoadedListener listener); void loadAds(@NonNull final String adUnitId); void loadAds(@NonNull final String adUnitId,
            @Nullable final RequestParameters requestParameters); boolean isAd(final int position); void clearAds(); void destroy(); @Override boolean areAllItemsEnabled(); @Override boolean isEnabled(final int position); @Override int getCount(); @Nullable @Override Object getItem(final int position); @Override long getItemId(final int position); @Override boolean hasStableIds(); @Nullable @Override View getView(final int position, final View view, final ViewGroup viewGroup); @Override int getItemViewType(final int position); @Override int getViewTypeCount(); @Override boolean isEmpty(); int getOriginalPosition(final int position); int getAdjustedPosition(final int originalPosition); void insertItem(final int originalPosition); void removeItem(final int originalPosition); void setOnClickListener(@NonNull final ListView listView,
            @Nullable final OnItemClickListener listener); void setOnItemLongClickListener(@NonNull final ListView listView,
            @Nullable final OnItemLongClickListener listener); void setOnItemSelectedListener(@NonNull final ListView listView,
            @Nullable final OnItemSelectedListener listener); void setSelection(@NonNull final ListView listView, final int originalPosition); void smoothScrollToPosition(@NonNull final ListView listView,
            final int originalPosition); void refreshAds(@NonNull final ListView listView, @NonNull String adUnitId); void refreshAds(@NonNull final ListView listView,
            @NonNull String adUnitId, @Nullable RequestParameters requestParameters);  }