PageChangeEvents - shiraji/androidannotations GitHub Wiki

Since AndroidAnnotations 4.0

@PageScrollStateChanged

This annotation is intended to be used on methods to receive events defined by android.support.v4.view.ViewPager.OnPageChangeListener.onPageScrollStateChanged(int state) when the scroll state changes. The annotation value should be one or several R.id.* fields that refers to a subclass of android.support.v4.view.ViewPager. If not set, the method name will be used as the R.id.* field name. The method may have multiple parameters:

  • A android.support.v4.view.ViewPager parameter to know which ViewPager has targeted this event.
  • An int parameter is to get new scroll state.

All of those parameters are parameter are optional.

Some usage examples of @PageScrollStateChanged annotation:

@PageScrollStateChanged(R.id.viewpager)
void onPageScrollStateChanged(ViewPager view, int state) {
	// Something Here
}

@PageScrollStateChanged
void viewPager(ViewPager view) {
	// Something Here
}

@PageScrollStateChanged({R.id.viewPager1, R.id.viewPager2})
void onPageScrollStateChangedOnMultipleViewPager(ViewPager v, int anything) {
	// Something Here
}

@PageScrollStateChanged(R.id.viewpager)
void onPageScrollStateChangedNoParam() {
	// Something Here
}

@PageScrolled

This annotation is intended to be used on methods to receive events defined by android.support.v4.view.ViewPager.OnPageChangeListener.onPageScrolled(int position, float positionOffset, int positionOffsetPixels) when the current page is scrolled, either as part of a programmatically initiated smooth scroll or a user initiated touch scroll. The annotation value should be one or several R.id.* fields that refers to a subclass of android.support.v4.view.ViewPager. If not set, the method name will be used as the R.id.* field name. The method may have multiple parameters, but the order must be following:

  • A android.support.v4.view.ViewPager parameter to know which ViewPager has targeted this event.
  • An int parameter named position to get position index of the first page currently being displayed. Page position+1 will be visible if positionOffset is nonzero.
  • A float parameter is value from [0,1) indicating the offset from the page at position.
  • An int parameter named positionOffsetPixels is value in pixels indicating the offset from position.

All of those parameters are parameter are optional.

Some usage examples of @PageScrolled annotation:

@PageScrolled(R.id.viewpager)
void onPageScrolled(ViewPager view, int position, float positionOffset, int positionOffsetPixels) {
	// Something Here
}

@PageScrolled
void viewPager(ViewPager view) {
	// Something Here
}

@PageScrolled({R.id.viewPager1, R.id.viewPager2})
void onPageScrolledOnMultipleViewPager(ViewPager v, int position) {
	// Something Here
}

@PageScrolled(R.id.viewpager)
void onPageScrolledNoParam() {
	// Something Here
}

@PageSelected

This annotation is intended to be used on methods to receive events defined by android.support.v4.view.ViewPager.OnPageChangeListener.onPageSelected(int position) when a new page becomes selected. Animation is not necessarily complete. The annotation value should be one or several R.id.* fields that refers to a subclass of android.support.v4.view.ViewPager. If not set, the method name will be used as the R.id.* field name. The method may have multiple parameters:

  • A android.support.v4.view.ViewPager parameter to know which ViewPager has targeted this event.
  • An int parameter is to get position index of the new selected page.

All of those parameters are parameter are optional.

Some usage examples of @PageSelected annotation:

@PageSelected(R.id.viewpager)
void onPageSelected(ViewPager view, int state) {
	// Something Here
}

@PageSelected
void viewPager(ViewPager view) {
	// Something Here
}

@PageSelected({R.id.viewPager1, R.id.viewPager2})
void onPageSelectedOnMultipleViewPager(ViewPager v, int anything) {
	// Something Here
}

@PageSelected(R.id.viewpager)
void onPageSelectedNoParam() {
	// Something Here
}