<|start_filename|>app/src/main/java/com/allure/lmbanners/MainActivity.java<|end_filename|>
package com.allure.lmbanners;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import com.allure.lbanners.LMBanners;
import com.allure.lbanners.transformer.TransitionEffect;
import com.allure.lbanners.utils.ScreenUtils;
import com.allure.lmbanners.adapter.LocalImgAdapter;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private LMBanners mLBanners;
    //本地图片
    private ArrayList<Integer> localImages = new ArrayList<Integer>();
    //网络图片
    private List<String> networkImages = new ArrayList<>();
    private int[] mImagesSrc = {
            R.mipmap.img1,
            R.mipmap.img2,
            R.mipmap.img3,
            R.mipmap.img4,
            R.mipmap.img5
    };

    private static final String[] strs = new String[]{
            "defaultEffect", "alpha", "rotate", "cube", "flip", "accordion", "zoomFade",
            "fade", "zoomCenter", "zoomStack", "stack", "depth", "zoom", "zoomOut", "parallax"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initImageLoader();
        addLocalImg();
        addUrilImg();

        ListView listView = (ListView) findViewById(R.id.listView);
        listView.setAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, strs));

        mLBanners = (LMBanners) findViewById(R.id.banners);
        //设置Banners高度
      mLBanners.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ScreenUtils.dip2px(this, 200)));


        //参数设置
        mLBanners.isGuide(false);//是否为引导页
        mLBanners.setAutoPlay(true);//自动播放
        mLBanners.setVertical(false);//是否锤子播放
        mLBanners.setScrollDurtion(2000);//两页切换时间
        mLBanners.setCanLoop(true);//循环播放
        mLBanners.setSelectIndicatorRes(R.drawable.guide_indicator_select);//选中的原点
        mLBanners.setUnSelectUnIndicatorRes(R.drawable.guide_indicator_unselect);//未选中的原点
        //若自定义原点到底部的距离,默认20,必须在setIndicatorWidth之前调用
        mLBanners.setIndicatorBottomPadding(30);
        mLBanners.setIndicatorWidth(10);//原点默认为5dp
        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.ZoomStack);//选中喜欢的样式
//        mLBanners.setHoriZontalCustomTransformer(new ParallaxTransformer(R.id.id_image));//自定义样式
        mLBanners.setDurtion(3000);//轮播切换时间
//        mLBanners.hideIndicatorLayout();//隐藏原点
//        mLBanners.showIndicatorLayout();//显示原点
        mLBanners.setIndicatorPosition(LMBanners.IndicaTorPosition.BOTTOM_MID);//设置原点显示位置


        //本地用法
        mLBanners.setAdapter(new LocalImgAdapter(MainActivity.this), localImages);
        //网络图片
