use of org.edx.mobile.view.custom.DisableableViewPager in project edx-app-android by edx.
the class CourseUnitNavigationActivity method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RelativeLayout insertPoint = (RelativeLayout) findViewById(R.id.fragment_container);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.view_course_unit_pager, null);
insertPoint.addView(v, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
pager = (DisableableViewPager) findViewById(R.id.pager);
pagerAdapter = new CourseUnitPagerAdapter(getSupportFragmentManager(), environment.getConfig(), unitList, courseData, this);
pager.setAdapter(pagerAdapter);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
if (state == ViewPager.SCROLL_STATE_DRAGGING) {
int curIndex = pager.getCurrentItem();
PageViewStateCallback curView = (PageViewStateCallback) pagerAdapter.instantiateItem(pager, curIndex);
if (curView != null)
curView.onPageDisappear();
}
if (state == ViewPager.SCROLL_STATE_IDLE) {
int curIndex = pager.getCurrentItem();
PageViewStateCallback curView = (PageViewStateCallback) pagerAdapter.instantiateItem(pager, curIndex);
if (curView != null)
curView.onPageShow();
tryToUpdateForEndOfSequential();
}
}
});
findViewById(R.id.course_unit_nav_bar).setVisibility(View.VISIBLE);
mPreviousBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
navigatePreviousComponent();
}
});
mNextBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
navigateNextComponent();
}
});
}
Aggregations