Search in sources :

Example 1 with NewsListPresenter

use of cn.nicolite.palm300heroes.presenter.NewsListPresenter 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)

Aggregations

Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 View (android.view.View)1 BindView (butterknife.BindView)1 News (cn.nicolite.palm300heroes.model.bean.News)1 NewsListPresenter (cn.nicolite.palm300heroes.presenter.NewsListPresenter)1 WebViewActivity (cn.nicolite.palm300heroes.view.activity.WebViewActivity)1 NewsAdapter (cn.nicolite.palm300heroes.view.oldAdapter.NewsAdapter)1 OnItemClickListener (com.github.jdsjlzx.interfaces.OnItemClickListener)1 OnLoadMoreListener (com.github.jdsjlzx.interfaces.OnLoadMoreListener)1 OnRefreshListener (com.github.jdsjlzx.interfaces.OnRefreshListener)1 LRecyclerView (com.github.jdsjlzx.recyclerview.LRecyclerView)1 LRecyclerViewAdapter (com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter)1