//        mLBanners.setAdapter(new UrlImgAdapter(MainActivity.this), networkImages);

        mLBanners.setOnStartListener(0XFFAABBCC, 0XFFAACCBB, new LMBanners.onStartListener() {
            @Override
            public void startOpen() {
                //回调跳转的逻辑
                Toast.makeText(MainActivity.this, "我要进入主界面", 1).show();

            }
        });

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Default);//Default
                        break;
                    case 1:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Alpha);//Alpha
                        break;
                    case 2:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Rotate);//Rotate
                        break;
                    case 3:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Cube);//Cube
                        break;
                    case 4:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Flip);//Flip
                        break;
                    case 5:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Accordion);//Accordion
                        break;
                    case 6:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.ZoomFade);//ZoomFade
                        break;
                    case 7:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Fade);//Fade
                        break;
                    case 8:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.ZoomCenter);//ZoomCenter
                        break;
                    case 9:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.ZoomStack);//ZoomStack
                        break;
                    case 10:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Stack);//Stack
                        break;
                    case 11:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Depth);//Depth
                        break;
                    case 12:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.Zoom);//Zoom
                        break;
                    case 13:
                        mLBanners.setHoriZontalTransitionEffect(TransitionEffect.ZoomOut);//ZoomOut
                        break;
                    case 14:
                        mLBanners.setHoriZontalCustomTransformer(new ParallaxTransformer(R.id.id_image));//Parallax
                        break;

                }
            }
        });


    }


    private void addUrilImg() {
        networkImages.add("http://h.hiphotos.baidu.com/image/h%3D300/sign=ff62800b073b5bb5a1d726fe06d2d523/a6efce1b9d16fdfa7807474eb08f8c5494ee7b23.jpg");
        networkImages.add("http://g.hiphotos.baidu.com/image/h%3D300/sign=0a9ac84f89b1cb1321693a13ed5556da/1ad5ad6eddc451dabff9af4bb2fd5266d0163206.jpg");
        networkImages.add("http://a.hiphotos.baidu.com/image/h%3D300/sign=61660ec2207f9e2f6f351b082f31e962/500fd9f9d72a6059e5c05d3e2f34349b023bbac6.jpg");
        networkImages.add("http://c.hiphotos.baidu.com/image/h%3D300/sign=f840688728738bd4db21b431918a876c/f7246b600c338744c90c3826570fd9f9d62aa09a.jpg");
    }

    private void addLocalImg() {
        localImages.add(R.mipmap.img1);
        localImages.add(R.mipmap.img2);
        localImages.add(R.mipmap.img3);
        localImages.add(R.mipmap.img4);
        localImages.add(R.mipmap.img5);
    }

    private void initImageLoader() {
        DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().
                showImageForEmptyUri(R.drawable.ic_launcher)
                .cacheInMemory(true).cacheOnDisk(true).build();
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                getApplicationContext()).defaultDisplayImageOptions(defaultOptions)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .diskCacheFileNameGenerator(new Md5FileNameGenerator())
                .tasksProcessingOrder(QueueProcessingType.LIFO).build();
        ImageLoader.getInstance().init(config);
    }



    @Override
    protected void onPause() {
        super.onPause();
        mLBanners.stopImageTimerTask();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mLBanners.startImageTimerTask();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mLBanners.clearImageTimerTask();
    }


}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/transformer/StackPageTransformer.java<|end_filename|>
package com.allure.lbanners.transformer;

import android.view.View;

import com.nineoldandroids.view.ViewHelper;

/**
 * Created by lm on 2016/7/8.
 */
public class StackPageTransformer extends LMPageTransformer {



    @Override
    public void scrollInvisible(View view, float position) {

    }

    @Override
    public void scrollLeft(View view, float position) {

    }

    @Override
    public void scrollRight(View view, float position) {
        ViewHelper.setTranslationX(view, -view.getWidth() * position);

    }
}

<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/transformer/vertical/VerticalPageTransformer.java<|end_filename|>
package com.allure.lbanners.transformer.vertical;

import android.support.v4.view.ViewPager;
import android.view.View;

import com.nineoldandroids.view.ViewHelper;

/**
 * Created by lm on 2016/7/8.
 */
public class VerticalPageTransformer implements ViewPager.PageTransformer {

    @Override
    public void transformPage(View view, float position) {

        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            ViewHelper.setAlpha(view, 0);

        } else if (position <= 1) { // [-1,1]
            ViewHelper.setAlpha(view, 1);
            // Counteract the default slide transition
            ViewHelper.setTranslationX(view, view.getWidth() * -position);
            //set Y position to swipe in from top
            float yPosition = position * view.getHeight();
            ViewHelper.setTranslationY(view,yPosition);
        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            ViewHelper.setAlpha(view, 0);
        }
    }
}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/adapter/LBaseAdapter.java<|end_filename|>
package com.allure.lbanners.adapter;

import android.content.Context;
import android.view.View;

import com.allure.lbanners.LMBanners;

/**
 * Created by luomin on 16/7/12.
 */
public interface LBaseAdapter<T> {
    View getView(LMBanners lBanners, Context context, int position, T data);
}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/transformer/TransitionEffect.java<|end_filename|>
package com.allure.lbanners.transformer;

/**
 * 默认动画
 * Created by lm on 2016/7/8.
 */
public enum TransitionEffect {
    Default,
    Alpha,
    Rotate,
    Cube,
    Flip,
    Accordion,
    ZoomFade,
    Fade,
    ZoomCenter,
    ZoomStack,
    Stack,
    Depth,
    Zoom,
    ZoomOut,
    Parallax
}

<|start_filename|>app/src/main/java/com/allure/lmbanners/adapter/UrlImgAdapter.java<|end_filename|>
package com.allure.lmbanners.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.allure.lbanners.LMBanners;
import com.allure.lbanners.adapter.LBaseAdapter;
import com.allure.lmbanners.R;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by luomin on 16/7/12.
 */
