Search in sources :

Example 11 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter 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();
    }
}
Also used : ArrayList(java.util.ArrayList) ContainerActivity(cn.nicolite.palm300heroes.view.activity.ContainerActivity) WebViewActivity(cn.nicolite.palm300heroes.view.activity.WebViewActivity) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) News(cn.nicolite.palm300heroes.model.bean.News) NewsAdapter(cn.nicolite.palm300heroes.view.oldAdapter.NewsAdapter) TextView(android.widget.TextView) ImageView(android.widget.ImageView) FightSkillActivity(cn.nicolite.palm300heroes.view.activity.FightSkillActivity) BGABanner(cn.bingoogolapple.bgabanner.BGABanner) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) NativeExpressADView(com.qq.e.ads.nativ.NativeExpressADView) View(android.view.View) INewsView(cn.nicolite.palm300heroes.view.iview.INewsView) TextView(android.widget.TextView) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) TalentActivity(cn.nicolite.palm300heroes.view.activity.TalentActivity) NewsPresenter(cn.nicolite.palm300heroes.presenter.NewsPresenter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 12 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter in project Palm300Heroes by nicolite.

the class EquJJCFragment method doBusiness.

@Override
protected void doBusiness() {
    // 根据屏幕宽度计算一行能放多少个
    int spanCount = (int) (ScreenUtils.getScreenWidth(context) / ScreenUtils.dp2px(context, 80));
    // 防止每行个数为0
    if (spanCount == 0) {
        spanCount = 4;
    }
    equJJCPresenter = new EquJJCPresenter(this, this);
    lRecyclerView.setLayoutManager(new GridLayoutManager(context, spanCount, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new EquipmentJJCAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    lRecyclerView.setLoadMoreEnabled(false);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            equJJCPresenter.showEquJJCList(true);
        }
    });
    lRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
        }
    });
    lRecyclerView.setOnNetWorkErrorListener(new OnNetWorkErrorListener() {

        @Override
        public void reload() {
        }
    });
    lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            Equipment equipment = dataList.get(position);
            String purchasePrice = equipment.getPurchasePrice() == null ? "" : String.valueOf(equipment.getPurchasePrice());
            String compoundPrice = equipment.getCompoundPrice() == null ? "无法合成" : String.valueOf(equipment.getCompoundPrice());
            String attribute = TextUtils.isEmpty(equipment.getAttribute()) ? "无" : equipment.getAttribute();
            String skill = TextUtils.isEmpty(equipment.getSkill()) ? "无" : equipment.getSkill();
            Bundle bundle = new Bundle();
            bundle.putString("picture", equipment.getPicture());
            bundle.putString("name", equipment.getName());
            bundle.putString("pp", purchasePrice);
            bundle.putString("cp", compoundPrice);
            bundle.putString("attribute", attribute);
            bundle.putString("skill", skill);
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
                startActivity(EquJJCDetailActivity.class, bundle);
            } else {
                Bundle options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, view, "equJJCTransition").toBundle();
                startActivity(EquJJCDetailActivity.class, bundle, options);
            }
        }
    });
}
Also used : OnLoadMoreListener(com.github.jdsjlzx.interfaces.OnLoadMoreListener) OnNetWorkErrorListener(com.github.jdsjlzx.interfaces.OnNetWorkErrorListener) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) Bundle(android.os.Bundle) EquipmentJJCAdapter(cn.nicolite.palm300heroes.view.oldAdapter.EquipmentJJCAdapter) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) IEquJJCView(cn.nicolite.palm300heroes.view.iview.IEquJJCView) EquJJCDetailActivity(cn.nicolite.palm300heroes.view.activity.EquJJCDetailActivity) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) GridLayoutManager(android.support.v7.widget.GridLayoutManager) Equipment(cn.nicolite.palm300heroes.model.bean.Equipment) EquJJCPresenter(cn.nicolite.palm300heroes.presenter.EquJJCPresenter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 13 with LRecyclerViewAdapter

use of com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter 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

OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)13 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)13 View (android.view.View)11 BindView (butterknife.BindView)11 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)11 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)10 Bundle (android.os.Bundle)9 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)8 OnNetWorkErrorListener (com.github.jdsjlzx.interfaces.OnNetWorkErrorListener)6 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)5 OnLoadMoreListener (com.github.jdsjlzx.interfaces.OnLoadMoreListener)5 TextView (android.widget.TextView)4 GridLayoutManager (android.support.v7.widget.GridLayoutManager)3 ActionBar (android.support.v7.app.ActionBar)2 ImageView (android.widget.ImageView)2 BGABanner (cn.bingoogolapple.bgabanner.BGABanner)2 News (cn.nicolite.palm300heroes.model.bean.News)2 ContainerActivity (cn.nicolite.palm300heroes.view.activity.ContainerActivity)2 NativeExpressADView (com.qq.e.ads.nativ.NativeExpressADView)2 Intent (android.content.Intent)1