use of org.edx.mobile.view.common.PageViewStateCallback in project edx-app-android by edx.
the class CourseUnitNavigationActivity method navigateNextComponent.
@Override
public void navigateNextComponent() {
int index = pager.getCurrentItem();
if (index < pagerAdapter.getCount() - 1) {
PageViewStateCallback curView = (PageViewStateCallback) pagerAdapter.instantiateItem(pager, index);
if (curView != null)
curView.onPageDisappear();
pager.setCurrentItem(index + 1);
}
}
use of org.edx.mobile.view.common.PageViewStateCallback 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();
}
});
}
use of org.edx.mobile.view.common.PageViewStateCallback in project edx-app-android by edx.
the class CourseUnitNavigationActivity method navigatePreviousComponent.
@Override
public void navigatePreviousComponent() {
int index = pager.getCurrentItem();
if (index > 0) {
PageViewStateCallback curView = (PageViewStateCallback) pagerAdapter.instantiateItem(pager, index);
if (curView != null)
curView.onPageDisappear();
pager.setCurrentItem(index - 1);
}
}
Aggregations