Search in sources :

Example 31 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project BookReader by JustWayward.

the class BookDetailCommunityActivity method initDatas.

@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.bookdetail_community_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(BookDetailDiscussionFragment.newInstance(bookId));
    mTabContents.add(BookDetailReviewFragment.newInstance(bookId));
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) BookDetailReviewFragment(com.justwayward.reader.ui.fragment.BookDetailReviewFragment) BookDetailDiscussionFragment(com.justwayward.reader.ui.fragment.BookDetailDiscussionFragment) Fragment(android.support.v4.app.Fragment)

Example 32 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project BookReader by JustWayward.

the class SubCategoryListActivity method initDatas.

@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_tabs));
    mPresenter.attachView(this);
    mPresenter.getCategoryListLv2();
    mTabContents = new ArrayList<>();
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.NEW));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.HOT));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.REPUTATION));
    mTabContents.add(SubCategoryFragment.newInstance(cate, "", gender, Constant.CateType.OVER));
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) SubCategoryFragment(com.justwayward.reader.ui.fragment.SubCategoryFragment) Fragment(android.support.v4.app.Fragment)

Example 33 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project BookReader by JustWayward.

the class SubRankActivity method initDatas.

@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.sub_rank_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(SubRankFragment.newInstance(week));
    mTabContents.add(SubRankFragment.newInstance(month));
    mTabContents.add(SubRankFragment.newInstance(all));
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) SubRankFragment(com.justwayward.reader.ui.fragment.SubRankFragment)

Example 34 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project PocketHub by pockethub.

the class FragmentPagerAdapter method clearAdapter.

/**
     * This methods clears any fragments that may not apply to the newly
     * selected org.
     *
     * @return this adapter
     */
public FragmentPagerAdapter clearAdapter() {
    if (tags.isEmpty()) {
        return this;
    }
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    for (String tag : tags) {
        Fragment fragment = fragmentManager.findFragmentByTag(tag);
        if (fragment != null) {
            transaction.remove(fragment);
        }
    }
    transaction.commit();
    tags.clear();
    return this;
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) Fragment(android.support.v4.app.Fragment)

Example 35 with FragmentPagerAdapter

use of android.support.v4.app.FragmentPagerAdapter in project priend by TakoJ.

the class CommunityActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_community);
    // Create the adapter that will return a fragment for each section
    mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        private final Fragment[] mFragments = new Fragment[] { new RecentPostsFragment(), new MyPostsFragment(), new MyTopPostsFragment() };

        private final String[] mFragmentNames = new String[] { getString(R.string.heading_recent), getString(R.string.heading_my_posts), getString(R.string.heading_my_top_posts) };

        @Override
        public Fragment getItem(int position) {
            return mFragments[position];
        }

        @Override
        public int getCount() {
            return mFragments.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mFragmentNames[position];
        }
    };
    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mPagerAdapter);
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);
    // Button launches NewPostActivity
    findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(CommunityActivity.this, NewPostActivity.class));
        }
    });
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Intent(android.content.Intent) Fragment(android.support.v4.app.Fragment) MyTopPostsFragment(com.example.management.fragment.MyTopPostsFragment) RecentPostsFragment(com.example.management.fragment.RecentPostsFragment) MyPostsFragment(com.example.management.fragment.MyPostsFragment) View(android.view.View) MyTopPostsFragment(com.example.management.fragment.MyTopPostsFragment) RecentPostsFragment(com.example.management.fragment.RecentPostsFragment) TabLayout(android.support.design.widget.TabLayout) MyPostsFragment(com.example.management.fragment.MyPostsFragment)

Aggregations

FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)29 Fragment (android.support.v4.app.Fragment)26 ViewPager (android.support.v4.view.ViewPager)10 View (android.view.View)7 Intent (android.content.Intent)6 TabLayout (android.support.design.widget.TabLayout)5 Bundle (android.os.Bundle)3 RecyclerView (android.support.v7.widget.RecyclerView)3 Toolbar (android.support.v7.widget.Toolbar)3 TextView (android.widget.TextView)3 FragmentPagerAdapter (android.support.v13.app.FragmentPagerAdapter)2 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 AlertDialog (android.support.v7.app.AlertDialog)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)2 Menu (android.view.Menu)2 MenuItem (android.view.MenuItem)2 LinearLayout (android.widget.LinearLayout)2 PageIndicator (com.viewpagerindicator.PageIndicator)2 TabPageIndicator (com.viewpagerindicator.TabPageIndicator)2 ArrayList (java.util.ArrayList)2