Search in sources :

Example 6 with ClassicsHeader

use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.

the class EmptyLayoutExampleFragmentInner 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();
        }
    });
    mRefreshLayout = (RefreshLayout) root.findViewById(refreshLayout);
    mRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()).setSpinnerStyle(SpinnerStyle.FixedBehind).setPrimaryColorId(R.color.colorPrimary).setAccentColorId(android.R.color.white));
    mRefreshLayout.setOnRefreshListener(this);
    mRecyclerView = (RecyclerView) root.findViewById(recyclerView);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
    mEmptyLayout = root.findViewById(R.id.empty);
    ImageView image = (ImageView) root.findViewById(R.id.empty_image);
    image.setImageResource(R.drawable.ic_empty);
    TextView empty = (TextView) root.findViewById(R.id.empty_text);
    empty.setText("暂无数据下拉刷新");
    /*主动演示刷新*/
    if (mIsNeedDemo) {
        mRefreshLayout.getLayout().postDelayed(new Runnable() {

            @Override
            public void run() {
                if (mIsNeedDemo) {
                    mRefreshLayout.autoRefresh();
                }
            }
        }, 3000);
        mRefreshLayout.setOnMultiPurposeListener(new SimpleMultiPurposeListener() {

            @Override
            public void onStateChanged(@NonNull RefreshLayout refreshLayout, @NonNull RefreshState oldState, @NonNull RefreshState newState) {
                mIsNeedDemo = false;
            }
        });
    }
}
Also used : SimpleMultiPurposeListener(com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener) ClassicsHeader(com.scwang.smartrefresh.layout.header.ClassicsHeader) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) R.id.recyclerView(com.scwang.refreshlayout.R.id.recyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) RefreshState(com.scwang.smartrefresh.layout.constant.RefreshState) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Toolbar(android.support.v7.widget.Toolbar)

Example 7 with ClassicsHeader

use of com.scwang.smartrefresh.layout.header.ClassicsHeader in project SmartRefreshLayout by scwang90.

the class ViewPagerExampleFragment 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();
        }
    });
    mRefreshLayout = (RefreshLayout) root.findViewById(refreshLayout);
    mRefreshLayout.setOnRefreshLoadMoreListener(this);
    mRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()));
    mRefreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));
    mViewPager = (ViewPager) root.findViewById(R.id.viewPager);
    mTabLayout = (TabLayout) root.findViewById(R.id.tableLayout);
    mViewPager.setAdapter(mAdapter = new SmartPagerAdapter(Item.values()));
    mTabLayout.setupWithViewPager(mViewPager, true);
}
Also used : ClassicsHeader(com.scwang.smartrefresh.layout.header.ClassicsHeader) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ClassicsFooter(com.scwang.smartrefresh.layout.footer.ClassicsFooter) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ClassicsHeader (com.scwang.smartrefresh.layout.header.ClassicsHeader)7 RecyclerView (android.support.v7.widget.RecyclerView)6 View (android.view.View)6 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)5 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 Toolbar (android.support.v7.widget.Toolbar)5 AdapterView (android.widget.AdapterView)5 R.id.recyclerView (com.scwang.refreshlayout.R.id.recyclerView)5 RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)5 ViewGroup (android.view.ViewGroup)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 SmartViewHolder (com.scwang.refreshlayout.adapter.SmartViewHolder)2 SmartRefreshLayout (com.scwang.smartrefresh.layout.SmartRefreshLayout)2 RefreshHeader (com.scwang.smartrefresh.layout.api.RefreshHeader)2 RefreshState (com.scwang.smartrefresh.layout.constant.RefreshState)2 ClassicsFooter (com.scwang.smartrefresh.layout.footer.ClassicsFooter)2 SimpleMultiPurposeListener (com.scwang.smartrefresh.layout.listener.SimpleMultiPurposeListener)2 Context (android.content.Context)1