prolificinteractive/ParallaxPager — pull request #5 by scompt (2014-07-07 13:04:04+00:00)
Title: Allow subclasses to override page indicator listener

There's no way to add a page indicator at the moment (for example, [ViewPagerIndicator](http://viewpagerindicator.com/). The `ViewPager` is created internally to the `ParallaxContainer`, so there's no way to connect it to a `ViewPagerIndicator`. This pull request adds a protected method that lets you create a subclass which lets you add a page indicator. The method signature is:

protected void attachOnPageChangeListener(ViewPager viewPager, ViewPager.OnPageChangeListener listener)

I've created a subclass for my project that looks like this:

````
package com.example;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;

import com.prolificinteractive.parallaxpager.ParallaxContainer;
import com.viewpagerindicator.PageIndicator;

public class PageIndicatorParallaxContainer extends ParallaxContainer {
private PageIndicator mPageIndicator;

@SuppressWarnings("UnusedDeclaration")
public PageIndicatorParallaxContainer(Context context) {
super(context);
}

@SuppressWarnings("UnusedDeclaration")
public PageIndicatorParallaxContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}

@SuppressWarnings("UnusedDeclaration")
public PageIndicatorParallaxContainer(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

@Override
protected void attachOnPageChangeListener(ViewPager viewPager,
ViewPager.OnPageChangeListener listener) {
if (mPageIndicator != null) {
mPageIndicator.setOnPageChangeListener(listener);
mPageIndicator.setViewPager(viewPager);

} else {
viewPager.setOnPageChangeListener(listener);
}
}

public void setPageIndicator(PageIndicator pageIndicator) {
this.mPageIndicator = pageIndicator;
}
}
````

I don't think this class belongs in the ParallaxPager package, but it's a good example.