本文整理汇总了Java中com.youth.banner.Transformer类的典型用法代码示例。如果您正苦于以下问题:Java Transformer类的具体用法?Java Transformer怎么用?Java Transformer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transformer类属于com.youth.banner包,在下文中一共展示了Transformer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inithead
import com.youth.banner.Transformer; //导入依赖的package包/类
private void inithead(List<TopStories> topStories) {
this.topStories = topStories;
List<String> titles = new ArrayList<>();
for (int i = 0; i < topStories.size(); i++) {
titles.add(topStories.get(i).getTitle());
}
banner.setBannerTitles(titles);
// banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
//设置图片加载器
banner.setImageLoader(new GlideImageLoader());
//设置banner动画效果
banner.setBannerAnimation(Transformer.Default);
//设置自动轮播,默认为true
banner.isAutoPlay(true);
//设置轮播时间
banner.setDelayTime(5000);
//设置指示器位置(当banner模式中有指示器时)
banner.setIndicatorGravity(BannerConfig.CENTER);
//设置图片集合
banner.setImages(topStories);
//banner设置方法全部调用完毕时最后调用
banner.start();
}
示例2: initBanner
import com.youth.banner.Transformer; //导入依赖的package包/类
private void initBanner() {
List<Integer> images = new ArrayList<>();
images.add(R.drawable.banner01);
images.add(R.drawable.banner02);
images.add(R.drawable.banner03);
images.add(R.drawable.banner04);
images.add(R.drawable.bnaner05);
images.add(R.drawable.banner06);
//设置banner样式
mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
// 设置图片加载器
mBanner.setImageLoader(new GlideImageLoader());
//设置图片集合
mBanner.setImages(images);
//设置banner动画效果
mBanner.setBannerAnimation(Transformer.DepthPage);
//设置标题集合(当banner样式有显示title时)
//banner.setBannerTitles(titles);
//设置自动轮播,默认为true
mBanner.isAutoPlay(true);
//设置轮播时间
mBanner.setDelayTime(2000);
//设置指示器位置(当banner模式中有指示器时)
mBanner.setIndicatorGravity(BannerConfig.CENTER);
//banner设置方法全部调用完毕时最后调用
mBanner.start();
}
示例3: setupRecyclerViewHeader
import com.youth.banner.Transformer; //导入依赖的package包/类
/**
* 配置recyclerView头部轮播
*/
private void setupRecyclerViewHeader(Banner banner) {
List<String> images = new ArrayList<>();
List<String> titles = new ArrayList<>();
for (ArticleListBean bean :
mIsGoodArticleBeans) {
images.add(bean.getTitlepic());
titles.add(bean.getTitle());
}
banner.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (SizeUtils.getScreenHeightPx(mContext) * 0.3)));
// 配置banner
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
.setImageLoader(new FrescoImageLoader())
.setImages(images)
.setBannerTitles(titles)
.isAutoPlay(true)
.setDelayTime(5000)
.setBannerAnimation(Transformer.Default)
.setIndicatorGravity(BannerConfig.RIGHT)
.start();
// 监听banner点击事件
banner.setOnBannerClickListener(new OnBannerClickListener() {
// position 从1开始
@Override
public void OnBannerClick(int position) {
if (mOnItemTapListener != null) {
mOnItemTapListener.onItemTapListener(mIsGoodArticleBeans.get(position - 1));
}
}
});
}
示例4: setupRecyclerViewHeader
import com.youth.banner.Transformer; //导入依赖的package包/类
/**
* 配置recyclerView头部轮播
*/
private void setupRecyclerViewHeader(Banner banner) {
List<String> images = new ArrayList<>();
List<String> titles = new ArrayList<>();
for (ArticleListBean bean :
isGoodArticleBeans) {
images.add(bean.getTitlepic());
titles.add(bean.getTitle());
}
banner.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (SizeUtils.getScreenHeightPx(context) * 0.3)));
// 配置banner
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE)
.setImageLoader(new FrescoImageLoader())
.setImages(images)
.setBannerTitles(titles)
.isAutoPlay(true)
.setDelayTime(5000)
.setBannerAnimation(Transformer.Default)
.setIndicatorGravity(BannerConfig.RIGHT)
.start();
// 监听banner点击事件
banner.setOnBannerClickListener(new OnBannerClickListener() {
// position 从1开始
@Override
public void OnBannerClick(int position) {
if (onItemTapListener != null) {
onItemTapListener.onItemTapListener(isGoodArticleBeans.get(position - 1));
}
}
});
}
示例5: initView
import com.youth.banner.Transformer; //导入依赖的package包/类
/**
* 初始化界面控件
*/
private void initView() {
mImages.add(R.drawable.find_1);
mImages.add(R.drawable.find_2);
mImages.add(R.drawable.find_8);
mImages.add(R.drawable.find_4);
mImages.add(R.drawable.find_5);
mImages.add(R.drawable.find_6);
mImages.add(R.drawable.find_7);
mTitles.add("既见公子,云胡不喜?");
mTitles.add("我只想静静地,做个美男子。");
mTitles.add("曾经的曾经,只剩期望...");
mTitles.add("你那么美,爱我如何?");
mTitles.add("夜,夜,夜...");
mTitles.add("孩子,快点睡吧,明天还要抢票回家呢。");
mTitles.add("天边美丽的火烧云啊,我的生活放荡,像条狗,像条流浪狗...");
titleSearchIbtn = (ImageButton) view.findViewById(R.id.title_find_search_ibtn);
titleSearchIbtn.setOnClickListener(ThirdFragment.this);
nineGridView = (NineGridView) view.findViewById(R.id.find_nine_gridview);
nineGridView.setAdapter(new NineGridViewAdapter(getActivity()));
mBanner = (Banner) view.findViewById(R.id.banner);
mBanner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
mBanner.setBannerAnimation(Transformer.Default);
mBanner.isAutoPlay(true);
mBanner.setDelayTime(3000);
mBanner.setIndicatorGravity(BannerConfig.CENTER);
mBanner.setBannerTitles(mTitles);
mBanner.setImageLoader(new GlideImageLoader());
mBanner.setImages(mImages);
mBanner.start();
mBanner.setOnBannerClickListener(this);
}
示例6: setData
import com.youth.banner.Transformer; //导入依赖的package包/类
public void setData(final List<ResultBean.BannerInfoBean> banner_info) {
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
//如果你想用自己项目的图片加载,那么----->自定义图片加载框架
List<String> imageUris = new ArrayList<>();
for (int i = 0; i < resultBean.getBanner_info().size(); i++) {
imageUris.add(resultBean.getBanner_info().get(i).getImage());
}
banner.setBannerAnimation(Transformer.Accordion);
banner.setImages(imageUris, new OnLoadImageListener() {
@Override
public void OnLoadImage(ImageView view, Object url) {
/**
* 这里你可以根据框架灵活设置
*/
Glide.with(mContext)
.load(Constants.BASE_URl_IMAGE + url)
.into(view);
}
});
//设置点击事件
banner.setOnBannerClickListener(new OnBannerClickListener() {
@Override
public void OnBannerClick(int position) {
if(position - 1 < banner_info.size()){
int option = banner_info.get(position - 1).getOption();
String product_id = "";
String name = "";
String cover_price = "";
if (position - 1 == 0) {
product_id = "627";
cover_price = "32.00";
name = "剑三T恤批发";
} else if (position - 1 == 1) {
product_id = "21";
cover_price = "8.00";
name = "同人原创】剑网3 剑侠情缘叁 Q版成男 口袋胸针";
} else {
product_id = "1341";
cover_price = "50.00";
name = "【蓝诺】《天下吾双》 剑网3同人本";
}
String image = banner_info.get(position - 1).getImage();
GoodsBean goodsBean = new GoodsBean(name, cover_price, image, product_id);
Intent intent = new Intent(mContext, GoodsInfoActivity.class);
intent.putExtra("goods_bean", goodsBean);
mContext.startActivity(intent);
}
}
});
}
示例7: initData
import com.youth.banner.Transformer; //导入依赖的package包/类
@Override
protected void initData(String content) {
if (!TextUtils.isEmpty(content)) {
// 1.使用fastJson解析数据,并封装数据到java对象中
JSONObject jsonObject = JSON.parseObject(content);
String proInfo = jsonObject.getString("proInfo");
Product product = JSON.parseObject(proInfo, Product.class);
String imageArr = jsonObject.getString("imageArr");
List<Image> images = JSON.parseArray(imageArr, Image.class);
index = new Index();
index.product = product;
index.images = images;
// 2.设置Banner,加载显示图片
// 设置banner样式
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE);
// 设置图片加载器
banner.setImageLoader(new ImageLoader() {
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
// Picasso加载图片简单用法
Picasso.with(context).load((String) path).into(imageView);
}
});
// 设置图片url集合:imageUrl
List<String> imageUrl = new ArrayList<String>(images.size());
for (int i = 0; i < images.size(); i++) {
imageUrl.add(images.get(i).IMAURL);
Log.e("TAG", "url = " + images.get(i).IMAURL);
}
banner.setImages(imageUrl);
// 设置banner动画效果
banner.setBannerAnimation(Transformer.FlipHorizontal); // DepthPage
// 设置标题集合(当banner样式有显示title时)
String[] titles = new String[]{"深情不及久伴,加息2%", "乐享活计划", "破茧重生", "安心钱包计划"};
banner.setBannerTitles(Arrays.asList(titles));
// 设置自动轮播,默认为true
banner.isAutoPlay(true);
// 设置轮播时间
banner.setDelayTime(1500);
// 设置指示器位置(当banner模式中有指示器时)
banner.setIndicatorGravity(BannerConfig.RIGHT);
// banner设置方法全部调用完毕时最后调用
banner.start();
// 3.根据得到的产品的数据,更新界面中的产品展示
String yearRate = index.product.yearRate;
tvHomeRate.setText(yearRate + "%");
currentProgress = Integer.parseInt(index.product.progress);
new Thread(runnable).start();
}
}