package com.huawei.mediacloud.livepushdemo.main;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.huawei.mediacloud.livepushdemo.R;
import com.huawei.mediacloud.livepushdemo.base.BaseFragment;

import java.util.List;

/**
 * Created by CaoZhiChao on 2018/10/16 10:37
 */
@SuppressLint("ValidFragment")
public class MainViewPagerFragment extends BaseFragment {
    private String TAG = "MainViewPagerFragment";
    Context context;
    OnItemClickListener onItemClickListener;
    RecyclerView main_fragment_recycle;
    List<MainViewPagerFragmentData> fragmentDataList;
    private int spanCount;

    public MainViewPagerFragment(Context context, OnItemClickListener listener, List<MainViewPagerFragmentData> dataList, int count) {
        this.context = context;
        onItemClickListener = listener;
        fragmentDataList = dataList;
        spanCount = count;
    }


    @Override
    protected int initRootView() {
        return R.layout.fragment_main_viewpager_item1;
    }

    @Override
    protected void initArguments(Bundle arguments) {
    }

    @Override
    protected void initView() {
        main_fragment_recycle = (RecyclerView) mRootView.findViewById(R.id.main_fragment_recycle);
        MainViewPagerFragmentAdapter adapter = new MainViewPagerFragmentAdapter(getContext(), fragmentDataList, onItemClickListener);
        main_fragment_recycle.setAdapter(adapter);
        GridLayoutManager layoutManager = new GridLayoutManager(getContext(), spanCount);
        main_fragment_recycle.setLayoutManager(layoutManager);
        main_fragment_recycle.addItemDecoration(new GridSpacingItemDecoration(getContext(),spanCount,(int) getResources().getDimension(R.dimen.dp77)));
    }

    @Override
    protected void onLazyLoad() {
    }

    @Override
    protected void initListener() {
    }
}
