Search in sources :

Example 1 with AdvertisingType

use of com.my.targetDemoApp.models.AdvertisingType in project mytarget-android by myTargetSDK.

the class MainActivity method initGrid.

private void initGrid() {
    AdvertisingType defaultAd = new AdvertisingType(AdTypes.AD_TYPE_320X50, 0);
    defaultAd.setName(getString(R.string.standard_banners));
    defaultAd.setImageResource(R.drawable.img_banners);
    defaultAd.setDescription(getString(R.string.standard_banners_desc));
    AdvertisingType interstitialAd = new AdvertisingType(AD_TYPE_FULLSCREEN, 0);
    interstitialAd.setName(getString(R.string.interstitial_ads));
    interstitialAd.setImageResource(R.drawable.img_interstitials);
    interstitialAd.setDescription(getString(R.string.interstitial_ads_desc));
    AdvertisingType nativeAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, 0);
    nativeAd.setName(getString(R.string.native_ads));
    nativeAd.setImageResource(R.drawable.img_native);
    nativeAd.setDescription(getString(R.string.native_ads_desc));
    AdvertisingType instreamAd = new AdvertisingType(AdTypes.AD_TYPE_INSTREAM, DefaultSlots.MIDROLL);
    instreamAd.setName(getString(R.string.instream_ads));
    instreamAd.setImageResource(R.drawable.img_instream);
    instreamAd.setDescription(getString(R.string.instream_ads_desc));
    typeList = new ArrayList<>();
    typeList.add(defaultAd);
    typeList.add(interstitialAd);
    typeList.add(nativeAd);
    typeList.add(instreamAd);
    typeList.addAll(getSavedTypes());
    RecyclerView.ItemAnimator itemAnimator = new DefaultItemAnimator();
    itemAnimator.setAddDuration(300);
    itemAnimator.setRemoveDuration(300);
    recyclerView.setItemAnimator(itemAnimator);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), getResources().getInteger(R.integer.grid_coloumns));
    recyclerView.setLayoutManager(gridLayoutManager);
    adapter = new MainAdapter(typeList);
    recyclerView.setAdapter(adapter);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) AdvertisingType(com.my.targetDemoApp.models.AdvertisingType) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 2 with AdvertisingType

use of com.my.targetDemoApp.models.AdvertisingType in project mytarget-android by myTargetSDK.

the class MainActivity method getSavedTypes.

private ArrayList<AdvertisingType> getSavedTypes() {
    ArrayList<AdvertisingType> advertisingTypes = new ArrayList<>();
    Set<String> set = sharedPreferences.getStringSet(KEY_STRING_SET, new HashSet<String>());
    for (String s : set) {
        String[] sar = TextUtils.split(s, ":");
        AdvertisingType advertisingType = new AdvertisingType(sar[0], sar[1]);
        advertisingTypes.add(advertisingType);
    }
    return advertisingTypes;
}
Also used : ArrayList(java.util.ArrayList) AdvertisingType(com.my.targetDemoApp.models.AdvertisingType)

Example 3 with AdvertisingType

use of com.my.targetDemoApp.models.AdvertisingType in project mytarget-android by myTargetSDK.

the class AdActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getIntent() != null) {
        AdvertisingType advertisingType = getIntent().getParcelableExtra(MainActivity.AD_TYPE_TAG);
        if (advertisingType != null) {
            slotId = advertisingType.getSlotId();
            adType = advertisingType.getAdType();
        }
    }
}
Also used : AdvertisingType(com.my.targetDemoApp.models.AdvertisingType)

Example 4 with AdvertisingType

use of com.my.targetDemoApp.models.AdvertisingType in project mytarget-android by myTargetSDK.

the class InterstitialAdActivity method initAds.

