Search in sources :

Example 1 with Tab

use of android.support.design.widget.TabLayout.Tab 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

Tab (android.support.design.widget.TabLayout.Tab)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 AdvertisingType (com.my.targetDemoApp.models.AdvertisingType)1