@Test public void onReceive_whenActionInterstitialShow_shouldNotifyListener() throws Exception { Intent intent = getIntentForActionAndIdentifier(ACTION_INTERSTITIAL_SHOW, broadcastIdentifier); subject.onReceive(context, intent); verify(customEventInterstitialListener).onInterstitialShown(); }
@Override public void onReceive(Context context, Intent intent) { if (mCustomEventInterstitialListener == null) { return; } final long receivedIdentifier = intent.getLongExtra(DataKeys.BROADCAST_IDENTIFIER_KEY, -1); if (mBroadcastIdentifier != receivedIdentifier) { return; } final String action = intent.getAction(); if (ACTION_INTERSTITIAL_FAIL.equals(action)) { mCustomEventInterstitialListener.onInterstitialFailed(NETWORK_INVALID_STATE); } else if (ACTION_INTERSTITIAL_SHOW.equals(action)) { mCustomEventInterstitialListener.onInterstitialShown(); } else if (ACTION_INTERSTITIAL_DISMISS.equals(action)) { mCustomEventInterstitialListener.onInterstitialDismissed(); unregister(); } else if (ACTION_INTERSTITIAL_CLICK.equals(action)) { mCustomEventInterstitialListener.onInterstitialClicked(); } }
EventForwardingBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (mCustomEventInterstitialListener == null) { return; } final long receivedIdentifier = intent.getLongExtra(DataKeys.BROADCAST_IDENTIFIER_KEY, -1); if (mBroadcastIdentifier != receivedIdentifier) { return; } final String action = intent.getAction(); if (ACTION_INTERSTITIAL_FAIL.equals(action)) { mCustomEventInterstitialListener.onInterstitialFailed(NETWORK_INVALID_STATE); } else if (ACTION_INTERSTITIAL_SHOW.equals(action)) { mCustomEventInterstitialListener.onInterstitialShown(); } else if (ACTION_INTERSTITIAL_DISMISS.equals(action)) { mCustomEventInterstitialListener.onInterstitialDismissed(); unregister(); } else if (ACTION_INTERSTITIAL_CLICK.equals(action)) { mCustomEventInterstitialListener.onInterstitialClicked(); } } }
EventForwardingBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (mCustomEventInterstitialListener == null) { return; } final long receivedIdentifier = intent.getLongExtra(DataKeys.BROADCAST_IDENTIFIER_KEY, -1); if (mBroadcastIdentifier != receivedIdentifier) { return; } final String action = intent.getAction(); if (ACTION_INTERSTITIAL_FAIL.equals(action)) { mCustomEventInterstitialListener.onInterstitialFailed(NETWORK_INVALID_STATE); } else if (ACTION_INTERSTITIAL_SHOW.equals(action)) { mCustomEventInterstitialListener.onInterstitialShown(); } else if (ACTION_INTERSTITIAL_DISMISS.equals(action)) { mCustomEventInterstitialListener.onInterstitialDismissed(); unregister(); } else if (ACTION_INTERSTITIAL_CLICK.equals(action)) { mCustomEventInterstitialListener.onInterstitialClicked(); } } EventForwardingBroadcastReceiver(CustomEventInterstitialListener customEventInterstitialListener, final long broadcastIdentifier); }
EventForwardingBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (mCustomEventInterstitialListener == null) { return; } final long receivedIdentifier = intent.getLongExtra(DataKeys.BROADCAST_IDENTIFIER_KEY, -1); if (mBroadcastIdentifier != receivedIdentifier) { return; } final String action = intent.getAction(); if (ACTION_INTERSTITIAL_FAIL.equals(action)) { mCustomEventInterstitialListener.onInterstitialFailed(NETWORK_INVALID_STATE); } else if (ACTION_INTERSTITIAL_SHOW.equals(action)) { mCustomEventInterstitialListener.onInterstitialShown(); } else if (ACTION_INTERSTITIAL_DISMISS.equals(action)) { mCustomEventInterstitialListener.onInterstitialDismissed(); unregister(); } else if (ACTION_INTERSTITIAL_CLICK.equals(action)) { mCustomEventInterstitialListener.onInterstitialClicked(); } } EventForwardingBroadcastReceiver(CustomEventInterstitialListener customEventInterstitialListener, final long broadcastIdentifier); static IntentFilter getHtmlInterstitialIntentFilter(); @Override void onReceive(Context context, Intent intent); void register(Context context); void unregister(); }
EventForwardingBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (mCustomEventInterstitialListener == null) { return; } final long receivedIdentifier = intent.getLongExtra(DataKeys.BROADCAST_IDENTIFIER_KEY, -1); if (mBroadcastIdentifier != receivedIdentifier) { return; } final String action = intent.getAction(); if (ACTION_INTERSTITIAL_FAIL.equals(action)) { mCustomEventInterstitialListener.onInterstitialFailed(NETWORK_INVALID_STATE); } else if (ACTION_INTERSTITIAL_SHOW.equals(action)) { mCustomEventInterstitialListener.onInterstitialShown(); } else if (ACTION_INTERSTITIAL_DISMISS.equals(action)) { mCustomEventInterstitialListener.onInterstitialDismissed(); unregister(); } else if (ACTION_INTERSTITIAL_CLICK.equals(action)) { mCustomEventInterstitialListener.onInterstitialClicked(); } } EventForwardingBroadcastReceiver(CustomEventInterstitialListener customEventInterstitialListener, final long broadcastIdentifier); static IntentFilter getHtmlInterstitialIntentFilter(); @Override void onReceive(Context context, Intent intent); void register(Context context); void unregister(); static final String ACTION_INTERSTITIAL_FAIL; static final String ACTION_INTERSTITIAL_SHOW; static final String ACTION_INTERSTITIAL_DISMISS; static final String ACTION_INTERSTITIAL_CLICK; }