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);
}
});
}
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());
}
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));
}
}
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());
}
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();
}
Aggregations