private void initAds() {
    typeList = new ArrayList<>();
    AdvertisingType promoAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_PROMO_AD);
    promoAd.setName(getResources().getString(R.string.interstitial_promo));
    promoAd.setImageResource(R.drawable.img_fullscreen_promo);
    promoAd.setDescription(getString(R.string.interstitial_promo_desc));
    InterstitialAd interstitialAd = new InterstitialAd(DefaultSlots.SLOT_PROMO_AD, this);
    Tools.fillCustomParamsUserData(interstitialAd.getCustomParams());
    interstitialAds.add(PROMO_AD, interstitialAd);
    AdvertisingType videoAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_PROMO_VIDEO_AD);
    videoAd.setName(getResources().getString(R.string.interstitial_video));
    videoAd.setImageResource(R.drawable.img_fullscreen_video);
    videoAd.setDescription(getString(R.string.interstitial_video_desc));
    InterstitialAd interstitialVideoAd = new InterstitialAd(DefaultSlots.SLOT_PROMO_VIDEO_AD, this);
    Tools.fillCustomParamsUserData(interstitialVideoAd.getCustomParams());
    interstitialAds.add(VIDEO_AD, interstitialVideoAd);
    AdvertisingType imageAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_IMAGE_AD);
    imageAd.setName(getResources().getString(R.string.interstitial_image));
    imageAd.setImageResource(R.drawable.img_fullscreen_image);
    imageAd.setDescription(getString(R.string.interstitial_image_desc));
    InterstitialAd interstitialImageAd = new InterstitialAd(DefaultSlots.SLOT_IMAGE_AD, this);
    Tools.fillCustomParamsUserData(interstitialImageAd.getCustomParams());
    interstitialAds.add(IMAGE_AD, interstitialImageAd);
    AdvertisingType videoStyleAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_PROMO_VIDEO_STYLE_AD);
    videoStyleAd.setName(getResources().getString(R.string.interstitial_video_style));
    videoStyleAd.setImageResource(R.drawable.img_fullscreen_promo_style);
    videoStyleAd.setDescription(getString(R.string.interstitial_video_style_desc));
    InterstitialAd interstitialVideoStyleAd = new InterstitialAd(DefaultSlots.SLOT_PROMO_VIDEO_STYLE_AD, this);
    Tools.fillCustomParamsUserData(interstitialVideoStyleAd.getCustomParams());
    interstitialAds.add(VIDEO_AD_STYLE, interstitialVideoStyleAd);
    typeList.add(PROMO_AD, promoAd);
    typeList.add(VIDEO_AD, videoAd);
    typeList.add(IMAGE_AD, imageAd);
    typeList.add(VIDEO_AD_STYLE, videoStyleAd);
    adapter = new InterstitialListAdapter(typeList);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), getResources().getInteger(R.integer.grid_coloumns));
    recyclerView.setLayoutManager(gridLayoutManager);
    recyclerView.setAdapter(adapter);
    for (InterstitialAd ad : interstitialAds) {
        ad.setListener(adListener);
        ad.load();
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) InterstitialAd(com.my.target.ads.InterstitialAd) AdvertisingType(com.my.targetDemoApp.models.AdvertisingType)

Example 5 with AdvertisingType

use of com.my.targetDemoApp.models.AdvertisingType in project mytarget-android by myTargetSDK.

the class StandardBannerAdActivity method initAds.

private void initAds() {
    if (slotId == 0 || adType == AdTypes.AD_TYPE_320X50) {
        int slotId320x50 = slotId == 0 ? DefaultSlots.SLOT_STANDARD_BANNER_320x50 : slotId;
        AdvertisingType standard320x50 = new AdvertisingType(AdTypes.AD_TYPE_320X50, slotId320x50);
        standard320x50.setName(getResources().getString(R.string.standard_banner_320x50));
        fragment320x50 = Standard320x50BannerFragment.newInstance(slotId320x50);
        typeList.add(standard320x50);
        if (fragment320x50 != null) {
            fragment320x50.show();
        }
    }
    if (slotId == 0 || adType == AdTypes.AD_TYPE_300X250) {
        int slotId300x250 = slotId == 0 ? DefaultSlots.SLOT_STANDARD_BANNER_300x250 : slotId;
        AdvertisingType standard300x250 = new AdvertisingType(AdTypes.AD_TYPE_300X250, slotId300x250);
        standard300x250.setName(getResources().getString(R.string.standard_banner_300x250));
        fragment300x250 = Standard300x250BannerFragment.newInstance(slotId300x250);
        typeList.add(standard300x250);
        if (fragment300x250 != null) {
            fragment300x250.show();
        }
    }
    if (slotId == 0 || adType == AdTypes.AD_TYPE_728X90) {
        int slotId728x90 = slotId == 0 ? DefaultSlots.SLOT_STANDARD_BANNER_728x90 : slotId;
        AdvertisingType standard728x90 = new AdvertisingType(AdTypes.AD_TYPE_728X90, slotId728x90);
        standard728x90.setName(getResources().getString(R.string.standard_banner_728x90));
        fragment728x90 = Standard728x90BannerFragment.newInstance(slotId728x90);
        typeList.add(standard728x90);
        if (fragment728x90 != null) {
            fragment728x90.show();
        }
    }
    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), typeList);
    viewPager.setAdapter(pagerAdapter);
    viewPager.addOnPageChangeListener(this);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : AdvertisingType(com.my.targetDemoApp.models.AdvertisingType) FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter)

Aggregations

AdvertisingType (com.my.targetDemoApp.models.AdvertisingType)8 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 Bundle (android.os.Bundle)1 Tab (android.support.design.widget.TabLayout.Tab)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 RecyclerView (android.support.v7.widget.RecyclerView)1 InterstitialAd (com.my.target.ads.InterstitialAd)1 FeedAdapter (com.my.targetDemoApp.adapters.FeedAdapter)1 ArrayList (java.util.ArrayList)1