Search in sources :

Example 1 with TabFragmentPagerAdapter

use of me.zhanghai.android.douya.ui.TabFragmentPagerAdapter in project Douya by DreaminginCodeZH.

the class BroadcastActivityDialogFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mTabAdapter = new TabFragmentPagerAdapter(this);
    mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {

        @Override
        public Fragment createFragment() {
            return BroadcastLikerListFragment.newInstance(mBroadcast);
        }
    }, null);
    mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {

        @Override
        public Fragment createFragment() {
            return BroadcastRebroadcasterListFragment.newInstance(mBroadcast);
        }
    }, null);
    updateTabTitle();
    mViewPager.setOffscreenPageLimit(mTabAdapter.getCount() - 1);
    mViewPager.setAdapter(mTabAdapter);
    mTabLayout.setupWithViewPager(mViewPager);
    mPositiveButton.setText(R.string.ok);
    mPositiveButton.setVisibility(View.VISIBLE);
    mPositiveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    mNegativeButton.setVisibility(View.GONE);
    mNeutralButton.setVisibility(View.GONE);
}
Also used : TabFragmentPagerAdapter(me.zhanghai.android.douya.ui.TabFragmentPagerAdapter) AppCompatDialogFragment(android.support.v7.app.AppCompatDialogFragment) Fragment(android.support.v4.app.Fragment) BindView(butterknife.BindView) View(android.view.View)

Example 2 with TabFragmentPagerAdapter

use of me.zhanghai.android.douya.ui.TabFragmentPagerAdapter in project Douya by DreaminginCodeZH.

the class HomeFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    mTabAdapter = new TabFragmentPagerAdapter(this);
    mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {

        @Override
        public Fragment createFragment() {
            return HomeBroadcastListFragment.newInstance();
        }
    }, getString(R.string.home_broadcast));
    mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {

        @Override
        public Fragment createFragment() {
            return NotYetImplementedFragment.newInstance();
        }
    }, getString(R.string.home_discover));
    mTabAdapter.addTab(new TabFragmentPagerAdapter.FragmentCreator() {

        @Override
        public Fragment createFragment() {
            return NotYetImplementedFragment.newInstance();
        }
    }, getString(R.string.home_online));
    mViewPager.setOffscreenPageLimit(mTabAdapter.getCount() - 1);
    mViewPager.setAdapter(mTabAdapter);
    mTabLayout.setupWithViewPager(mViewPager);
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) TabFragmentPagerAdapter(me.zhanghai.android.douya.ui.TabFragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) NotYetImplementedFragment(me.zhanghai.android.douya.ui.NotYetImplementedFragment) HomeBroadcastListFragment(me.zhanghai.android.douya.broadcast.ui.HomeBroadcastListFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)2 TabFragmentPagerAdapter (me.zhanghai.android.douya.ui.TabFragmentPagerAdapter)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 AppCompatDialogFragment (android.support.v7.app.AppCompatDialogFragment)1 View (android.view.View)1 BindView (butterknife.BindView)1 HomeBroadcastListFragment (me.zhanghai.android.douya.broadcast.ui.HomeBroadcastListFragment)1 NotYetImplementedFragment (me.zhanghai.android.douya.ui.NotYetImplementedFragment)1