Search in sources :

Example 1 with OnTwoLevelListener

use of com.scwang.smart.refresh.header.listener.OnTwoLevelListener in project wanandroid by KnightAndroid.

the class HomeRecommendFragment method initView.

@Override
protected void initView(Bundle savedInstanceState) {
    mDatabind.setClick(new ProxyClick());
    EventBus.getDefault().register(this);
    mSkeletonScreen = Skeleton.bind(mDatabind.flTest).load(R.layout.activity_home_skeleton).duration(1200).angle(0).show();
    bindHeadView();
    mTopArticleAdapter = new TopArticleAdapter(new ArrayList<>());
    SetInitCustomView.initSwipeRecycleview(home_top_article_rv, new LinearLayoutManager(getActivity()), mTopArticleAdapter, false);
    mOfficialAccountAdapter = new OfficialAccountAdapter(new ArrayList<>());
    mHomeArticleAdapter = new HomeArticleAdapter(new ArrayList<>());
    SetInitCustomView.initSwipeRecycleview(mDatabind.homeRecommendArticleBody, new LinearLayoutManager(getActivity()), mHomeArticleAdapter, true);
    topArticleFootView = LayoutInflater.from(getActivity()).inflate(R.layout.home_toparticle_foot, null);
    topArticleFootView.findViewById(R.id.home_ll_seemorearticles).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            HomeArticleLogic.getInstance().setArrowAnimate(mTopArticleAdapter, topArticleFootView.findViewById(R.id.home_iv_toparticlearrow), isShowOnlythree);
            isShowOnlythree = !isShowOnlythree;
        }
    });
    mDatabind.homeIconFab.setBackgroundTintList(ColorUtils.createColorStateList(CacheUtils.getThemeColor(), CacheUtils.getThemeColor()));
    initTopAdapterClick();
    initOfficialAccountClick();
    initArticleListener();
    initTwoLevel();
    mDatabind.homeRefreshLayout.setOnMultiListener(new SimpleMultiListener() {

        @Override
        public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, int headerHeight, int maxDragHeight) {
        }

        @Override
        public void onRefresh(@NonNull RefreshLayout refreshLayout) {
            lazyLoadData();
        }

        @Override
        public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
            if (oldState == RefreshState.TwoLevel) {
                mDatabind.homeTwoLevelContent.animate().alpha(0).setDuration(0);
            } else if (oldState == RefreshState.TwoLevelReleased) {
                openTwoLevel = true;
                mDatabind.homeIconFab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.base_icon_bottom));
            } else if (oldState == RefreshState.TwoLevelFinish) {
                openTwoLevel = false;
                mDatabind.homeIconFab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.base_icon_up));
            }
        }
    });
    mDatabind.homeTwoLevelHeader.setOnTwoLevelListener(new OnTwoLevelListener() {

        @Override
        public boolean onTwoLevel(@NonNull RefreshLayout refreshLayout) {
            mDatabind.homeTwoLevelContent.animate().alpha(1).setDuration(1000);
            return true;
        }
    });
    mDatabind.homeTwoLevelHeader.setEnablePullToCloseTwoLevel(false);
    mDatabind.homeRefreshLayout.setEnableLoadMore(true);
    mDatabind.homeRefreshLayout.setOnLoadMoreListener(this);
}
Also used : RefreshHeader(com.scwang.smart.refresh.layout.api.RefreshHeader) ArrayList(java.util.ArrayList) HomeArticleAdapter(com.knight.wanandroid.module_home.module_adapter.HomeArticleAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) TextView(android.widget.TextView) SetInitCustomView(com.knight.wanandroid.library_widget.SetInitCustomView) SwipeRecyclerView(com.yanzhenjie.recyclerview.SwipeRecyclerView) OfficialAccountAdapter(com.knight.wanandroid.module_home.module_adapter.OfficialAccountAdapter) SimpleMultiListener(com.scwang.smart.refresh.layout.simple.SimpleMultiListener) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) OnTwoLevelListener(com.scwang.smart.refresh.header.listener.OnTwoLevelListener) RefreshState(com.scwang.smart.refresh.layout.constant.RefreshState) TopArticleAdapter(com.knight.wanandroid.module_home.module_adapter.TopArticleAdapter)

Aggregations

View (android.view.View)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 SetInitCustomView (com.knight.wanandroid.library_widget.SetInitCustomView)1 HomeArticleAdapter (com.knight.wanandroid.module_home.module_adapter.HomeArticleAdapter)1 OfficialAccountAdapter (com.knight.wanandroid.module_home.module_adapter.OfficialAccountAdapter)1 TopArticleAdapter (com.knight.wanandroid.module_home.module_adapter.TopArticleAdapter)1 OnTwoLevelListener (com.scwang.smart.refresh.header.listener.OnTwoLevelListener)1 RefreshHeader (com.scwang.smart.refresh.layout.api.RefreshHeader)1 RefreshLayout (com.scwang.smart.refresh.layout.api.RefreshLayout)1 RefreshState (com.scwang.smart.refresh.layout.constant.RefreshState)1 SimpleMultiListener (com.scwang.smart.refresh.layout.simple.SimpleMultiListener)1 SwipeRecyclerView (com.yanzhenjie.recyclerview.SwipeRecyclerView)1 ArrayList (java.util.ArrayList)1