@Test public void loadPositionsTwice_shouldCancelPreviousRequest_shouldNotCallListener() { subject.loadPositions("test_ad_unit", mockPositioningListener); subject.loadPositions("test_ad_unit", mockPositioningListener); verify(mockRequestQueue, times(2)).add(any(Request.class)); verify(mockPositioningListener, never()).onFailed(); verify(mockPositioningListener, never()).onLoad(any(MoPubClientPositioning.class)); }
@Override public void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener) { if (mRequest != null) { mRequest.cancel(); mRequest = null; } if (mRetryCount > 0) { mRetryHandler.removeCallbacks(mRetryRunnable); mRetryCount = 0; } mListener = listener; mRetryUrl = new PositioningUrlGenerator(mContext) .withAdUnitId(adUnitId) .generateUrlString(Constants.HOST); requestPositioningInternal(); }
ServerPositioningSource implements PositioningSource { @Override public void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener) { if (mRequest != null) { mRequest.cancel(); mRequest = null; } if (mRetryCount > 0) { mRetryHandler.removeCallbacks(mRetryRunnable); mRetryCount = 0; } mListener = listener; mRetryUrl = new PositioningUrlGenerator(mContext) .withAdUnitId(adUnitId) .generateUrlString(Constants.HOST); requestPositioningInternal(); } }
ServerPositioningSource implements PositioningSource { @Override public void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener) { if (mRequest != null) { mRequest.cancel(); mRequest = null; } if (mRetryCount > 0) { mRetryHandler.removeCallbacks(mRetryRunnable); mRetryCount = 0; } mListener = listener; mRetryUrl = new PositioningUrlGenerator(mContext) .withAdUnitId(adUnitId) .generateUrlString(Constants.HOST); requestPositioningInternal(); } ServerPositioningSource(@NonNull final Context context); }
ServerPositioningSource implements PositioningSource { @Override public void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener) { if (mRequest != null) { mRequest.cancel(); mRequest = null; } if (mRetryCount > 0) { mRetryHandler.removeCallbacks(mRetryRunnable); mRetryCount = 0; } mListener = listener; mRetryUrl = new PositioningUrlGenerator(mContext) .withAdUnitId(adUnitId) .generateUrlString(Constants.HOST); requestPositioningInternal(); } ServerPositioningSource(@NonNull final Context context); @Override void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener); }
ServerPositioningSource implements PositioningSource { @Override public void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener) { if (mRequest != null) { mRequest.cancel(); mRequest = null; } if (mRetryCount > 0) { mRetryHandler.removeCallbacks(mRetryRunnable); mRetryCount = 0; } mListener = listener; mRetryUrl = new PositioningUrlGenerator(mContext) .withAdUnitId(adUnitId) .generateUrlString(Constants.HOST); requestPositioningInternal(); } ServerPositioningSource(@NonNull final Context context); @Override void loadPositions(@NonNull String adUnitId, @NonNull PositioningListener listener);  }