public class UrlImgAdapter implements LBaseAdapter<String> {
    private Context mContext;

    public UrlImgAdapter(Context context) {
        mContext=context;
    }



    @Override
    public View getView(final LMBanners lBanners, final Context context, int position, String data) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.id_image);
        ImageLoader.getInstance().displayImage(data,imageView);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                        MainActivity.this.startActivity(new Intent(MainActivity.this,SeconedAc.class));
            }
        });
        return view;
    }



}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/transformer/ZoomPageTransformer.java<|end_filename|>
package com.allure.lbanners.transformer;

import android.view.View;

import com.nineoldandroids.view.ViewHelper;

/**
 * Created by lm on 2016/7/8.
 */
public class ZoomPageTransformer extends LMPageTransformer {
    private float mMinScale = 0.85f;
    private float mMinAlpha = 0.65f;

    public ZoomPageTransformer() {
    }

    public ZoomPageTransformer(float minAlpha, float minScale) {
        setMinAlpha(minAlpha);
        setMinScale(minScale);
    }

    @Override
    public void scrollInvisible(View view, float position) {
        ViewHelper.setAlpha(view, 0);
    }

    @Override
    public void scrollLeft(View view, float position) {
        float scale = Math.max(mMinScale, 1 + position);
        float vertMargin = view.getHeight() * (1 - scale) / 2;
        float horzMargin = view.getWidth() * (1 - scale) / 2;
        ViewHelper.setTranslationX(view, horzMargin - vertMargin / 2);
        ViewHelper.setScaleX(view, scale);
        ViewHelper.setScaleY(view, scale);
        ViewHelper.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
    }

    @Override
    public void scrollRight(View view, float position) {
        float scale = Math.max(mMinScale, 1 - position);
        float vertMargin = view.getHeight() * (1 - scale) / 2;
        float horzMargin = view.getWidth() * (1 - scale) / 2;
        ViewHelper.setTranslationX(view, -horzMargin + vertMargin / 2);
        ViewHelper.setScaleX(view, scale);
        ViewHelper.setScaleY(view, scale);
        ViewHelper.setAlpha(view, mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
    }

    public void setMinAlpha(float minAlpha) {
        if (minAlpha >= 0.6f && minAlpha <= 1.0f) {
            mMinAlpha = minAlpha;
        }
    }

    public void setMinScale(float minScale) {
        if (minScale >= 0.6f && minScale <= 1.0f) {
            mMinScale = minScale;
        }
    }


}

<|start_filename|>app/src/main/java/com/allure/lmbanners/GuideActivity.java<|end_filename|>
package com.allure.lmbanners;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.allure.lbanners.LMBanners;
import com.allure.lbanners.transformer.TransitionEffect;
import com.allure.lmbanners.adapter.LocalImgAdapter;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：luomin
 * 邮箱：<EMAIL>
 */

public class GuideActivity extends AppCompatActivity {
    private LMBanners lmBanners;
    //本地图片
    private ArrayList<Integer> localImages = new ArrayList<Integer>();
    //网络图片
    private List<String> networkImages = new ArrayList<>();
    private int[] mImagesSrc = {
            R.mipmap.img1,
            R.mipmap.img2,
            R.mipmap.img3,
            R.mipmap.img4,
            R.mipmap.img5
    };
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        initImageLoader();
        addLocalImg();
        addUrilImg();
        initGuide();


    }

    private void addLocalImg() {
        localImages.add(R.mipmap.img1);
        localImages.add(R.mipmap.img2);
        localImages.add(R.mipmap.img3);
        localImages.add(R.mipmap.img4);
        localImages.add(R.mipmap.img5);
    }

    private void addUrilImg() {
        networkImages.add("http://h.hiphotos.baidu.com/image/h%3D300/sign=ff62800b073b5bb5a1d726fe06d2d523/a6efce1b9d16fdfa7807474eb08f8c5494ee7b23.jpg");
        networkImages.add("http://g.hiphotos.baidu.com/image/h%3D300/sign=0a9ac84f89b1cb1321693a13ed5556da/1ad5ad6eddc451dabff9af4bb2fd5266d0163206.jpg");
        networkImages.add("http://a.hiphotos.baidu.com/image/h%3D300/sign=61660ec2207f9e2f6f351b082f31e962/500fd9f9d72a6059e5c05d3e2f34349b023bbac6.jpg");
        networkImages.add("http://c.hiphotos.baidu.com/image/h%3D300/sign=f840688728738bd4db21b431918a876c/f7246b600c338744c90c3826570fd9f9d62aa09a.jpg");
    }

