Search in sources :

Example 1 with MyTargetView

use of com.my.target.ads.MyTargetView in project mytarget-android by myTargetSDK.

the class BannerAdActivity method initAd.

private void initAd() {
    adView = new MyTargetView(this);
    Tools.fillCustomParamsUserData(adView.getCustomParams());
    adView.init(slotId);
    adView.setListener(adListener);
    float density = getResources().getDisplayMetrics().density;
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (50 * density));
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    adView.setLayoutParams(params);
    layout.addView(adView);
    adView.load();
}
Also used : RelativeLayout(android.widget.RelativeLayout) MyTargetView(com.my.target.ads.MyTargetView)

Example 2 with MyTargetView

use of com.my.target.ads.MyTargetView in project mytarget-android by myTargetSDK.

the class Standard300x250BannerFragment method createView.

private void createView() {
    adView = new MyTargetView(getContext());
    adView.init(slotId, MyTargetView.AdSize.BANNER_300x250);
    Tools.fillCustomParamsUserData(adView.getCustomParams());
    adView.setListener(adListener);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    adView.setLayoutParams(layoutParams);
    adView.load();
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) MyTargetView(com.my.target.ads.MyTargetView)

Example 3 with MyTargetView

use of com.my.target.ads.MyTargetView in project mytarget-android by myTargetSDK.

the class Standard320x50BannerFragment method initAd.

private void initAd() {
    final Context context = getActivity();
    if (context == null) {
        return;
    }
    adView = new MyTargetView(context);
    adView.init(slotId);
    Tools.fillCustomParamsUserData(adView.getCustomParams());
    adView.setListener(adListener);
    float density = getResources().getDisplayMetrics().density;
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (50 * density));
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    adView.setLayoutParams(params);
    layout.addView(adView);
    adView.load();
}
Also used : Context(android.content.Context) RelativeLayout(android.widget.RelativeLayout) MyTargetView(com.my.target.ads.MyTargetView)

Example 4 with MyTargetView

use of com.my.target.ads.MyTargetView in project mytarget-android by myTargetSDK.

the class Standard728x90BannerFragment method initAd.

private void initAd() {
    final Context context = getActivity();
    if (context == null) {
        return;
    }
    adView = new MyTargetView(context);
    adView.init(slotId, MyTargetView.AdSize.BANNER_728x90);
    Tools.fillCustomParamsUserData(adView.getCustomParams());
    adView.setListener(adListener);
    float density = getResources().getDisplayMetrics().density;
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (90 * density));
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    adView.setLayoutParams(params);
    layout.addView(adView);
    adView.load();
}
Also used : Context(android.content.Context) RelativeLayout(android.widget.RelativeLayout) MyTargetView(com.my.target.ads.MyTargetView)

Example 5 with MyTargetView

use of com.my.target.ads.MyTargetView in project mytarget-android by myTargetSDK.

the class MyTargetMopubCustomEventBanner method loadBanner.

@Override
protected void loadBanner(Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> stringObjectMap, Map<String, String> stringStringMap) {
    int slotId;
    if (stringStringMap == null || stringStringMap.size() == 0 || !stringStringMap.containsKey(SLOT_ID_KEY)) {
        Tracer.i("Unable to get slotId from parameter json. Probably Mopub mediation misconfiguration.");
        if (customEventBannerListener != null) {
            customEventBannerListener.onBannerFailed(MoPubErrorCode.NO_FILL);
        }
        return;
    }
    slotId = Integer.parseInt(stringStringMap.get(SLOT_ID_KEY));
    bannerListener = customEventBannerListener;
    if (myTargetView == null) {
        myTargetView = new MyTargetView(context);
        myTargetView.init(slotId, MyTargetView.AdSize.BANNER_320x50, false);
        final CustomParams customParams = myTargetView.getCustomParams();
        if (customParams != null) {
            MopubCustomParamsUtils.fillCustomParams(customParams, stringObjectMap);
        }
        myTargetView.setListener(myTargetViewListener);
    }
    myTargetView.load();
}
Also used : MyTargetView(com.my.target.ads.MyTargetView) CustomParams(com.my.target.common.CustomParams)

Aggregations

MyTargetView (com.my.target.ads.MyTargetView)6 RelativeLayout (android.widget.RelativeLayout)3 Context (android.content.Context)2 LayoutParams (android.view.ViewGroup.LayoutParams)1 LoadListener (com.mopub.mobileads.AdLifecycleListener.LoadListener)1 AdSize (com.my.target.ads.MyTargetView.AdSize)1 CustomParams (com.my.target.common.CustomParams)1