public class Fragment_One extends Fragment {
private RecyclerView recycle_view;
private Presenter presenter;
private XBannerBean xBannerBean;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.item_layout_one, container, false);
recycle_view = view.findViewById(R.id.recycle_view);
LinearLayoutManager linearLayoutManager =new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false);
recycle_view.setLayoutManager(linearLayoutManager);
presenter = new Presenter(this);
presenter.getPre();
presenter.getXBannerPre();
return view;
}
public void getShow(final String data) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
xBannerBean = gson.fromJson(data, XBannerBean.class);
}
});
}
public void getViewShow(final String data) {
getActivity().runOnUiThread(new Runnable() {
private MyAdapter myAdapter;
@Override
public void run() {
Gson gson =new Gson();
ShowBean showBean = gson.fromJson(data, ShowBean.class);
ShowBean.ResultEntity list = showBean.getResult();
myAdapter = new MyAdapter(getActivity(),list,xBannerBean);
recycle_view.setAdapter(myAdapter);
}
});
}