    private void initImageLoader() {
        DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().
                showImageForEmptyUri(R.drawable.ic_launcher)
                .cacheInMemory(true).cacheOnDisk(true).build();
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                getApplicationContext()).defaultDisplayImageOptions(defaultOptions)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .diskCacheFileNameGenerator(new Md5FileNameGenerator())
                .tasksProcessingOrder(QueueProcessingType.LIFO).build();
        ImageLoader.getInstance().init(config);
    }
    private void initGuide() {
        lmBanners = (LMBanners) findViewById(R.id.banners);
        lmBanners.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
        lmBanners.isGuide(true);
//        lmBanners.setVertical(true);
        lmBanners.setAutoPlay(false);
        lmBanners.setCanLoop(false);
        lmBanners.setScrollDurtion(1200);
        lmBanners.setIndicatorBottomPadding(30);
        lmBanners.setIndicatorWidth(10);
//      lmBanners.setHoriZontalTransitionEffect(TransitionEffect.Default);
        lmBanners.setHoriZontalCustomTransformer(new ParallaxTransformer(R.id.id_image));
        lmBanners.setIndicatorPosition(LMBanners.IndicaTorPosition.BOTTOM_MID);
        //本地用法
        lmBanners.setAdapter(new LocalImgAdapter(GuideActivity.this), localImages);

        /**
         * 若btnBgColor为-1，则表示不需要任何背景色
         * textColor 文字颜色
         * 点击事件
         */
//        lmBanners.setOnStartListener(-1,getResources().getColor(R.color.colorAccent),****);
        lmBanners.setOnStartListener(R.drawable.button_shape,0XFFAACCBB,new LMBanners.onStartListener() {
            @Override
            public void startOpen() {
                //回调跳转的逻辑
                startActivity(new Intent(GuideActivity.this,MainActivity.class));
                Toast.makeText(GuideActivity.this, "进入Banners", 1).show();
            }
        });
    }


    @Override
    protected void onPause() {
        super.onPause();
        lmBanners.stopImageTimerTask();
    }

    @Override
    protected void onResume() {
        super.onResume();
        lmBanners.startImageTimerTask();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        lmBanners.clearImageTimerTask();
    }


}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/viewpager/HorizonVerticalViewPager.java<|end_filename|>
package com.allure.lbanners.viewpager;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.allure.lbanners.transformer.vertical.VerticalPageTransformer;


public class HorizonVerticalViewPager extends MyViewPager{
	private boolean isVertical = false;

    public boolean isVertical() {
        return isVertical;
    }

    public void setIsVertical(boolean isVertical) {
        this.isVertical = isVertical;
    }

    public HorizonVerticalViewPager(Context context) {
        super(context);
        init();
    }

    public HorizonVerticalViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
//        initIsVertical(attrs, 0);
        init();
    }
    
    public HorizonVerticalViewPager(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs);
//        initIsVertical(attrs, defStyle);
        init();
    }
    
//    private void initIsVertical(AttributeSet attrs, int defStyle){
//    	final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomViewPager, defStyle, 0);
//    	isVertical = a.getBoolean(R.styleable.CustomViewPager_isVertical, false);
//    	System.out.println("isVertical=>" + isVertical);
//    	a.recycle();
//    }

    public void init() {
    	if(isVertical){
    		// The majority of the magic happens here
//    		setPageTransformer(true, new ParallaxTransformer(R.id.id_image));
            setPageTransformer(true, new VerticalPageTransformer());
    		// The easiest way to get rid of the overscroll drawing that happens on the left and right
    		setOverScrollMode(OVER_SCROLL_NEVER);
    	}
    }


    /**
     * Swaps the X and Y coordinates of your touch event.
     */
    private MotionEvent swapXY(MotionEvent ev) {
        float width = getWidth();
        float height = getHeight();

        float newX = (ev.getY() / height) * width;
        float newY = (ev.getX() / width) * height;

        ev.setLocation(newX, newY);

        return ev;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev){
    	if (isVertical) {
    		boolean intercepted = super.onInterceptTouchEvent(swapXY(ev));
    		swapXY(ev); // return touch coordinates to original reference frame for any child views
    		return intercepted;
		}else {
			return super.onInterceptTouchEvent(ev);
		}
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
    	if (isVertical) {
    		return super.onTouchEvent(swapXY(ev));
		}else {
			return super.onTouchEvent(ev);
		}
    }
}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/transformer/ZoomFadePageTransformer.java<|end_filename|>
package com.allure.lbanners.transformer;

