Search in sources :

Example 26 with SmartViewHolder

use of com.scwang.refreshlayout.adapter.SmartViewHolder in project SmartRefreshLayout by scwang90.

the class NestedScrollExampleFragmentIntegral method onViewCreated.

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

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    Banner banner = (Banner) root.findViewById(R.id.banner);
    banner.setImageLoader(new BannerImageLoader());
    banner.setImages(Arrays.asList(image_weibo_home_2, gif_header_repast));
    banner.start();
    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<Item>(buildItems(), simple_list_item_2, NestedScrollExampleFragmentIntegral.this) {

        @Override
        protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
            holder.text(android.R.id.text1, model.name());
            holder.text(android.R.id.text2, model.name);
            holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
        }
    });
    RefreshLayout refreshLayout = (RefreshLayout) root.findViewById(R.id.refreshLayout);
    refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {

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

                @Override
                public void run() {
                    mAdapter.loadMore(buildItems());
                    refreshLayout.finishLoadMore();
                }
            }, 2000);
        }
    });
}
Also used : OnLoadMoreListener(com.scwang.smartrefresh.layout.listener.OnLoadMoreListener) SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) Banner(com.youth.banner.Banner) 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) BaseRecyclerAdapter(com.scwang.refreshlayout.adapter.BaseRecyclerAdapter) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Item(com.scwang.refreshlayout.fragment.example.NestedScrollExampleFragment.Item) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Example 27 with SmartViewHolder

use of com.scwang.refreshlayout.adapter.SmartViewHolder in project SmartRefreshLayout by scwang90.

the class PureScrollExampleFragment 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();
        }
    });
    View view = root.findViewById(R.id.recyclerView);
    if (view instanceof RecyclerView) {
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
        recyclerView.setAdapter(new BaseRecyclerAdapter<Item>(Arrays.asList(Item.values()), simple_list_item_2, this) {

            @Override
            protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
                holder.text(android.R.id.text1, model.name());
                holder.text(android.R.id.text2, model.name);
                holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
            }
        });
    }
}
Also used : SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Toolbar(android.support.v7.widget.Toolbar)

Example 28 with SmartViewHolder

use of com.scwang.refreshlayout.adapter.SmartViewHolder in project SmartRefreshLayout by scwang90.

the class SpecifyStyleExampleFragment 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();
        }
    });
    toolbar.setTitle("指定样式");
    View view = root.findViewById(R.id.recyclerView);
    if (view instanceof RecyclerView) {
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
        recyclerView.setAdapter(new BaseRecyclerAdapter<Item>(Arrays.asList(Item.values()), simple_list_item_2, this) {

            @Override
            protected void onBindViewHolder(SmartViewHolder holder, Item model, int position) {
                holder.text(android.R.id.text1, model.name());
                holder.text(android.R.id.text2, model.name);
                holder.textColorId(android.R.id.text2, R.color.colorTextAssistant);
            }
        });
    }
}
Also used : SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Toolbar(android.support.v7.widget.Toolbar)

Example 29 with SmartViewHolder

use of com.scwang.refreshlayout.adapter.SmartViewHolder in project SmartRefreshLayout by scwang90.

the class ThreeLevelExampleFragment method onViewCreated.

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

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    if (recyclerView != null) {
        recyclerView.setAdapter(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.text1, android.R.color.white);
                holder.textColorId(android.R.id.text2, android.R.color.white);
            }
        });
    }
    RefreshLayout refreshLayout1 = (RefreshLayout) view.findViewById(R.id.refreshLayout1);
    if (refreshLayout1 != null) {
        refreshLayout1.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                refreshLayout.finishRefresh(1000);
            }
        });
    }
    RefreshLayout refreshLayout2 = (RefreshLayout) view.findViewById(R.id.refreshLayout2);
    if (refreshLayout2 != null) {
        refreshLayout2.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                refreshLayout.finishRefresh(2000);
            }
        });
    }
}
Also used : SmartViewHolder(com.scwang.refreshlayout.adapter.SmartViewHolder) RefreshLayout(com.scwang.smartrefresh.layout.api.RefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) OnRefreshListener(com.scwang.smartrefresh.layout.listener.OnRefreshListener) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

View (android.view.View)29 SmartViewHolder (com.scwang.refreshlayout.adapter.SmartViewHolder)29 RecyclerView (android.support.v7.widget.RecyclerView)28 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)26 AdapterView (android.widget.AdapterView)25 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)23 Toolbar (android.support.v7.widget.Toolbar)13 RefreshLayout (com.scwang.smartrefresh.layout.api.RefreshLayout)11 BaseRecyclerAdapter (com.scwang.refreshlayout.adapter.BaseRecyclerAdapter)8 OnLoadMoreListener (com.scwang.smartrefresh.layout.listener.OnLoadMoreListener)4 OnRefreshListener (com.scwang.smartrefresh.layout.listener.OnRefreshListener)4 AppBarLayout (android.support.design.widget.AppBarLayout)3 ViewGroup (android.view.ViewGroup)3 ImageView (android.widget.ImageView)3 BottomSheetDialog (android.support.design.widget.BottomSheetDialog)2 AbsListView (android.widget.AbsListView)2 TextView (android.widget.TextView)2 R.id.recyclerView (com.scwang.refreshlayout.R.id.recyclerView)2 Item (com.scwang.refreshlayout.fragment.example.PureScrollExampleFragment.Item)2