Search in sources :

Example 1 with MoPubInterstitial

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();
}
Also used : MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial)

Example 2 with MoPubInterstitial

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();
        }
    }
}
Also used : MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial)

Example 3 with MoPubInterstitial

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);
    }
}
Also used : MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial)

Example 4 with MoPubInterstitial

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;
}
Also used : Context(android.content.Context) MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Example 5 with MoPubInterstitial

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());
}
Also used : MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial) HashMap(java.util.HashMap) MoPubInterstitialMediationUtils(com.mopub.mediation.MoPubInterstitialMediationUtils) Test(org.junit.Test)

Aggregations

MoPubInterstitial (com.mopub.mobileads.MoPubInterstitial)15 MoPubView (com.mopub.mobileads.MoPubView)5 MoPubErrorCode (com.mopub.mobileads.MoPubErrorCode)4 Test (org.junit.Test)4 InterstitialAdUnit (org.prebid.mobile.InterstitialAdUnit)4 FrameLayout (android.widget.FrameLayout)3 HashMap (java.util.HashMap)3 OnCompleteListener (org.prebid.mobile.OnCompleteListener)3 ResultCode (org.prebid.mobile.ResultCode)3 View (android.view.View)2 PublisherAdRequest (com.google.android.gms.ads.doubleclick.PublisherAdRequest)2 PublisherAdView (com.google.android.gms.ads.doubleclick.PublisherAdView)2 PublisherInterstitialAd (com.google.android.gms.ads.doubleclick.PublisherInterstitialAd)2 AdUnit (org.prebid.mobile.AdUnit)2 BannerAdUnit (org.prebid.mobile.BannerAdUnit)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Uri (android.net.Uri)1 Nullable (android.support.annotation.Nullable)1 TextUtils (android.text.TextUtils)1