All Downloads are FREE. Search and download functionalities are using the official Maven repository.

butterknife.OnPageChange Maven / Gradle / Ivy

There is a newer version: 10.2.3
Show newest version
package butterknife;

import butterknife.internal.ListenerClass;
import butterknife.internal.ListenerMethod;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.CLASS;

/**
 * Bind a method to an {@code OnPageChangeListener} on the view for each ID specified.
 * 

 * {@literal @}OnPageChange(R.id.example_pager) void onPageSelected(int position) {
 *   Toast.makeText(this, "Selected " + position + "!", LENGTH_SHORT).show();
 * }
 * 
* Any number of parameters from {@code onPageSelected} may be used on the method. *

* To bind to methods other than {@code onPageSelected}, specify a different {@code callback}. *


 * {@literal @}OnPageChange(value = R.id.example_pager, callback = PAGE_SCROLL_STATE_CHANGED)
 * void onPageStateChanged(int state) {
 *   Toast.makeText(this, "State changed: " + state + "!", LENGTH_SHORT).show();
 * }
 * 
* * @see Optional */ @Target(METHOD) @Retention(CLASS) @ListenerClass( targetType = "android.support.v4.view.ViewPager", setter = "setOnPageChangeListener", type = "android.support.v4.view.ViewPager.OnPageChangeListener", callbacks = OnPageChange.Callback.class ) public @interface OnPageChange { /** View IDs to which the method will be bound. */ int[] value(); /** Listener callback to which the method will be bound. */ Callback callback() default Callback.PAGE_SELECTED; /** {@code ViewPager.OnPageChangeListener} callback methods. */ enum Callback { /** {@code onPageSelected(int)} */ @ListenerMethod( name = "onPageSelected", parameters = "int" ) PAGE_SELECTED, /** {@code onPageScrolled(int, float, int)} */ @ListenerMethod( name = "onPageScrolled", parameters = { "int", "float", "int" } ) PAGE_SCROLLED, /** {@code onPageScrollStateChanged(int)} */ @ListenerMethod( name = "onPageScrollStateChanged", parameters = "int" ) PAGE_SCROLL_STATE_CHANGED, } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy