use of me.yluo.ruisiapp.adapter.HistoryAdapter in project Ruisi by freedom10086.
the class FrageHistory method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
initToolbar(true, "浏览历史");
addToolbarMenu(R.drawable.ic_delete_24dp).setOnClickListener(view -> {
Dialog alertDialog = new AlertDialog.Builder(getActivity()).setTitle("清空历史记录").setMessage("你确定要清空浏览历史吗??").setPositiveButton("是的(=・ω・=)", (dialogInterface, i) -> {
MyDB db = new MyDB(getActivity());
db.clearHistory();
datas.clear();
adapter.notifyDataSetChanged();
Toast.makeText(getActivity(), "浏览历史已清空~~", Toast.LENGTH_SHORT).show();
}).setNegativeButton("取消", null).setCancelable(true).create();
alertDialog.show();
});
RecyclerView recyclerView = mRootView.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
SwipeRefreshLayout refreshLayout = mRootView.findViewById(R.id.refresh_layout);
refreshLayout.setEnabled(false);
adapter = new HistoryAdapter(getActivity(), datas);
adapter.setPlaceHolderText("暂无浏览历史");
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.addItemDecoration(new MyListDivider(getActivity(), MyListDivider.VERTICAL));
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
refresh();
return mRootView;
}
Aggregations