Search in sources :

Example 1 with ViewPager

use of android.support.v4.view.ViewPager in project Meizhi by drakeet.

the class SmoothAppBarLayout method initViews.

protected void initViews() {
    if (mViewPagerId > 0) {
        vViewPager = (ViewPager) getRootView().findViewById(mViewPagerId);
    } else {
        int i = 0;
        ViewGroup parent = (ViewGroup) getParent();
        View child;
        for (int z = parent.getChildCount(); i < z; i++) {
            child = parent.getChildAt(i);
            if (child instanceof ViewPager) {
                vViewPager = (ViewPager) child;
                break;
            }
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager)

Example 2 with ViewPager

use of android.support.v4.view.ViewPager in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final ViewPager pager = (ViewPager) findViewById(R.id.pager);
    final MaterialTabs tabs = (MaterialTabs) findViewById(R.id.tabs);
    observable = (Observable<PermissionRoster>) getLastNonConfigurationInstance();
    if (observable == null) {
        observable = Observable.create(new PermissionSource(this)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).cache();
    }
    sub = observable.subscribe(new Consumer<PermissionRoster>() {

        @Override
        public void accept(PermissionRoster roster) throws Exception {
            pager.setAdapter(new PermissionTabAdapter(MainActivity.this, getFragmentManager(), roster));
            tabs.setViewPager(pager);
        }
    }, new Consumer<Throwable>() {

        @Override
        public void accept(Throwable error) throws Exception {
            Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_LONG).show();
            Log.e(getClass().getSimpleName(), "Exception processing request", error);
        }
    });
}
Also used : MaterialTabs(io.karim.MaterialTabs) Consumer(io.reactivex.functions.Consumer) ViewPager(android.support.v4.view.ViewPager)

Example 3 with ViewPager

use of android.support.v4.view.ViewPager in project UltimateAndroid by cymcsg.

the class ViewPagerTabListViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.observable_scroll_view_activity_viewpagertabscrollview);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    mHeaderView = findViewById(R.id.header);
    ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation));
    mToolbarView = findViewById(R.id.toolbar);
    mPagerAdapter = new NavigationAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
    slidingTabLayout.setCustomTabView(R.layout.observable_scroll_view_tab_indicator, android.R.id.text1);
    slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(R.color.accent));
    slidingTabLayout.setDistributeEvenly(true);
    slidingTabLayout.setViewPager(mPager);
    // When the page is selected, other fragments' scrollY should be adjusted
    // according to the toolbar status(shown/hidden)
    slidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int i, float v, int i2) {
        }

        @Override
        public void onPageSelected(int i) {
            propagateToolbarState(toolbarIsShown());
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });
    propagateToolbarState(toolbarIsShown());
}
Also used : SlidingTabLayout(com.marshalchen.common.demoofui.observablescrollview.ui.widget.SlidingTabLayout) ViewPager(android.support.v4.view.ViewPager)

Example 4 with ViewPager

use of android.support.v4.view.ViewPager in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(buildAdapter());
}
Also used : ViewPager(android.support.v4.view.ViewPager)

Example 5 with ViewPager

use of android.support.v4.view.ViewPager in project cw-omnibus by commonsguy.

the class TabPageIndicator method setViewPager.

@Override
public void setViewPager(ViewPager view) {
    if (mViewPager == view) {
        return;
    }
    if (mViewPager != null) {
        mViewPager.setOnPageChangeListener(null);
    }
    final PagerAdapter adapter = view.getAdapter();
    if (adapter == null) {
        throw new IllegalStateException("ViewPager does not have adapter instance.");
    }
    mViewPager = view;
    view.setOnPageChangeListener(this);
    notifyDataSetChanged();
}
Also used : PagerAdapter(android.support.v4.view.PagerAdapter)

Aggregations

ViewPager (android.support.v4.view.ViewPager)387 View (android.view.View)176 TabLayout (android.support.design.widget.TabLayout)80 Fragment (android.support.v4.app.Fragment)79 TextView (android.widget.TextView)74 PagerAdapter (android.support.v4.view.PagerAdapter)64 Bundle (android.os.Bundle)52 ArrayList (java.util.ArrayList)50 ImageView (android.widget.ImageView)46 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)45 Toolbar (android.support.v7.widget.Toolbar)44 Intent (android.content.Intent)41 ViewGroup (android.view.ViewGroup)41 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)30 ActionBar (android.support.v7.app.ActionBar)23 LinearLayout (android.widget.LinearLayout)19 RecyclerView (android.support.v7.widget.RecyclerView)18 AdapterView (android.widget.AdapterView)18 SuppressLint (android.annotation.SuppressLint)15 Context (android.content.Context)14