com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter Java Examples

The following examples show how to use com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PieActivity.java    From PercentageChartView with Apache License 2.0 6 votes vote down vote up
private void setupLayout() {
    Explode transition = new Explode();
    transition.setDuration(600);
    transition.setInterpolator(new OvershootInterpolator(1f));
    getWindow().setEnterTransition(transition);

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getSupportFragmentManager(), FragmentPagerItems.with(this)
            .add("behavior", BehaviorSubFragment.class,  new Bundler().putBoolean(ORIENTATION_STATE_ARG, true).get())
            .add("progress", ProgressSubFragment.class)
            .add("background", BackgroundSubFragment.class, new Bundler().putBoolean(OFFSET_STATE_ARG, true).get())
            .add("text", TextSubFragment.class)
            .create());

    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(3);
    mTAbs.setViewPager(mViewPager);

    shadowColor = Color.WHITE;
    blur = distX = distY = 2f;
}
 
Example #2
Source File: RingActivity.java    From PercentageChartView with Apache License 2.0 6 votes vote down vote up
private void setupLayout() {
    Explode transition = new Explode();
    transition.setDuration(600);
    transition.setInterpolator(new OvershootInterpolator(1f));
    getWindow().setEnterTransition(transition);

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getSupportFragmentManager(), FragmentPagerItems.with(this)
            .add("behavior", BehaviorSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, true).get())
            .add("progress bar", ProgressSubFragment.class, new Bundler().putBoolean(BAR_STATE_ARG, true).get())
            .add("background bar", BackgroundBarSubFragment.class)
            .add("background", BackgroundSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, false).get())
            .add("text", TextSubFragment.class)
            .create());

    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(4);
    mTAbs.setViewPager(mViewPager);

    shadowColor = Color.WHITE;
    blur = distX = distY = 2f;
}
 
Example #3
Source File: FillActivity.java    From PercentageChartView with Apache License 2.0 6 votes vote down vote up
private void setupLayout() {
    Explode transition = new Explode();
    transition.setDuration(600);
    transition.setInterpolator(new OvershootInterpolator(1f));
    getWindow().setEnterTransition(transition);

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getSupportFragmentManager(), FragmentPagerItems.with(this)
            .add("behavior", BehaviorSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, false).get())
            .add("progress", ProgressSubFragment.class)
            .add("background", BackgroundSubFragment.class, new Bundler().putBoolean(OFFSET_STATE_ARG, true).get())
            .add("text", TextSubFragment.class)
            .create());

    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(3);
    mTAbs.setViewPager(mViewPager);

    shadowColor = Color.WHITE;
    blur = distX = distY = 2f;
}
 
Example #4
Source File: MainActivity.java    From RemoteControlView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ViewPager viewPager = this.findViewById(R.id.viewpager);
    SmartTabLayout viewPagerTab = this.findViewById(R.id.viewpagertab);

    FragmentPagerItems pages = new FragmentPagerItems(this);
    pages.add(FragmentPagerItem.of("功能键", DemoFragment.class));
    pages.add(FragmentPagerItem.of("音量键", DemoFragment1.class));
    pages.add(FragmentPagerItem.of("播放键", DemoFragment.class));
    pages.add(FragmentPagerItem.of("数字键", DemoFragment.class));

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);

    viewPager.setAdapter(adapter);
    viewPagerTab.setViewPager(viewPager);

    remoteControlView = this.findViewById(R.id.rcv);
}
 
Example #5
Source File: PageFragment.java    From ChangeTabLayout with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ViewPager mViewPager = (ViewPager) view.findViewById(R.id.vp);
    FragmentPagerItems pages = new FragmentPagerItems(getActivity());
    final int page = FragmentPagerItem.getPosition(getArguments());

    for (int i = 0; i < 5; i++) {
        Bundle bundle = new Bundle();
        bundle.putInt("page", page);
        bundle.putInt("position", i);
        pages.add(FragmentPagerItem.of(String.valueOf(i), DemoFragment.class, bundle));
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getChildFragmentManager(), pages); //Fragment嵌套Fragment时,要用getChildFragmentManager
    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(2);
    mViewPager.setPageMargin(30);
    final MainActivity mainActivity = (MainActivity) getActivity();
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            mainActivity.pageScrolled(page, position, positionOffset);
        }
    });
}
 
Example #6
Source File: FindDetailActivity.java    From OpenEyes with Apache License 2.0 6 votes vote down vote up
private void setAdapter() {
    final Bundle bundle = new Bundle();
    bundle.putString("name", name);
    viewpagertab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            bundle.putInt("position", position);

        }
    });
    //实例化适配器
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), FragmentPagerItems.with(this)
            .add(FragmentPagerItem.of(TITLE[0], CommonFindFragment.class, bundle))
            .add(FragmentPagerItem.of(TITLE[1], CommonFindFragment.class, bundle))
            .create());
    //设置适配器
    findDetailViewpager.setAdapter(adapter);
    viewpagertab.setViewPager(findDetailViewpager);
}
 
