package com.example.cloudmusic.textNewUI;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.example.cloudmusic.R;

import java.util.ArrayList;
import java.util.List;

public class Text10087 extends Fragment {


    private RecyclerView recyclerView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_text10087, container, false);
        recyclerView = root.findViewById(R.id.text_rcv);
        Text10088 adapter = new Text10088(initData(), root.getContext());
        recyclerView.setAdapter(adapter);
        LinearLayoutManager manager = new LinearLayoutManager(root.getContext());
        recyclerView.setLayoutManager(manager);

        return root;
    }
//    public void resetHeight(RecyclerView listview) {
//        RecyclerView.Adapter listAdapter = listview.getAdapter();
//        if (listAdapter == null) {
//            return;
//        }
//
//        int totalHeight = 0;


//        ViewGroup.LayoutParams params = listview.getLayoutParams();
//        for (int i = 0; i < listAdapter.getItemCount(); i++) {
//            View listItem = listAdapter.onCreateViewHolder(n,i);
//            listItem.measure(0, 0);
//            totalHeight += listItem.getMeasuredHeight();
//        }
//        params.height = totalHeight + (listview.getDividerHeight() * (listAdapter.getCount() - 1));
//        listview.setLayoutParams(params);
//        ((Text10086) getActivity()).setVpLp(params.height);
//    }

    private List<String> initData() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add("我的天哪");
        }
        System.out.println(list.size());
        return list;
    }
}