package com.example.six_week2.fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.six_week2.R;
import com.example.six_week2.adapter.MyAdapter;
import com.example.six_week2.adapter.MyLeftAdapter;
import com.example.six_week2.bean.JsonBean;
import com.example.six_week2.bean.LeftBean;
import com.example.six_week2.left.presenter.ShowPresenterleft;
import java.util.List;
public class OneFragment extends Fragment {
private View inflate;
private RecyclerView leftrecyclerView,rightrecyclerView;
LeftBean leftBean;
private ShowPresenterleft leftPre;
private MyLeftAdapter leftAabter;
private LinearLayoutManager linearLayoutManager;
private MyAdapter rightAdapter;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
inflate = inflater.inflate(R.layout.one_layout, container, false);
leftrecyclerView = inflate.findViewById(R.id.type_rvleft);
linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setOrientation(OrientationHelper.VERTICAL);
leftrecyclerView.setLayoutManager(linearLayoutManager);
rightrecyclerView = inflate.findViewById(R.id.type_rvright);
linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setOrientation(OrientationHelper.VERTICAL);
rightrecyclerView.setLayoutManager(linearLayoutManager);
leftPre = new ShowPresenterleft(this);
leftPre.GetDDataleft();
leftPre.GetRightata("1");
return inflate;
}
public void getleftViewDate(Object obj) {
LeftBean leftBean= (LeftBean) obj;
leftAabter = new MyLeftAdapter(getActivity(),leftBean);
leftAabter.setRecyclerItemClickListener(new MyLeftAdapter.OnRecyclerItemClickListener() {
@Override
public void onItemClick(int position, List<LeftBean.DataBean> dataBeanList) {
leftPre.GetRightata(dataBeanList.get(position).getCid());
rightAdapter.notifyDataSetChanged();
}
});
leftrecyclerView.setAdapter(leftAabter);
}
public void getRightViewDate(Object obj){
JsonBean jsonBean= (JsonBean) obj;
rightAdapter = new MyAdapter(getActivity(), jsonBean);
rightrecyclerView.setAdapter(rightAdapter);
}
}