InfiniteCycleViewPager 項(xiàng)目里有一個(gè)
HorizontalInfiniteCycleViewPager類 繼承的ViewPager 實(shí)現(xiàn)了自己的一個(gè)ViewPageable接口 , 主要是就拿到InfiniteCycleManager 內(nèi)部層邏輯處理后傳遞的參數(shù),我們來調(diào)用系統(tǒng)的viewPager的代碼;
InfiniteCycleManager 控制寫邏輯代碼
InfiniteCyclePagerAdapter 是一個(gè)包裝類,用戶傳遞過來pagerAdapter 實(shí)現(xiàn)類
package com.gigamole.infinitecycleviewpager;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import static android.support.v4.view.ViewPager.OnPageChangeListener;
import static android.support.v4.view.ViewPager.PageTransformer;
/**
* Created by GIGAMOLE on 7/27/16.
*/
// Interface that duplicate methods of ViewPager for implements it in Horizontal and Vertical
// InfiniteCycleViewPager for casting them to ViewPageable in InfiniteCycleManager
interface ViewPageable {
boolean hasWindowFocus();
int getCurrentItem();
int getChildCount();
View getChildAt(final int index);
PagerAdapter getAdapter();
boolean post(final Runnable runnable);
void addOnPageChangeListener(final OnPageChangeListener onPageChangeListener);
void setClipChildren(final boolean clipChildren);
void setDrawingCacheEnabled(final boolean drawingCacheEnabled);
void setWillNotCacheDrawing(final boolean willNotCacheDrawing);
void setOverScrollMode(final int overScrollMode);
void setCurrentItem(final int item);
void setPageTransformer(final boolean reverseDrawingOrder, final PageTransformer transformer);
void setPageMargin(final int pageMargin);
void setOffscreenPageLimit(final int offscreenPageLimit);
boolean isFakeDragging();
boolean beginFakeDrag();
void fakeDragBy(final float dragBy);
void endFakeDrag();
}
其實(shí) HorizontalInfiniteCycleViewPager 他就是自定義的?ViewPager
推薦 GitHub: https://github.com/Devlight/InfiniteCycleViewPager