Search in sources :

Example 6 with OnNetWorkErrorListener

use of com.github.jdsjlzx.interfaces.OnNetWorkErrorListener 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)

Aggregations

View (android.view.View)6 BindView (butterknife.BindView)6 OnNetWorkErrorListener (com.github.jdsjlzx.interfaces.OnNetWorkErrorListener)6 OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)6 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)6 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)6 Bundle (android.os.Bundle)5 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)4 GridLayoutManager (android.support.v7.widget.GridLayoutManager)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 OnLoadMoreListener (com.github.jdsjlzx.interfaces.OnLoadMoreListener)3 ActionBar (android.support.v7.app.ActionBar)2 TextView (android.widget.TextView)2 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 ImageView (android.widget.ImageView)1 BGABanner (cn.bingoogolapple.bgabanner.BGABanner)1 Bilibili (cn.nicolite.palm300heroes.model.bean.Bilibili)1 Equipment (cn.nicolite.palm300heroes.model.bean.Equipment)1 Hero (cn.nicolite.palm300heroes.model.bean.Hero)1