@Test public void setOnItemLongClickListener_withAdPosition_shouldNotCallListener() { subject.setOnItemLongClickListener(mockListView, mockOnItemLongClickListener); ArgumentCaptor<OnItemLongClickListener> listenerCaptor = ArgumentCaptor.forClass(OnItemLongClickListener.class); verify(mockListView).setOnItemLongClickListener(listenerCaptor.capture()); OnItemLongClickListener listener = listenerCaptor.getValue(); listener.onItemLongClick(mockListView, mockItemView, AD_POSITION, 0); verify(mockOnItemLongClickListener, never()).onItemLongClick( any(AdapterView.class), any(View.class), anyInt(), anyInt()); }
public void setOnItemLongClickListener(@NonNull final ListView listView, @Nullable final OnItemLongClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter." + "setOnItemLongClickListener with a null ListView")) { return; } if (listener == null) { listView.setOnItemLongClickListener(null); return; } listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { return isAd(position) || listener.onItemLongClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } }); }
MoPubAdAdapter extends BaseAdapter { public void setOnItemLongClickListener(@NonNull final ListView listView, @Nullable final OnItemLongClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter." + "setOnItemLongClickListener with a null ListView")) { return; } if (listener == null) { listView.setOnItemLongClickListener(null); return; } listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { return isAd(position) || listener.onItemLongClick( adapterView, view, mStreamAdPlacer.getOriginalPosition(position), id); } }); } }
MoPubAdAdapter extends BaseAdapter { public void setOnItemLongClickListener(@NonNull final ListView listView, @Nullable final OnItemLongClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter." + "setOnItemLongClickListener with a null ListView")) { return; } if (listener == null) { listView.setOnItemLongClickListener(null); return; } listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { return isAd(position) || listener.onItemLongClick( 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 setOnItemLongClickListener(@NonNull final ListView listView, @Nullable final OnItemLongClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter." + "setOnItemLongClickListener with a null ListView")) { return; } if (listener == null) { listView.setOnItemLongClickListener(null); return; } listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { return isAd(position) || listener.onItemLongClick( 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 setOnItemLongClickListener(@NonNull final ListView listView, @Nullable final OnItemLongClickListener listener) { if (!NoThrow.checkNotNull(listView, "You called MoPubAdAdapter." + "setOnItemLongClickListener with a null ListView")) { return; } if (listener == null) { listView.setOnItemLongClickListener(null); return; } listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> adapterView, final View view, final int position, final long id) { return isAd(position) || listener.onItemLongClick( 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);  }