use of com.mopub.mobileads.MoPubInterstitial in project frostwire by frostwire.
the class MoPubAdNetwork method showInterstitial.
@Override
public boolean showInterstitial(Activity activity, String placement, boolean shutdownActivityAfterwards, boolean dismissActivityAfterward) {
if (interstitials == null || interstitials.isEmpty()) {
return false;
}
MoPubInterstitial interstitial = interstitials.get(placement);
MoPubInterstitialListener listener = (MoPubInterstitialListener) interstitial.getInterstitialAdListener();
if (listener != null) {
listener.shutdownAppAfter(shutdownActivityAfterwards);
listener.dismissActivityAfterwards(dismissActivityAfterward);
}
return listener != null && interstitial.isReady() && interstitial.show();
}
use of com.mopub.mobileads.MoPubInterstitial in project frostwire by frostwire.
the class MoPubAdNetwork method stop.
@Override
public void stop(Context context) {
super.stop(context);
if (placements == null || interstitials == null || placements.isEmpty() || interstitials.isEmpty()) {
return;
}
Set<String> placementKeys = placements.keySet();
for (String key : placementKeys) {
MoPubInterstitial interstitial = interstitials.get(key);
if (interstitial != null) {
interstitial.destroy();
}
}
}
use of com.mopub.mobileads.MoPubInterstitial in project frostwire by frostwire.
the class MoPubAdNetwork method loadMoPubInterstitial.
public void loadMoPubInterstitial(final Activity activity, final String placement) {
if (activity == null) {
LOG.info("Aborted loading interstitial (" + placement + "), no Activity");
return;
}
if (!started() || !enabled()) {
LOG.info("loadMoPubInterstitial(placement=" + placement + ") aborted. Network not started or not enabled");
return;
}
LOG.info("Loading " + placement + " interstitial");
try {
final MoPubInterstitial moPubInterstitial = new MoPubInterstitial(activity, placements.get(placement));
MoPubInterstitialListener moPubListener = new MoPubInterstitialListener(this, placement);
moPubInterstitial.setInterstitialAdListener(moPubListener);
interstitials.put(placement, moPubInterstitial);
moPubInterstitial.load();
} catch (Throwable e) {
LOG.warn("Mopub Interstitial couldn't be loaded", e);
}
}
use of com.mopub.mobileads.MoPubInterstitial in project mopub-android-mediation by mopub.
the class InterstitialDetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
final MoPubSampleAdUnit adConfiguration = MoPubSampleAdUnit.fromBundle(getArguments());
final View view = inflater.inflate(R.layout.interstitial_detail_fragment, container, false);
final DetailFragmentViewHolder views = DetailFragmentViewHolder.fromView(view);
views.mKeywordsField.setText(getArguments().getString(MoPubListFragment.KEYWORDS_KEY, ""));
views.mUserDataKeywordsField.setText(getArguments().getString(MoPubListFragment.USER_DATA_KEYWORDS_KEY, ""));
hideSoftKeyboard(views.mUserDataKeywordsField);
final String adUnitId = adConfiguration.getAdUnitId();
views.mDescriptionView.setText(adConfiguration.getDescription());
views.mAdUnitIdView.setText(adUnitId);
views.mLoadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mShowButton.setEnabled(false);
if (mMoPubInterstitial == null) {
mMoPubInterstitial = new MoPubInterstitial(getActivity(), adUnitId);
mMoPubInterstitial.setInterstitialAdListener(InterstitialDetailFragment.this);
}
final String keywords = views.mKeywordsField.getText().toString();
final String userDatakeywords = views.mUserDataKeywordsField.getText().toString();
mMoPubInterstitial.setKeywords(keywords);
mMoPubInterstitial.setUserDataKeywords(userDatakeywords);
if (mCallbacksAdapter != null) {
mCallbacksAdapter.generateCallbackList(InterstitialCallbacks.class);
}
mMoPubInterstitial.load();
}
});
mShowButton = views.mShowButton;
mShowButton.setEnabled(false);
mShowButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mMoPubInterstitial.show();
}
});
final RecyclerView callbacksView = view.findViewById(R.id.callbacks_recycler_view);
final Context context = getContext();
if (callbacksView != null && context != null) {
callbacksView.setLayoutManager(new LinearLayoutManager(context));
mCallbacksAdapter = new CallbacksAdapter(context);
mCallbacksAdapter.generateCallbackList(InterstitialCallbacks.class);
callbacksView.setAdapter(mCallbacksAdapter);
}
return view;
}
use of com.mopub.mobileads.MoPubInterstitial in project prebid-mobile-android by prebid.
the class KeywordsSetupTest method handleMoPubKeywordsUpdateWithInterstitial_KeyWordsShouldMatchExpected.
@Test
public void handleMoPubKeywordsUpdateWithInterstitial_KeyWordsShouldMatchExpected() {
MoPubInterstitial moPubInterstitial = new MoPubInterstitial(mActivity, "123456");
MoPubInterstitialMediationUtils mediationUtils = new MoPubInterstitialMediationUtils(moPubInterstitial);
HashMap<String, String> bids = new HashMap<>();
bids.put("hb_pb", "0.50");
bids.put("hb_cache_id", "123456");
moPubInterstitial.setKeywords("key1:value1,key2:value2");
mediationUtils.handleKeywordsUpdate(bids);
assertEquals("hb_pb:0.50,hb_cache_id:123456,key1:value1,key2:value2", moPubInterstitial.getKeywords());
mediationUtils.handleKeywordsUpdate(null);
assertEquals("key1:value1,key2:value2", moPubInterstitial.getKeywords());
}
Aggregations