use of me.jingbin.banner.holder.ByBannerViewHolder in project CloudReader by youlookwhat.
the class EverydayFragment method onObserveViewModel.
private void onObserveViewModel() {
viewModel.getShowLoading().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(@Nullable Boolean aBoolean) {
showRotaLoading(aBoolean);
}
});
viewModel.getBannerData().observe(this, new Observer<EverydayViewModel.BannerDataBean>() {
@Override
public void onChanged(@Nullable EverydayViewModel.BannerDataBean bean) {
if (bean != null && bean.getImageUrls() != null && bean.getImageUrls().size() > 0) {
mHeaderBinding.banner.setAutoPlay(true).setOffscreenPageLimit(bean.getImageUrls().size()).setPages(bean.getImageUrls(), new HolderCreator<ByBannerViewHolder>() {
@Override
public ByBannerViewHolder createViewHolder() {
return new ByBannerViewHolder<String>() {
private ImageView imageView;
@Override
public View createView(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.item_banner_wanandroid, null);
imageView = (ImageView) view.findViewById(R.id.iv_banner);
return view;
}
@Override
public void onBind(Context context, int position, String data) {
DensityUtil.setWidthHeight(imageView, DensityUtil.getDisplayWidth(), 2.5f);
GlideUtil.displayEspImage(data, imageView, 3);
}
};
}
}).start();
mHeaderBinding.banner.setOnBannerClickListener(new OnBannerClickListener() {
@Override
public void onBannerClick(int position) {
if (bean.getList() != null && bean.getList().size() > 0 && !TextUtils.isEmpty(bean.getList().get(position).getCode()) && bean.getList().get(position).getCode().startsWith("http")) {
WebViewActivity.loadUrl(getContext(), bean.getList().get(position).getCode(), "加载中...");
}
}
});
isLoadBanner = true;
}
}
});
viewModel.getContentData().observe(this, new Observer<ArrayList<ArrayList<AndroidBean>>>() {
@Override
public void onChanged(@Nullable ArrayList<ArrayList<AndroidBean>> lists) {
if (lists != null && lists.size() > 0) {
mEverydayAdapter.setNewData(lists);
} else {
showError();
}
}
});
}
use of me.jingbin.banner.holder.ByBannerViewHolder in project CloudReader by youlookwhat.
the class GankHomeFragment method onObserveViewModel.
private void onObserveViewModel() {
viewModel.getShowLoading().observe(getViewLifecycleOwner(), new Observer<Boolean>() {
@Override
public void onChanged(@Nullable Boolean aBoolean) {
showRotaLoading(aBoolean);
}
});
viewModel.getBannerData().observe(getViewLifecycleOwner(), new Observer<GankIoDataBean>() {
@Override
public void onChanged(@Nullable GankIoDataBean bean) {
if (bean != null && bean.getResults() != null && bean.getResults().size() > 0) {
mHeaderBinding.banner.setDelayTime(4000).setAutoPlay(true).setOffscreenPageLimit(bean.getResults().size()).setPages(bean.getResults(), new HolderCreator<ByBannerViewHolder>() {
@Override
public ByBannerViewHolder createViewHolder() {
return new ByBannerViewHolder<GankIoDataBean.ResultBean>() {
private ImageView imageView;
@Override
public View createView(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.item_banner_wanandroid, null);
imageView = (ImageView) view.findViewById(R.id.iv_banner);
return view;
}
@Override
public void onBind(Context context, int position, GankIoDataBean.ResultBean data) {
DensityUtil.setWidthHeight(imageView, DensityUtil.getDisplayWidth(), 2.2f);
GlideUtil.displayEspImage(data.getImage(), imageView, 3);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!TextUtils.isEmpty(bean.getResults().get(position).getUrl()) && bean.getResults().get(position).getUrl().startsWith("http")) {
WebViewActivity.loadUrl(getContext(), bean.getResults().get(position).getUrl(), "干货集中营");
}
}
});
imageView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ViewBigImageActivity.start(v.getContext(), data.getImage(), data.getTitle());
return true;
}
});
}
};
}
}).start();
isLoadBanner = true;
}
}
});
viewModel.getContentData().observe(getViewLifecycleOwner(), new Observer<GankIoDataBean>() {
@Override
public void onChanged(@Nullable GankIoDataBean bean) {
bindingView.ivLoading.postDelayed(new Runnable() {
@Override
public void run() {
if (bean != null && bean.getResults() != null && bean.getResults().size() > 0) {
skeletonScreen.hide();
mAdapter.setNewData(bean.getResults());
bindingView.recyclerView.loadMoreEnd();
} else {
showError();
}
}
}, 1000);
}
});
}
Aggregations