Search in sources :

Example 1 with R.id.recyclerView

use of com.scwang.refreshlayout.R.id.recyclerView in project SmartRefreshLayout by scwang90.

the class BottomSheetExampleFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(root, savedInstanceState);
    final Toolbar toolbar = (Toolbar) root.findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
    refreshLayout.setRefreshHeader(new ClassicsHeader(getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind).setPrimaryColorId(R.color.colorPrimary).setAccentColorId(android.R.color.white));
    refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

        @Override
        public void onLoadMore(@NonNull final RefreshLayout refreshLayout) {
            refreshLayout.getLayout().postDelayed(new Runnable() {

                @Override
                public void run() {
                    mAdapter.loadMore(initData());
                    refreshLayout.finishLoadMore();
                }
            }, 2000);
        }
    });
    RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recyclerView);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
    recyclerView.setAdapter(mAdapter = new BaseRecyclerAdapter<Void>(initData(), simple_list_item_2) {

        @Override
        protected void onBindViewHolder(SmartViewHolder holder, Void model, int position) {
            holder.text(android.R.id.text1, getString(R.string.item_example_number_title, position));
            holder.text(android.R.id.text2, getString(R.string.item_example_number_abstract, position));
            holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
        }
    });
    ((ViewGroup) refreshLayout.getLayout().getParent()).removeView(refreshLayout.getLayout());
    BottomSheetDialog dialog = new BottomSheetDialog(getContext());
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            getActivity().finish();
        }
    });
    dialog.setContentView(refreshLayout.getLayout());
    dialog.show();
}
Also used : OnLoadMoreListener(com.scwang.smartrefresh.layout.listener.OnLoadMoreListener) SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) DialogInterface(android.content.DialogInterface) ClassicsHeader(com.scwang.smartrefresh.layout.header.ClassicsHeader) ViewGroup(android.view.ViewGroup) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) R.id.recyclerView(com.scwang.refreshlayout.R.id.recyclerView) BaseRecyclerAdapter(com.scwang.refreshlayout.adapter.BaseRecyclerAdapter) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) BottomSheetDialog(android.support.design.widget.BottomSheetDialog) SmartRefreshLayout(com.scwang.smartrefresh.layout.SmartRefreshLayout) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

DialogInterface (android.content.DialogInterface)1 BottomSheetDialog (android.support.design.widget.BottomSheetDialog)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 R.id.recyclerView (com.scwang.refreshlayout.R.id.recyclerView)1 BaseRecyclerAdapter (com.scwang.refreshlayout.adapter.BaseRecyclerAdapter)1 SmartViewHolder (com.scwang.refreshlayout.adapter.SmartViewHolder)1 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)1 RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)1 ClassicsHeader (com.scwang.smartrefresh.layout.header.ClassicsHeader)1 OnLoadMoreListener (com.scwang.smartrefresh.layout.listener.OnLoadMoreListener)1