Search in sources :

Example 1 with HomeBannerInfos

use of com.seven.seven.home.model.HomeBannerInfos in project seven_develop by seven123456.

the class HomeFragment method disposeHomeFragmentData.

@Subscribe(threadMode = ThreadMode.MAIN, priority = 0, sticky = true)
public void disposeHomeFragmentData(HomeEvents homeEvents) {
    switch(homeEvents.getWhat()) {
        case Constans.HOMEDATA:
            HomeNewsInfos homeNewsInfos = (HomeNewsInfos) homeEvents.getData();
            newsInfosList = homeNewsInfos.getDatas();
            if (newsInfosList != null) {
                errorLayoutView.hide();
            }
            if (!isRefresh) {
                homeCommonAdapter.setNewData(newsInfosList);
                isRefresh = true;
                homeCommonAdapter.setEnableLoadMore(true);
            } else {
                if (newsInfosList != null) {
                    homeCommonAdapter.addData(newsInfosList);
                } else {
                    homeCommonAdapter.loadMoreEnd(true);
                }
            }
            PAGE_COUNT = homeNewsInfos.getPageCount();
            break;
        case Constans.HOMEBANNER:
            homeBannerInfos = (List<HomeBannerInfos>) homeEvents.getData();
            initRecyclerHeadView(homeBannerInfos);
            if (homeBannerInfos != null) {
                errorLayoutView.hide();
            }
            break;
        case Constans.HOMEERROR:
            showErrorToast((String) homeEvents.getData());
            errorLayoutView.showErrorView();
            break;
        case Constans.HOMEDASUCCESS:
            errorLayoutView.hide();
            break;
    }
    // }
    swipeRefreshLayout.setRefreshing(false);
}
Also used : HomeBannerInfos(com.seven.seven.home.model.HomeBannerInfos) HomeNewsInfos(com.seven.seven.home.model.HomeNewsInfos) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 2 with HomeBannerInfos

use of com.seven.seven.home.model.HomeBannerInfos in project seven_develop by seven123456.

the class HomeFragment method initRecyclerHeadView.

private void initRecyclerHeadView(List<HomeBannerInfos> homeBannerInfos) {
    bannerViewAdapter = new BannerViewAdapter(R.layout.recycler_item_banner, homeBannerInfos, getContext());
    bannerLayout.setAdapter(bannerViewAdapter);
    bannerViewAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {

        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
            HomeBannerInfos homeBannerInfos = (HomeBannerInfos) adapter.getItem(position);
            HomeToWebViewInfo homeToWebViewInfo = new HomeToWebViewInfo();
            Intent intent = new Intent(getContext(), HomeNewsDetailActivity.class);
            homeToWebViewInfo.title = homeBannerInfos.getTitle();
            homeToWebViewInfo.imgUrl = homeBannerInfos.getImagePath();
            homeToWebViewInfo.h5Url = homeBannerInfos.getUrl();
            intent.putExtra("newsInfo", homeToWebViewInfo);
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) getContext(), view.findViewById(R.id.iv_banner_image), getResources().getString(R.string.transition_news_img));
            ActivityCompat.startActivity(getContext(), intent, options.toBundle());
        }
    });
}
Also used : HomeBannerInfos(com.seven.seven.home.model.HomeBannerInfos) HomeToWebViewInfo(com.seven.seven.home.model.HomeToWebViewInfo) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) BannerViewAdapter(com.seven.seven.home.adapter.BannerViewAdapter) MainActivity(com.seven.seven.ui.MainActivity) Activity(android.app.Activity) Intent(android.content.Intent) ErrorLayoutView(com.seven.seven.common.view.ErrorLayoutView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Aggregations

HomeBannerInfos (com.seven.seven.home.model.HomeBannerInfos)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 ErrorLayoutView (com.seven.seven.common.view.ErrorLayoutView)1 BannerViewAdapter (com.seven.seven.home.adapter.BannerViewAdapter)1 HomeNewsInfos (com.seven.seven.home.model.HomeNewsInfos)1 HomeToWebViewInfo (com.seven.seven.home.model.HomeToWebViewInfo)1 MainActivity (com.seven.seven.ui.MainActivity)1 Subscribe (org.greenrobot.eventbus.Subscribe)1