Search in sources :

Example 6 with NewsBanner

use of cn.nicolite.palm300heroes.model.bean.NewsBanner 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();
    }
}
Also used : TYAreaAdapter(cn.nicolite.palm300heroes.view.adapter.TYAreaAdapter) OnNetWorkErrorListener(com.github.jdsjlzx.interfaces.OnNetWorkErrorListener) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) WebViewActivity(cn.nicolite.palm300heroes.view.activity.WebViewActivity) ImageView(android.widget.ImageView) ITYAreaView(cn.nicolite.palm300heroes.view.iview.ITYAreaView) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) NativeExpressADView(com.qq.e.ads.nativ.NativeExpressADView) View(android.view.View) TYAreaPresenter(cn.nicolite.palm300heroes.presenter.TYAreaPresenter) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) ImageView(android.widget.ImageView) NewsBanner(cn.nicolite.palm300heroes.model.bean.NewsBanner) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener) BGABanner(cn.bingoogolapple.bgabanner.BGABanner)

Example 7 with NewsBanner

use of cn.nicolite.palm300heroes.model.bean.NewsBanner in project Palm300Heroes by nicolite.

the class NewsModel method getNewsBannerList.

public static List<NewsBanner> getNewsBannerList(Document document) {
    List<NewsBanner> list = new ArrayList<>();
    Elements bd = document.body().getElementsByClass("bd");
    for (Element element : bd) {
        Elements a = element.select("a");
        Elements img = element.select("img");
        for (int i = 0; i < Math.min(a.size(), img.size()); i++) {
            NewsBanner newsBanner = new NewsBanner();
            newsBanner.setUrl(a.get(i).attr("abs:href"));
            newsBanner.setImage(img.get(i).attr("abs:src"));
            newsBanner.setTitle(" ");
            list.add(newsBanner);
        }
    }
    return list;
}
Also used : Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) NewsBanner(cn.nicolite.palm300heroes.model.bean.NewsBanner) Elements(org.jsoup.select.Elements)

Aggregations

NewsBanner (cn.nicolite.palm300heroes.model.bean.NewsBanner)7 ImageView (android.widget.ImageView)3 ArrayList (java.util.ArrayList)3 Elements (org.jsoup.select.Elements)3 Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 View (android.view.View)1 BindView (butterknife.BindView)1 BGABanner (cn.bingoogolapple.bgabanner.BGABanner)1 TYAreaPresenter (cn.nicolite.palm300heroes.presenter.TYAreaPresenter)1 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)1 TYAreaAdapter (cn.nicolite.palm300heroes.view.adapter.TYAreaAdapter)1 ITYAreaView (cn.nicolite.palm300heroes.view.iview.ITYAreaView)1 OnNetWorkErrorListener (com.github.jdsjlzx.interfaces.OnNetWorkErrorListener)1 OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)1 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)1 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)1 NativeExpressADView (com.qq.e.ads.nativ.NativeExpressADView)1 Element (org.jsoup.nodes.Element)1