Search in sources :

Example 11 with FragmentStatePagerAdapter

use of android.support.v4.app.FragmentStatePagerAdapter in project making-apps-beautiful by ankurkotwal.

the class ArticleDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int i) {
            Bundle arguments = new Bundle();
            arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
            ArticleDetailFragment fragment = new ArticleDetailFragment();
            fragment.setArguments(arguments);
            return fragment;
        }

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }
    });
    pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
    for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
        if (DummyContent.ITEMS.get(i).id.equals(startId)) {
            pager.setCurrentItem(i);
            return;
        }
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) Bundle(android.os.Bundle) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Example 12 with FragmentStatePagerAdapter

use of android.support.v4.app.FragmentStatePagerAdapter in project making-apps-beautiful by ankurkotwal.

the class ArticleDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int i) {
            Bundle arguments = new Bundle();
            arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
            ArticleDetailFragment fragment = new ArticleDetailFragment();
            fragment.setArguments(arguments);
            return fragment;
        }

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }
    });
    pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
    for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
        if (DummyContent.ITEMS.get(i).id.equals(startId)) {
            pager.setCurrentItem(i);
            return;
        }
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) Bundle(android.os.Bundle) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Example 13 with FragmentStatePagerAdapter

use of android.support.v4.app.FragmentStatePagerAdapter in project making-apps-beautiful by ankurkotwal.

the class ArticleDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int i) {
            Bundle arguments = new Bundle();
            arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
            ArticleDetailFragment fragment = new ArticleDetailFragment();
            fragment.setArguments(arguments);
            return fragment;
        }

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }
    });
    pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
    for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
        if (DummyContent.ITEMS.get(i).id.equals(startId)) {
            pager.setCurrentItem(i);
            return;
        }
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) Bundle(android.os.Bundle) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Example 14 with FragmentStatePagerAdapter

use of android.support.v4.app.FragmentStatePagerAdapter in project making-apps-beautiful by ankurkotwal.

the class ArticleDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int i) {
            Bundle arguments = new Bundle();
            arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
            ArticleDetailFragment fragment = new ArticleDetailFragment();
            fragment.setArguments(arguments);
            return fragment;
        }

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }
    });
    pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
    for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
        if (DummyContent.ITEMS.get(i).id.equals(startId)) {
            pager.setCurrentItem(i);
            return;
        }
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) Bundle(android.os.Bundle) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Example 15 with FragmentStatePagerAdapter

use of android.support.v4.app.FragmentStatePagerAdapter in project making-apps-beautiful by ankurkotwal.

the class ArticleDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article_detail);
    // Show the Up button in the action bar.
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int i) {
            Bundle arguments = new Bundle();
            arguments.putString(ArticleDetailFragment.ARG_ITEM_ID, DummyContent.ITEMS.get(i).id);
            ArticleDetailFragment fragment = new ArticleDetailFragment();
            fragment.setArguments(arguments);
            return fragment;
        }

        @Override
        public int getCount() {
            return DummyContent.ITEMS.size();
        }
    });
    pager.setPageMarginDrawable(getResources().getDrawable(R.drawable.list_divider_holo_light));
    pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()));
    String startId = getIntent().getStringExtra(ArticleDetailFragment.ARG_ITEM_ID);
    for (int i = 0; i < DummyContent.ITEMS.size(); i++) {
        if (DummyContent.ITEMS.get(i).id.equals(startId)) {
            pager.setCurrentItem(i);
            return;
        }
    }
}
Also used : FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) Bundle(android.os.Bundle) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Aggregations

FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21 Fragment (android.support.v4.app.Fragment)20 ViewPager (android.support.v4.view.ViewPager)13 Bundle (android.os.Bundle)11 View (android.view.View)6 Toolbar (android.support.v7.widget.Toolbar)3 BindView (butterknife.BindView)3 MaterialViewPager (com.github.florent37.materialviewpager.MaterialViewPager)3 HeaderDesign (com.github.florent37.materialviewpager.header.HeaderDesign)3 PagerAdapter (android.support.v4.view.PagerAdapter)2 TextView (android.widget.TextView)2 RecyclerViewFragment (com.github.florent37.materialviewpager.sample.fragment.RecyclerViewFragment)2 Intent (android.content.Intent)1 StateListDrawable (android.graphics.drawable.StateListDrawable)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 WebView (android.webkit.WebView)1 AbsListView (android.widget.AbsListView)1