Example #7
Source File: MainActivity.java    From phphub-android with Apache License 2.0 6 votes vote down vote up
protected void setupTabView() {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final int[] tabIcons = {R.drawable.ic_recommended, R.drawable.ic_topics, R.drawable.ic_wiki, R.drawable.ic_me};
    FragmentPagerItems pages = FragmentPagerItems.with(this)
            .add(R.string.recommended, RecommendedFragment.class)
            .add(R.string.topics, TopicsFragment.class)
            .add(R.string.wiki, WikiFragment.class)
            .add(R.string.me, MeFragment.class)
            .create();
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getSupportFragmentManager(),
            pages);

    viewPager.setOffscreenPageLimit(pages.size());
    viewPager.setAdapter(adapter);
    viewpagerTab.setCustomTabView(new SmartTabLayout.TabProvider() {
        @Override
        public View createTabView(ViewGroup container, int position, PagerAdapter pagerAdapter) {
            View view = inflater.inflate(R.layout.custom_tab_icon, container, false);
            ImageView iconView = (ImageView) view.findViewById(R.id.iv_icon);
            iconView.setBackgroundResource(tabIcons[position % tabIcons.length]);
            return view;
        }
    });
    viewpagerTab.setViewPager(viewPager);
}
 
Example #8
Source File: TopicsFragment.java    From phphub-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void lazyLoad() {
    if (!isPrepared || !isVisible || adapterHasCreated) {
        return;
    }

    FragmentPagerItems pages = FragmentPagerItems.with(getActivity())
            .add(R.string.recent, TopicFragment.class, getTopicTypeBundle(TOPIC_TYPE_RECENT))
            .add(R.string.vote, TopicFragment.class, getTopicTypeBundle(TOPIC_TYPE_VOTE))
            .add(R.string.jobs, TopicFragment.class, getTopicTypeBundle(TOPIC_TYPE_JOBS))
            .create();
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getChildFragmentManager(),
            pages);

    viewPager.setOffscreenPageLimit(pages.size());
    viewPager.setAdapter(adapter);
    viewpagerTab.setViewPager(viewPager);

    adapterHasCreated = true;
}
 
Example #9
Source File: MainActivity.java    From ChatApp with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Action bar related

    Toolbar toolbar = findViewById(R.id.main_app_bar);
    toolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("ChatApp");

    // Fragments handler using SmartTabLayout

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
            getSupportFragmentManager(), FragmentPagerItems.with(this)
            .add("Requests", RequestsFragment.class)
            .add("Chat", ChatFragment.class)
            .add("Friends", FriendsFragment.class)
            .create());

    ViewPager viewPager = findViewById(R.id.viewpager);
    viewPager.setAdapter(adapter);
    viewPager.setCurrentItem(1);

    SmartTabLayout viewPagerTab = findViewById(R.id.viewpagertab);
    viewPagerTab.setViewPager(viewPager);
}
 
Example #10
Source File: MainActivity.java    From ChangeTabLayout with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mViewPager = (VerticalViewPager) this.findViewById(R.id.viewpager);
    mTabLayout = (ChangeTabLayout) this.findViewById(R.id.tabLayout);

    pages = new FragmentPagerItems(this);
    mViewPager.setOffscreenPageLimit(title.length);
    for (String titleResId : title) {
        pages.add(FragmentPagerItem.of(titleResId, PageFragment.class));
    }

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
    mViewPager.setAdapter(adapter);
    mTabLayout.setViewPager(mViewPager, icon, null);
    mTabLayout.setOnTabClickListener(new ChangeTabLayout.OnTabClickListener() {
        @Override
        public void onTabClicked(int position) {
            Log.d(TAG, "点击了" + position);
        }
    });

}
 
Example #11
Source File: BaseSmartTabFragment.java    From Dota2Helper with Apache License 2.0 5 votes vote down vote up
@Override
public void initView(View view) {
    FragmentPagerItems.Creator creator = FragmentPagerItems.with(getActivity());
    for (int i = 0, tabCount = getTabCount(); i < tabCount; i++) {
        creator.add(getTabTitle(i), getViewPagerItemFragmentClass());
    }
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getChildFragmentManager(), creator.create());

    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(getTabCount());
    mSmartTabLayout.setViewPager(mViewPager);
}
 
Example #12
Source File: HotFragment.java    From OpenEyes with Apache License 2.0 5 votes vote down vote up
private void setAdapter() {
    //实例化适配器
    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getFragmentManager(), FragmentPagerItems.with(getContext())
            .add(TITLE[0], fragments.get(0).getClass())
            .add(TITLE[1], fragments.get(1).getClass())
            .add(TITLE[2], fragments.get(2).getClass())
            .create());
    //设置适配器
    hotViewpager.setAdapter(adapter);
    viewpagertab.setViewPager(hotViewpager);
}
 
Example #13
Source File: ProgramPagerFragment.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public FragmentPagerItemAdapter getViewPagerAdapter() {
    return (FragmentPagerItemAdapter) ((ViewPager) (getView().findViewById(R.id.program_pager))).getAdapter();
}
 
Example #14
Source File: FontesPagerFragment.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public FragmentPagerItemAdapter getViewPagerAdapter() {
    return (FragmentPagerItemAdapter) ((ViewPager) (getView().findViewById(R.id.pager))).getAdapter();
}
 
Example #15
Source File: ExerciseDetailsPager.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public FragmentPagerItemAdapter getViewPagerAdapter() {
    return (FragmentPagerItemAdapter) ((ViewPager) (getView().findViewById(R.id.pager))).getAdapter();
}