use of com.wm.remusic.adapter.MainFragmentAdapter in project remusic by aa112901.
the class MainFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
// swipeRefresh.setColorSchemeResources(R.color.theme_color_PrimaryAccent);
swipeRefresh.setColorSchemeColors(ThemeUtils.getColorById(mContext, R.color.theme_color_primary));
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
reloadAdapter();
}
});
// 先给adapter设置空数据,异步加载好后更新数据,防止Recyclerview no attach
mAdapter = new MainFragmentAdapter(mContext);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
// 设置没有item动画
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
reloadAdapter();
mContext.getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
return view;
}
Aggregations