Search in sources :

Example 36 with Fragment

use of android.support.v4.app.Fragment in project AppIntro by apl-devs.

the class AppIntroBase method handleBeforeSlideChanged.

/**
     * Called before a slide change happens. By returning false, one can disallow the slide change.
     *
     * @return true, if the slide change should be allowed, else false
     */
private boolean handleBeforeSlideChanged() {
    Fragment currentFragment = mPagerAdapter.getItem(pager.getCurrentItem());
    LogHelper.d(TAG, String.format("User wants to move away from slide: %s. Checking if this should be allowed...", currentFragment));
    // Check if the current fragment implements ISlidePolicy, else a change is always allowed
    if (currentFragment instanceof ISlidePolicy) {
        ISlidePolicy slide = (ISlidePolicy) currentFragment;
        LogHelper.d(TAG, "Current fragment implements ISlidePolicy.");
        // Check if policy is fulfilled
        if (!slide.isPolicyRespected()) {
            LogHelper.d(TAG, "Slide policy not respected, denying change request.");
            return false;
        }
    }
    LogHelper.d(TAG, "Change request will be allowed.");
    return true;
}
Also used : Fragment(android.support.v4.app.Fragment)

Example 37 with Fragment

use of android.support.v4.app.Fragment in project platform_frameworks_base by android.

the class RvCompatListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        RecyclerViewFragment fragment = new RecyclerViewFragment();
        fragment.layoutManager = createLayoutManager(this);
        fragment.adapter = createAdapter();
        fm.beginTransaction().add(android.R.id.content, fragment).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager)

Example 38 with Fragment

use of android.support.v4.app.Fragment 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)

Example 39 with Fragment

use of android.support.v4.app.Fragment 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 40 with Fragment

use of android.support.v4.app.Fragment 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)

Aggregations

Fragment (android.support.v4.app.Fragment)663 FragmentTransaction (android.support.v4.app.FragmentTransaction)233 Bundle (android.os.Bundle)149 View (android.view.View)140 FragmentManager (android.support.v4.app.FragmentManager)134 DialogFragment (android.support.v4.app.DialogFragment)80 TextView (android.widget.TextView)59 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)48 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)48 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)48 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)43 Intent (android.content.Intent)41 ViewPager (android.support.v4.view.ViewPager)38 FragmentActivity (android.support.v4.app.FragmentActivity)34 ImageView (android.widget.ImageView)32 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ArrayList (java.util.ArrayList)28 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ActionBar (android.support.v7.app.ActionBar)23