Search in sources :

Example 1 with News

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

the class NewsListFragment method doBusiness.

@Override
protected void doBusiness() {
    lRecyclerView.setLayoutManager(new LinearLayoutManager(context, OrientationHelper.VERTICAL, false));
    lRecyclerViewAdapter = new LRecyclerViewAdapter(new NewsAdapter(context, dataList));
    lRecyclerView.setAdapter(lRecyclerViewAdapter);
    newsListPresenter = new NewsListPresenter(this, this);
    lRecyclerView.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            newsListPresenter.loadNewsList(url, type);
        }
    });
    lRecyclerView.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore() {
            currentPage++;
            newsListPresenter.loadMoreNewsList(url, type, currentPage);
        }
    });
    lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            News news = dataList.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 (url.equals(Constants.JUMP_NEWS_URL) && isFirstVisible && ListUtils.isEmpty(dataList)) {
        lRecyclerView.forceToRefresh();
    }
}
Also used : OnLoadMoreListener(com.github.jdsjlzx.interfaces.OnLoadMoreListener) OnItemClickListener(com.github.jdsjlzx.interfaces.OnItemClickListener) NewsListPresenter(cn.nicolite.palm300heroes.presenter.NewsListPresenter) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) WebViewActivity(cn.nicolite.palm300heroes.view.activity.WebViewActivity) BindView(butterknife.BindView) LRecyclerView(com.github.jdsjlzx.recyclerview.LRecyclerView) View(android.view.View) LRecyclerViewAdapter(com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter) News(cn.nicolite.palm300heroes.model.bean.News) NewsAdapter(cn.nicolite.palm300heroes.view.oldAdapter.NewsAdapter) OnRefreshListener(com.github.jdsjlzx.interfaces.OnRefreshListener)

Example 2 with News

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

the class NewsModel method getNewsList.

public static List<News> getNewsList(Document document, String newsType) {
    List<News> newsList = new ArrayList<>();
    Elements newses = document.body().getElementsByClass("newsList");
    for (Element element : newses) {
        Elements content = element.getElementsByTag("a");
        Elements dates = element.getElementsByTag("h2");
        for (int i = 0; i < Math.min(content.size(), dates.size()); i++) {
            News news = new News();
            news.setNewsTitle(content.get(i).text());
            news.setNewsUrl(content.get(i).attr("abs:href"));
            news.setNewsDate(dates.get(i).text());
            news.setNewsType(newsType);
            newsList.add(news);
        }
    }
    return newsList;
}
Also used : News(cn.nicolite.palm300heroes.model.bean.News) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) Elements(org.jsoup.select.Elements)

Example 3 with News

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

the class NewsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(NewsViewHolder holder, int position) {
    News news = newsList.get(position);
    Glide.with(context).load(news.getNewsImage()).placeholder(R.drawable.img_loading).error(R.drawable.img_loading).skipMemoryCache(true).dontAnimate().into(holder.image);
    holder.title.setText(news.getNewsTitle());
    holder.date.setText(news.getNewsDate());
}
Also used : News(cn.nicolite.palm300heroes.model.bean.News)

Example 4 with News

use of cn.nicolite.palm300heroes.model.bean.News 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 5 with News

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

the class NewsModel method getMainNesList.

public static List<News> getMainNesList(Document document) {
    List<News> list = new ArrayList<>();
    Element idTab1 = document.body().getElementById("idTab1");
    Elements a = idTab1.select("a");
    Elements span = idTab1.select("span");
    // for (int i = 0; i < Math.min(a.size(), span.size()); i++) {
    // News news = new News();
    // news.setNewsTitle(a.get(i).text());
    // news.setNewsUrl(a.get(i).attr("abs:href"));
    // news.setNewsType("综合");
    // news.setNewsDate(span.get(i).text().replace("[", "")
    // .replace("]", ""));
    // list.add(news);
    // }
    Element idTab4 = document.body().getElementById("idTab4");
    Elements a3 = idTab4.select("a");
    Elements span3 = idTab4.select("span");
    for (int i = 0; i < Math.min(a3.size(), span3.size()); i++) {
        News news = new News();
        news.setNewsTitle(a3.get(i).text());
        news.setNewsUrl(a3.get(i).attr("abs:href"));
        news.setNewsType("公告");
        news.setNewsDate(span3.get(i).text().replace("[", "").replace("]", ""));
        list.add(news);
    }
    Element idTab2 = document.body().getElementById("idTab2");
    Elements a1 = idTab2.select("a");
    Elements span1 = idTab2.select("span");
    for (int i = 0; i < Math.min(a1.size(), span1.size()); i++) {
        News news = new News();
        news.setNewsTitle(a1.get(i).text());
        news.setNewsUrl(a1.get(i).attr("abs:href"));
        news.setNewsType("新闻");
        news.setNewsDate(span1.get(i).text().replace("[", "").replace("]", ""));
        list.add(news);
    }
    Element idTab3 = document.body().getElementById("idTab3");
    Elements a2 = idTab3.select("a");
    Elements span2 = idTab3.select("span");
    for (int i = 0; i < Math.min(a2.size(), span2.size()); i++) {
        News news = new News();
        news.setNewsTitle(a2.get(i).text());
        news.setNewsUrl(a2.get(i).attr("abs:href"));
        news.setNewsType("活动");
        news.setNewsDate(span2.get(i).text().replace("[", "").replace("]", ""));
        list.add(news);
    }
    return list;
}
Also used : News(cn.nicolite.palm300heroes.model.bean.News) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) Elements(org.jsoup.select.Elements)

Aggregations

News (cn.nicolite.palm300heroes.model.bean.News)5 ArrayList (java.util.ArrayList)3 Bundle (android.os.Bundle)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 View (android.view.View)2 BindView (butterknife.BindView)2 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)2 NewsAdapter (cn.nicolite.palm300heroes.view.oldAdapter.NewsAdapter)2 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)2 OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)2 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)2 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)2 Element (org.jsoup.nodes.Element)2 Elements (org.jsoup.select.Elements)2 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BGABanner (cn.bingoogolapple.bgabanner.BGABanner)1 NewsListPresenter (cn.nicolite.palm300heroes.presenter.NewsListPresenter)1 NewsPresenter (cn.nicolite.palm300heroes.presenter.NewsPresenter)1 ContainerActivity (cn.nicolite.palm300heroes.view.activity.ContainerActivity)1