Search in sources :

Example 56 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 57 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 58 with ViewPager

use of android.support.v4.view.ViewPager in project glide by bumptech.

the class FlickrSearchActivity method onCreate.

/**
   * Called when the activity is first created.
   */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    backgroundThread = new HandlerThread("BackgroundThumbnailHandlerThread");
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());
    setContentView(R.layout.flickr_search_activity);
    searching = findViewById(R.id.searching);
    searchLoading = findViewById(R.id.search_loading);
    searchTerm = (TextView) findViewById(R.id.search_term);
    Resources res = getResources();
    ViewPager pager = (ViewPager) findViewById(R.id.view_pager);
    pager.setPageMargin(res.getDimensionPixelOffset(R.dimen.page_margin));
    pager.setAdapter(new FlickrPagerAdapter(getSupportFragmentManager()));
    Api.get(this).registerSearchListener(queryListener);
    if (savedInstanceState != null) {
        Query savedQuery = savedInstanceState.getParcelable(STATE_QUERY);
        if (savedQuery != null) {
            executeQuery(savedQuery);
        }
    } else {
        executeQuery(RecentQuery.get());
    }
    int smallGridSize = res.getDimensionPixelSize(R.dimen.small_photo_side);
    int mediumGridSize = res.getDimensionPixelSize(R.dimen.medium_photo_side);
    int listHeightSize = res.getDimensionPixelSize(R.dimen.flickr_list_item_height);
    int screenWidth = getScreenWidth();
    if (savedInstanceState == null) {
        // Weight values determined experimentally by measuring the number of incurred GCs while
        // scrolling through the various photo grids/lists.
        Glide.get(this).preFillBitmapPool(new PreFillType.Builder(smallGridSize).setWeight(1), new PreFillType.Builder(mediumGridSize).setWeight(1), new PreFillType.Builder(screenWidth / 2, listHeightSize).setWeight(6));
    }
}
Also used : StrictMode(android.os.StrictMode) HandlerThread(android.os.HandlerThread) Query(com.bumptech.glide.samples.flickr.api.Query) SearchQuery(com.bumptech.glide.samples.flickr.api.SearchQuery) RecentQuery(com.bumptech.glide.samples.flickr.api.RecentQuery) Handler(android.os.Handler) Resources(android.content.res.Resources) ViewPager(android.support.v4.view.ViewPager)

Example 59 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 60 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)246 View (android.view.View)95 PagerAdapter (android.support.v4.view.PagerAdapter)55 Fragment (android.support.v4.app.Fragment)44 TabLayout (android.support.design.widget.TabLayout)37 TextView (android.widget.TextView)35 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)34 Toolbar (android.support.v7.widget.Toolbar)30 Bundle (android.os.Bundle)28 ViewGroup (android.view.ViewGroup)27 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21 ImageView (android.widget.ImageView)20 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)17 ActionBar (android.support.v7.app.ActionBar)15 RecyclerView (android.support.v7.widget.RecyclerView)11 ViewTreeObserver (android.view.ViewTreeObserver)9 AdapterView (android.widget.AdapterView)9 LinearLayout (android.widget.LinearLayout)9 UiController (android.support.test.espresso.UiController)8