Search in sources :

Example 6 with AdvertisingType

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

the class FeedFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Bundle args = getArguments();
    AdvertisingType advertisingType = args.getParcelable(ARG_KEY);
    listView = (ListView) view.findViewById(R.id.list_view);
    if (advertisingType != null) {
        feedAdapter = new FeedAdapter(advertisingType, view.getContext());
        listView.setAdapter(feedAdapter);
    }
}
Also used : Bundle(android.os.Bundle) AdvertisingType(com.my.targetDemoApp.models.AdvertisingType) FeedAdapter(com.my.targetDemoApp.adapters.FeedAdapter)

Example 7 with AdvertisingType

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

the class MainActivity method onSaveType.

@Override
public void onSaveType(int adType, int slotId) {
    Set<String> set = sharedPreferences.getStringSet(KEY_STRING_SET, new HashSet<String>());
    set.add(adType + ":" + slotId);
    sharedPreferences.edit().remove(KEY_STRING_SET).apply();
    sharedPreferences.edit().putStringSet(KEY_STRING_SET, set).apply();
    AdvertisingType newType = new AdvertisingType(adType, slotId);
    typeList.add(newType);
    adapter.notifyItemInserted(typeList.size() - 1);
}
Also used : AdvertisingType(com.my.targetDemoApp.models.AdvertisingType)

Example 8 with AdvertisingType

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

the class NativeAdFragment method initAds.

private void initAds() {
    switch(fragmentType) {
        case R.id.action_native_static:
        default:
            int slot = slotId == 0 ? DefaultSlots.CONTENT_STREAM : slotId;
            AdvertisingType contentStream = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, slot);
            contentStream.setName(getResources().getString(R.string.content_stream));
            contentStream.setType(FeedAdapter.Type.CONTENT_STREAM);
            AdvertisingType newsFeed = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, slot);
            newsFeed.setName(getResources().getString(R.string.news_feed));
            newsFeed.setType(FeedAdapter.Type.NEWS_FEED);
            AdvertisingType chatList = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, slot);
            chatList.setName(getResources().getString(R.string.chat_list));
            chatList.setType(FeedAdapter.Type.CHAT_LIST);
            AdvertisingType contentWall = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, slot);
            contentWall.setName(getResources().getString(R.string.content_wall));
            contentWall.setType(FeedAdapter.Type.CONTENT_WALL);
            typeList.add(contentStream);
            typeList.add(newsFeed);
            typeList.add(chatList);
            typeList.add(contentWall);
            break;
        case R.id.action_native_video:
            slot = slotId == 0 ? DefaultSlots.NATIVE_VIDEO : slotId;
            AdvertisingType contentStreamVideo = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, slot);
            contentStreamVideo.setName(getResources().getString(R.string.content_stream_video));
            contentStreamVideo.setType(FeedAdapter.Type.CONTENT_STREAM_VIDEO);
            typeList.add(contentStreamVideo);
            break;
        case R.id.action_native_slider:
            slot = slotId == 0 ? DefaultSlots.NATIVE_SLIDER : slotId;
            AdvertisingType nativeSlider = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, slot);
            nativeSlider.setName(getResources().getString(R.string.native_slider));
            nativeSlider.setType(FeedAdapter.Type.NATIVE_SLIDER);
            typeList.add(nativeSlider);
            break;
    }
    pagerAdapter = new PagerAdapter(getChildFragmentManager(), typeList);
    viewPager.setAdapter(pagerAdapter);
    tabLayout.setupWithViewPager(viewPager);
    final int tabCount = tabLayout.getTabCount();
    for (int i = 0; i < tabCount; i++) {
        final Tab tabAt = tabLayout.getTabAt(i);
        if (tabAt != null) {
            tabAt.setContentDescription(fragmentType + "_tab_" + i);
        }
    }
}
Also used : Tab(android.support.design.widget.TabLayout.Tab) 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