Search in sources :

Example 1 with ForumsAdapter

use of me.yluo.ruisiapp.adapter.ForumsAdapter in project Ruisi by freedom10086.

the class FrageForums method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    userImg = mRootView.findViewById(R.id.img);
    formsList = mRootView.findViewById(R.id.recycler_view);
    formsList.setClipToPadding(false);
    formsList.setPadding(0, 0, 0, (int) getResources().getDimension(R.dimen.bottombarHeight));
    mRootView.findViewById(R.id.search).setOnClickListener(this);
    adapter = new ForumsAdapter(getActivity());
    int spanCount = Math.max(4, DimenUtils.px2dip(getResources(), Resources.getSystem().getDisplayMetrics().widthPixels) / 75);
    GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), spanCount);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            int type = adapter.getItemViewType(position);
            if (type == ForumsAdapter.TYPE_HEADER || type == ForumsAdapter.TYPE_WATER) {
                return spanCount;
            } else {
                // 4 / 1 = 4 列
                return 1;
            }
        }
    });
    userImg.setOnClickListener(this);
    formsList.setLayoutManager(layoutManager);
    formsList.setAdapter(adapter);
    return mRootView;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ForumsAdapter(me.yluo.ruisiapp.adapter.ForumsAdapter) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)1 ForumsAdapter (me.yluo.ruisiapp.adapter.ForumsAdapter)1