use of cn.bingoogolapple.bgabanner.BGABanner in project BGARefreshLayout-Android by bingoogolapple.
the class DataEngine method getCustomHeaderView.
public static View getCustomHeaderView(final Context context) {
View headerView = View.inflate(context, R.layout.view_custom_header, null);
final BGABanner banner = headerView.findViewById(R.id.banner);
banner.setAdapter(new BGABanner.Adapter<ImageView, String>() {
@Override
public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
Glide.with(itemView.getContext()).load(model).apply(new RequestOptions().placeholder(R.mipmap.holder).error(R.mipmap.holder).dontAnimate().centerCrop()).into(itemView);
}
});
banner.setDelegate(new BGABanner.Delegate<ImageView, String>() {
@Override
public void onBannerItemClick(BGABanner banner, ImageView imageView, String model, int position) {
Toast.makeText(banner.getContext(), "点击了第" + (position + 1) + "页", Toast.LENGTH_SHORT).show();
}
});
App.getInstance().getEngine().getBannerModel().enqueue(new Callback<BannerModel>() {
@Override
public void onResponse(Call<BannerModel> call, Response<BannerModel> response) {
BannerModel bannerModel = response.body();
if (bannerModel == null) {
return;
}
banner.setData(R.layout.view_image, bannerModel.imgs, bannerModel.tips);
}
@Override
public void onFailure(Call<BannerModel> call, Throwable t) {
}
});
return headerView;
}
use of cn.bingoogolapple.bgabanner.BGABanner in project Palm300Heroes by nicolite.
the class NewsFragment method doBusiness.
@Override
protected void doBusiness() {
newsPresenter = new NewsPresenter(this, this);
View headView = LayoutInflater.from(context).inflate(R.layout.news_headview, rootView, false);
bgaBanner = headView.findViewById(R.id.banner_guide_content);
bgaBanner.setAdapter(new BGABanner.Adapter() {
@Override
public void fillBannerItem(BGABanner banner, View itemView, Object model, int position) {
if (itemView instanceof ImageView) {
Glide.with(context).load((String) model).placeholder(R.drawable.img_loading).error(R.drawable.img_error).skipMemoryCache(true).centerCrop().dontAnimate().into((ImageView) itemView);
}
}
});
bgaBanner.setDelegate(new BGABanner.Delegate() {
@Override
public void onBannerItemClick(BGABanner banner, View itemView, Object model, int position) {
if (itemView instanceof ImageView) {
String url = bannerList.get(position).getUrl();
if (url.contains("/details/")) {
Bundle bundle = new Bundle();
bundle.putInt("type", WebViewActivity.TYPE_NEWS);
bundle.putString("url", url);
bundle.putString("title", "资讯详情");
startActivity(WebViewActivity.class, bundle);
} else {
Bundle bundle = new Bundle();
bundle.putInt("type", WebViewActivity.TYPE_NEWS_BANNER);
bundle.putString("url", url);
bundle.putString("title", "资讯详情");
startActivity(WebViewActivity.class, bundle);
}
}
}
});
View record = headView.findViewById(R.id.record);
View equipment = headView.findViewById(R.id.equipment);
View fightSkill = headView.findViewById(R.id.fightSkill);
View talent = headView.findViewById(R.id.talent);
record.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putInt("type", ContainerActivity.TYPE_NEWS_LIST);
startActivity(ContainerActivity.class, bundle);
}
});
equipment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bundle bundle = new Bundle();
bundle.putInt("type", ContainerActivity.TYPE_RECORD_RANK_TITLE);
bundle.putString("title", "服务器排行榜");
bundle.putInt("extra", HostRankFragment.TYPE_RANK_TITLE);
startActivity(ContainerActivity.class, bundle);
}
});
fightSkill.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(FightSkillActivity.class);
}
});
talent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(TalentActivity.class);
}
});
List<View> viewList = new ArrayList<>();
viewList.add(record);
viewList.add(equipment);
viewList.add(fightSkill);
viewList.add(talent);
for (int i = 0; i < viewList.size(); i++) {
View itemView = viewList.get(i);
ImageView menuImg = itemView.findViewById(R.id.menu_img);
TextView menuText = itemView.findViewById(R.id.menu_text);
menuImg.setImageResource(menuImgs[i]);
menuText.setText(menuTexts[i]);
}
lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
lRecyclerViewAdapter = new LRecyclerViewAdapter(new NewsAdapter(context, newsList));
lRecyclerView.setAdapter(lRecyclerViewAdapter);
lRecyclerViewAdapter.addHeaderView(headView);
lRecyclerView.setLoadMoreEnabled(false);
lRecyclerView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
bannerViewList.clear();
model.clear();
tips.clear();
newsPresenter.showBanner();
newsPresenter.showNews();
}
});
lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
News news = newsList.get(position);
if (!news.getNewsUrl().contains("/details/")) {
Bundle bundle = new Bundle();
bundle.putString("title", news.getNewsTitle());
bundle.putString("url", news.getNewsUrl());
bundle.putInt("type", WebViewActivity.TYPE_OTHERS);
startActivity(WebViewActivity.class, bundle);
} else {
Bundle bundle = new Bundle();
bundle.putString("url", news.getNewsUrl());
bundle.putString("title", news.getNewsTitle());
bundle.putInt("type", WebViewActivity.TYPE_NEWS);
startActivity(WebViewActivity.class, bundle);
}
}
});
if (isFirstVisible && ListUtils.isEmpty(newsList)) {
lRecyclerView.forceToRefresh();
}
}
use of cn.bingoogolapple.bgabanner.BGABanner in project Palm300Heroes by nicolite.
the class TYAreaListFragment method doBusiness.
@Override
protected void doBusiness() {
lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
lRecyclerViewAdapter = new LRecyclerViewAdapter(new TYAreaAdapter(context, dataList));
lRecyclerView.setAdapter(lRecyclerViewAdapter);
lRecyclerView.setLoadMoreEnabled(false);
if (url.equals(Constants.JUMPW_COSPLAY_RUL)) {
View headView = LayoutInflater.from(context).inflate(R.layout.tyarea_cos_headview, rootView, false);
bgaBanner = headView.findViewById(R.id.banner_guide_content);
bgaBanner.setAdapter(new BGABanner.Adapter() {
@Override
public void fillBannerItem(BGABanner banner, View itemView, Object model, int position) {
if (itemView instanceof ImageView) {
Glide.with(context).load((String) model).placeholder(R.drawable.img_loading).error(R.drawable.img_error).skipMemoryCache(true).centerCrop().dontAnimate().into((ImageView) itemView);
}
}
});
bgaBanner.setDelegate(new BGABanner.Delegate() {
@Override
public void onBannerItemClick(BGABanner banner, View itemView, Object model, int position) {
if (itemView instanceof ImageView) {
NewsBanner newsBanner = bannerList.get(position);
Bundle bundle = new Bundle();
bundle.putInt("type", WebViewActivity.TYPE_TY_COS);
bundle.putString("url", newsBanner.getUrl());
bundle.putString("title", newsBanner.getTitle());
startActivity(WebViewActivity.class, bundle);
}
}
});
lRecyclerViewAdapter.addHeaderView(headView);
}
tyAreaPresenter = new TYAreaPresenter(this, this);
lRecyclerView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
if (url.equals(Constants.JUMPW_COSPLAY_RUL)) {
bannerViewList.clear();
model.clear();
tips.clear();
tyAreaPresenter.showCosBanner();
}
tyAreaPresenter.showTYAreaList(url);
}
});
lRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {
@Override
public void reload() {
if (url.equals(Constants.JUMPW_COSPLAY_RUL)) {
bannerViewList.clear();
model.clear();
tips.clear();
tyAreaPresenter.showCosBanner();
}
tyAreaPresenter.showTYAreaList(url);
}
});
if (url.equals(Constants.JUMPW_COSPLAY_RUL) && isFirstVisible && ListUtils.isEmpty(dataList)) {
lRecyclerView.forceToRefresh();
}
}
use of cn.bingoogolapple.bgabanner.BGABanner in project BGARefreshLayout-Android by bingoogolapple.
the class ViewPagerActivity method initBanner.
private void initBanner() {
mBanner.setAdapter(new BGABanner.Adapter<ImageView, String>() {
@Override
public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
Glide.with(itemView.getContext()).load(model).apply(new RequestOptions().placeholder(R.mipmap.holder).error(R.mipmap.holder).dontAnimate()).thumbnail(0.1f).into(itemView);
}
});
App.getInstance().getEngine().getBannerModel().enqueue(new Callback<BannerModel>() {
@Override
public void onResponse(Call<BannerModel> call, Response<BannerModel> response) {
BannerModel bannerModel = response.body();
mBanner.setData(R.layout.view_image, bannerModel.imgs, bannerModel.tips);
}
@Override
public void onFailure(Call<BannerModel> call, Throwable t) {
}
});
}
use of cn.bingoogolapple.bgabanner.BGABanner in project BGARefreshLayout-Android by bingoogolapple.
the class SwipeRecyclerViewActivity method initBanner.
private void initBanner() {
mBanner.setAdapter(new BGABanner.Adapter<ImageView, String>() {
@Override
public void fillBannerItem(BGABanner banner, ImageView itemView, String model, int position) {
Glide.with(itemView.getContext()).load(model).apply(new RequestOptions().placeholder(R.mipmap.holder).error(R.mipmap.holder).dontAnimate()).thumbnail(0.1f).into(itemView);
}
});
App.getInstance().getEngine().getBannerModel().enqueue(new Callback<BannerModel>() {
@Override
public void onResponse(Call<BannerModel> call, Response<BannerModel> response) {
BannerModel bannerModel = response.body();
mBanner.setData(R.layout.view_image, bannerModel.imgs, bannerModel.tips);
}
@Override
public void onFailure(Call<BannerModel> call, Throwable t) {
}
});
}
Aggregations