package com.mayi.demo.view;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.mayi.demo.R;
import com.mayi.fastdevelop.base.BaseActivity;
import com.mayi.fastdevelop.view.PicassoImageLoader;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.listener.OnBannerListener;
import com.youth.banner.transformer.FlipHorizontalTransformer;

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

public class BannerActivity extends BaseActivity implements OnBannerListener {

    List list = new ArrayList();
    List listText = new ArrayList();


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner);
        list.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic1xjab4j30ci08cjrv.jpg");
        list.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic21363tj30ci08ct96.jpg");
        list.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic259ohaj30ci08c74r.jpg");
        list.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2b16zuj30ci08cwf4.jpg");
        list.add("http://ww4.sinaimg.cn/large/006uZZy8jw1faic2e7vsaj30ci08cglz.jpg");

        listText.add("1");
        listText.add("2");
        listText.add("3");
        listText.add("4");
        listText.add("5");


        Banner banner1 = findViewById(R.id.banner1);
        banner1.setIndicatorGravity(BannerConfig.LEFT);//设置指示器位置
        banner1.updateBannerStyle(BannerConfig.NUM_INDICATOR_TITLE);//设置样式
        banner1.setImages(list)
                .setBannerTitles(listText)//设置图片文字
                .setBannerAnimation(FlipHorizontalTransformer.class)//设置动画
                .setImageLoader(new PicassoImageLoader())
                .setOnBannerListener(this)
                .start();

        Banner banner2 = findViewById(R.id.banner2);
        List<Integer> list = new ArrayList<>();
        list.add(R.mipmap.b1);
        list.add(R.mipmap.b2);
        list.add(R.mipmap.b3);

        banner2.setImages(list)
                .setImageLoader(new PicassoImageLoader())
                .start();
    }

    @Override
    public void OnBannerClick(int position) {
        showToast("position=" + position);
    }

}
