Java Code Examples for android.support.v4.view.PagerAdapter#unregisterDataSetObserver()

The following examples show how to use android.support.v4.view.PagerAdapter#unregisterDataSetObserver() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagerTitleStrip.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
void updateAdapter(PagerAdapter oldAdapter, PagerAdapter newAdapter) {
    if (oldAdapter != null) {
        oldAdapter.unregisterDataSetObserver(mPageListener);
        mWatchingAdapter = null;
    }
    if (newAdapter != null) {
        newAdapter.registerDataSetObserver(mPageListener);
        mWatchingAdapter = new WeakReference<PagerAdapter>(newAdapter);
    }
    if (mPager != null) {
        mLastKnownCurrentPage = -1;
        mLastKnownPositionOffset = -1;
        updateText(mPager.getCurrentItem(), newAdapter);
        requestLayout();
    }
}
 
Example 2
Source File: PagerTitleStrip.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
void updateAdapter(PagerAdapter oldAdapter, PagerAdapter newAdapter) {
    if (oldAdapter != null) {
        oldAdapter.unregisterDataSetObserver(mPageListener);
        mWatchingAdapter = null;
    }
    if (newAdapter != null) {
        newAdapter.registerDataSetObserver(mPageListener);
        mWatchingAdapter = new WeakReference<PagerAdapter>(newAdapter);
    }
    if (mPager != null) {
        mLastKnownCurrentPage = -1;
        mLastKnownPositionOffset = -1;
        updateText(mPager.getCurrentItem(), newAdapter);
        requestLayout();
    }
}
 
Example 3
Source File: PagerIndicator.java    From ImageSliderWithSwipes with Apache License 2.0 5 votes vote down vote up
/**
 * clear self means unregister the dataset observer and remove all the child views(indicators).
 */
public void destroySelf(){
    if(mPager == null || mPager.getAdapter() == null){
        return;
    }
    InfinitePagerAdapter wrapper = (InfinitePagerAdapter)mPager.getAdapter();
    PagerAdapter adapter = wrapper.getRealAdapter();
    if(adapter!=null){
        adapter.unregisterDataSetObserver(dataChangeObserver);
    }
    removeAllViews();
}
 
Example 4
Source File: PagerIndicator.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
/**
 * clear self means unregister the dataset observer and remove all the child views(indicators).
 */
public void destroySelf() {
    if (mPager == null || mPager.getAdapter() == null) {
        return;
    }
    InfinitePagerAdapter wrapper = (InfinitePagerAdapter) mPager.getAdapter();
    PagerAdapter adapter = wrapper.getRealAdapter();
    if (adapter != null) {
        adapter.unregisterDataSetObserver(dataChangeObserver);
    }
    removeAllViews();
    ShapeDrawable shapeDrawable;

}
 
Example 5
Source File: PagerIndicator.java    From AndroidImageSlider with MIT License 5 votes vote down vote up
/**
 * clear self means unregister the dataset observer and remove all the child views(indicators).
 */
public void destroySelf(){
    if(mPager == null || mPager.getAdapter() == null){
        return;
    }
    InfinitePagerAdapter wrapper = (InfinitePagerAdapter)mPager.getAdapter();
    PagerAdapter adapter = wrapper.getRealAdapter();
    if(adapter!=null){
        adapter.unregisterDataSetObserver(dataChangeObserver);
    }
    removeAllViews();
}
 
Example 6
Source File: PagerIndicator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * clear self means unregister the dataset observer and remove all the child views(indicators).
 */
public void destroySelf(){
    if(mPager == null || mPager.getAdapter() == null){
        return;
    }
    InfinitePagerAdapter wrapper = (InfinitePagerAdapter)mPager.getAdapter();
    PagerAdapter adapter = wrapper.getRealAdapter();
    if(adapter!=null){
        adapter.unregisterDataSetObserver(dataChangeObserver);
    }
    removeAllViews();
}
 
Example 7
Source File: PagerIndicator.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * clear self means unregister the dataset observer and remove all the child views(indicators).
 */
public void destroySelf(){
    if(mPager == null || mPager.getAdapter() == null){
        return;
    }
    InfinitePagerAdapter wrapper = (InfinitePagerAdapter)mPager.getAdapter();
    PagerAdapter adapter = wrapper.getRealAdapter();
    if(adapter!=null){
        adapter.unregisterDataSetObserver(dataChangeObserver);
    }
    removeAllViews();
}