import android.view.View;

import com.nineoldandroids.view.ViewHelper;

/**
 * Created by lm on 2016/7/8.
 */
public class ZoomFadePageTransformer extends LMPageTransformer {

    @Override
    public void scrollInvisible(View view, float position) {
    }

    @Override
    public void scrollLeft(View view, float position) {
        ViewHelper.setTranslationX(view, -view.getWidth() * position);

        ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
        ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
        ViewHelper.setScaleX(view, 1 + position);
        ViewHelper.setScaleY(view, 1 + position);

        ViewHelper.setAlpha(view, 1 + position);
    }

    @Override
    public void scrollRight(View view, float position) {
        ViewHelper.setTranslationX(view, -view.getWidth() * position);

        ViewHelper.setPivotX(view,view.getWidth() * 0.5f);
        ViewHelper.setPivotY(view, view.getHeight() * 0.5f);
        ViewHelper.setScaleX(view, 1 - position);
        ViewHelper.setScaleY(view, 1 - position);
        ViewHelper.setAlpha(view, 1 - position);
    }


}

<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/transformer/DefaultPageTransformer.java<|end_filename|>
package com.allure.lbanners.transformer;

import android.view.View;

/**
 * Created by lm on 2016/7/8.
 */
public class DefaultPageTransformer extends LMPageTransformer {


    @Override
    public void scrollInvisible(View view, float position) {

    }

    @Override
    public void scrollLeft(View view, float position) {

    }

    @Override
    public void scrollRight(View view, float position) {

    }
}

<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/viewpager/CustomViewPager.java<|end_filename|>
package com.allure.lbanners.viewpager;

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

/**
 * 可锤子滑动，可禁滑动的Viewpager
 * Created by lm on 2016/7/7.
 */
public class CustomViewPager extends ViewPager {
    private boolean isScrollEnabled = true;

    public CustomViewPager(Context context) {
        super(context);
    }

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return this.isScrollEnabled && super.onTouchEvent(event);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        return this.isScrollEnabled && super.onInterceptTouchEvent(event);

    }

    public void setScrollEnabled(boolean b) {
        this.isScrollEnabled = b;
    }}


<|start_filename|>lm_banner_library/src/main/java/com/allure/lbanners/viewpager/MyViewPager.java<|end_filename|>
package com.allure.lbanners.viewpager;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 判断disptch事件分发
 */
public class MyViewPager extends CustomViewPager {

    public MyViewPager(Context context) {
        super(context);
    }

    public MyViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                if (listener != null) {
                    listener.onTouchDown();
                }
                break;
            case MotionEvent.ACTION_UP:
                if (listener != null) {
                    listener.onTouchUp();
                }
                break;
            default:
                break;
        }
        return super.dispatchTouchEvent(ev);
    }

    private OnViewPagerTouchEvent listener;

    public void setOnViewPagerTouchEventListener(OnViewPagerTouchEvent l) {
        listener = l;
    }

    public interface OnViewPagerTouchEvent {
        void onTouchDown();

        void onTouchUp();
    }
}


<|start_filename|>app/src/main/java/com/allure/lmbanners/adapter/LocalImgAdapter.java<|end_filename|>
package com.allure.lmbanners.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import com.allure.lbanners.LMBanners;
import com.allure.lbanners.adapter.LBaseAdapter;
import com.allure.lmbanners.R;

/**
 * Created by luomin on 16/7/12.
 */
public class LocalImgAdapter implements LBaseAdapter<Integer> {
    private Context mContext;

    public LocalImgAdapter(Context context) {
        mContext=context;
    }

    @Override
    public View getView(final LMBanners lBanners, final Context context, int position, Integer data) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.id_image);
        imageView.setImageResource(data);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        return view;
    }


}
