Search in sources :

Example 1 with SquareArticleAdapter

use of com.knight.wanandroid.module_square.module_adapter.SquareArticleAdapter in project wanandroid by KnightAndroid.

the class SquareFragment method initView.

@Override
protected void initView(Bundle savedInstanceState) {
    mDatabind.setClick(new ProcyClick());
    loadLoading(mDatabind.squareSharearticleFreshlayout);
    mHotKeyAdapter = new HotKeyAdapter(new ArrayList<SearchHotKeyEntity>());
    mSquareArticleAdapter = new SquareArticleAdapter(new ArrayList<SquareArticleEntity>());
    initListener();
    FlexboxLayoutManager flexboxLayoutManager = new FlexboxLayoutManager(getActivity());
    // 方向 主轴为水平方向,起点在左端
    flexboxLayoutManager.setFlexDirection(FlexDirection.ROW);
    // 左对齐
    flexboxLayoutManager.setJustifyContent(JustifyContent.FLEX_START);
    // flexboxLayoutManager.setAlignItems(AlignItems.CENTER);
    SetInitCustomView.initSwipeRecycleview(mDatabind.squareSearchhotRv, flexboxLayoutManager, mHotKeyAdapter, false);
    SetInitCustomView.initSwipeRecycleview(mDatabind.squareArticleRv, new LinearLayoutManager(getActivity()), mSquareArticleAdapter, true);
    mDatabind.squareSharearticleFreshlayout.setOnRefreshListener(this);
    mDatabind.squareSharearticleFreshlayout.setOnLoadMoreListener(this);
    EventBus.getDefault().register(this);
    View QuestionMenu = LayoutInflater.from(getActivity()).inflate(R.layout.square_question_activity, null);
    mSquareQuestionAdapter = new SquareQuestionAdapter(new ArrayList<>());
    initAdapterListener();
    baserecycleview = QuestionMenu.findViewById(R.id.base_body_rv);
    smartRefreshLayout = (SmartRefreshLayout) QuestionMenu.findViewById(R.id.include_square_question);
    tv_question_title = ((TextView) QuestionMenu.findViewById(R.id.square_question_tv_title));
    tv_question_title.setText(getString(R.string.square_question));
    smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
        questionPage = 1;
        mPresenter.requestSquareQuestion(questionPage);
    });
    smartRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
            mPresenter.requestSquareQuestion(questionPage);
        }
    });
    SetInitCustomView.initSwipeRecycleview(baserecycleview, new LinearLayoutManager(getActivity()), mSquareQuestionAdapter, true);
    mDatabind.squareRoot.addView(QuestionMenu);
    LoadSir loadSir = LoadSir.getDefault();
    mViewLoadService = loadSir.register(QuestionMenu.findViewById(R.id.include_square_question), new Callback.OnReloadListener() {

        @Override
        public void onReload(View v) {
            mViewLoadService.showCallback(LoadCallBack.class);
        }
    });
    mViewLoadService.showCallback(LoadCallBack.class);
    mRightLottieAnimation = new RightLottieAnimation.GuillotineBuilder(QuestionMenu, QuestionMenu.findViewById(R.id.square_question_lefticon), mDatabind.squareIvQuestion, mSquareQuestionAdapter).setStartDelay(RIPPLE_DURATION).setActionBarViewForAnimation(mDatabind.squareToolbar).setClosedOnStart(true).setGuillotineListener(new RightLottieListener() {

        @Override
        public void onRightLottieOpened() {
            mDatabind.squareFabUp.setVisibility(View.GONE);
            mViewLoadService.showCallback(LoadCallBack.class);
            mPresenter.requestSquareQuestion(questionPage);
        }

        @Override
        public void onRightLottieClosed() {
            questionPage = 1;
            mDatabind.squareFabUp.setVisibility(View.VISIBLE);
        }
    }).build();
}
Also used : OnLoadMoreListener(com.scwang.smart.refresh.layout.listener.OnLoadMoreListener) RightLottieListener(com.knight.wanandroid.library_widget.lottie.RightLottieListener) HotKeyAdapter(com.knight.wanandroid.module_square.module_adapter.HotKeyAdapter) SquareArticleAdapter(com.knight.wanandroid.module_square.module_adapter.SquareArticleAdapter) FlexboxLayoutManager(com.google.android.flexbox.FlexboxLayoutManager) ArrayList(java.util.ArrayList) 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) SquareQuestionAdapter(com.knight.wanandroid.module_square.module_adapter.SquareQuestionAdapter) RefreshLayout(com.scwang.smart.refresh.layout.api.RefreshLayout) SmartRefreshLayout(com.scwang.smart.refresh.layout.SmartRefreshLayout) LoadCallBack(com.knight.wanandroid.library_base.loadsir.LoadCallBack) TextView(android.widget.TextView) LoadSir(com.kingja.loadsir.core.LoadSir)

Aggregations

View (android.view.View)1 TextView (android.widget.TextView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 FlexboxLayoutManager (com.google.android.flexbox.FlexboxLayoutManager)1 LoadSir (com.kingja.loadsir.core.LoadSir)1 LoadCallBack (com.knight.wanandroid.library_base.loadsir.LoadCallBack)1 SetInitCustomView (com.knight.wanandroid.library_widget.SetInitCustomView)1 RightLottieListener (com.knight.wanandroid.library_widget.lottie.RightLottieListener)1 HotKeyAdapter (com.knight.wanandroid.module_square.module_adapter.HotKeyAdapter)1 SquareArticleAdapter (com.knight.wanandroid.module_square.module_adapter.SquareArticleAdapter)1 SquareQuestionAdapter (com.knight.wanandroid.module_square.module_adapter.SquareQuestionAdapter)1 SmartRefreshLayout (com.scwang.smart.refresh.layout.SmartRefreshLayout)1 RefreshLayout (com.scwang.smart.refresh.layout.api.RefreshLayout)1 OnLoadMoreListener (com.scwang.smart.refresh.layout.listener.OnLoadMoreListener)1 SwipeRecyclerView (com.yanzhenjie.recyclerview.SwipeRecyclerView)1 ArrayList (java.util.ArrayList)1