RecyclerView Encapsulation Library and Comprehensive Case [Including 25 Blogs]

Keywords: Java github Android network Database

Directory Introduction

  • 1. Introduction to Complex Page Library
  • 2. Advantage highlights of this library

    • 2.1 supports multiple state transition management
    • 2.2 Support for adding multiple header s and footer s
    • 2.3 Support for side sliding and dragging
    • 2.4 Introduction to Other Highlights
  • 3. How to use the introduction

    • 3.1 Basic Use
    • 3.2 Add drop-down refresh and load more monitoring
    • 3.3 Add header and footer operations
    • 3.4 Set up data and refresh
    • 3.5 Set adapter
    • 3.6 Set entry click events
    • 3.7 Set Side Slide Delete Function [QQ Side Slide Delete]
    • 3.8 Lightweight Drag Sort and Slide Delete
  • 4. About state switching

    • 4.1 About Layout Content
    • 4.2 Ideas for implementation
    • 4.3 About state switch api calls
    • 4.4 About customizing the status layout
    • 4.5 About custom layout interaction event handling
  • 5. Introduction to common api

    • 5.1 State Switching Method Description
    • 5.2 viewHolder method description
    • 5.3 Adaptpter method description
    • 5.4 Explanation of Split Line Method
    • Explanation of 5.5 swipe sideslip method
    • 5.6 Additional api instructions
  • 6. wiki documentation for recyclerView [in update]

    • Introduction of 6.1 Packaging Library
    • 6.2 Introduction to Optimized Processing Logic
    • 6.3 recyclerView related classes
    • 6.4 recyclerView Slide Conflict
    • 6.5 recyclerView Cache Mechanism
    • 6.5 recyclerView related blogs (25 articles)
  • 7. Realize the effect display

    • 7.1 Drop-down Refresh, Drop-up Load
    • 7.2 Add multiple headerView s and FooterView s
    • 7.3 Horizontal Slide
    • 7.4 Paste Head
    • 7.5 Combined with coordinatorLayout
    • 7.6 Waterfall Flow Effect
  • 8. Version update instructions
  • 9. Reference Explanation
  • 10. Additional information

0.recyclerView related blogs

RecyclerView can be used in a wide range of applications. Here's my blog that I've sorted out step by step. With blogs, you can also encapsulate your recyclerView library step by step.Although there are many recyclerViews on the web, it is also a good practice to summarize records while applying them once if you want to master them.

Open source library address [most recyclerView use cases can be downloaded directly demo]: https://github.com/yangchong2...

  • 00.RecyclerView Complex Encapsulation Library

    • Almost all of the knowledge points in this series of blogs are merged. Welcome to see the blog once and practice, step by step from simple to powerful library
  • 01.RecyclerView

    • Structure of RecycleView, Introduction to RecyclerView's Simple Usage
  • 02.Adapter

    • RecyclerView.Adapter's role, description of commonly used rewriting methods, observer mode for data change notifications, view.notifyChanged(); source code
  • 03.ViewHolder

    • The role of ViewHolder, how to understand that the onCreateViewHolder method is stopped after the number of ViewHolder objects is "enough", ViewHolder is simply encapsulated
  • 04.LayoutManager

    • What does LayoutManager do?setLayoutManager Source Code Analysis
  • 05.SnapHelper

    • SnapHelper role, what is Fling operation, SnapHelper class important methods,
  • 06.ItemTouchHelper
  • 07.SpanSizeLookup

    • How does SpanSizeLookup work with lists, grids with two columns, and grids with three columns?
  • 08.ItemDecoration

    • Uses of ItemDecoration, addItemDecoration() Source Analysis
  • 09.RecycledViewPool

    • RecyclerViewPool is used to share views among multiple RecyclerViews.
  • 11.RecyclerView pull-up loading

    • Add sliding events for recyclerView, pull-up loading paging data, set bottom footer layout for pull-up loading, show and hide footer layout
  • 12.RecyclerView Caching Principles

    • RecyclerView is complex and complex for performance optimization, such as layout optimization, caching, preloading, reusing pools, refreshing data, etc.
  • 13.SnapHelper Source Analysis

    • SnapHelper is designed to support RecyclerView alignment by calculating the alignment of a specific point of the TargetView in RecyclerView or any pixel point in a container.
  • 16. Customize SnapHelper

    • Customize SnapHelper
  • 19. Custom ItemDecoration Split Line

    • You need a custom class to implement the RecyclerView.ItemDecoration class and choose the appropriate method to override it
  • 22.RecyclerView problem summary

    • Differences between getLayoutPosition() and getAdapterPosition()
  • 23.RecyclerView Slide Conflict

    • 01. How to determine if the RecyclerView control slides to the top and bottom
    • 02.RecyclerView Nested RecyclerView Entry Auto-Roll-Up Bug
    • 03.ScrollView Nested RecyclerView Slide Conflict
    • 04.ViewPager nested horizontal RecyclerView slides horizontally to the bottom without sliding ViewPager
    • 05.RecyclerView Nested RecyclerView Slide Conflict Problem
    • 06.RecyclerView uses Glide to load pictures causing the picture to be confused problem solving
  • 24.ScrollView Nested RecyclerView Problem

    • To embed one or more RecyclerView s in the NestedScrollView, a sliding conflict, preemptive focus, and incomplete display occur.What to do?

1. Introduction to Complex Page Library

  • Custom support for pull-up loading more controls [Loading, Loading Failures [such as no more data], Loading Exceptions [no network], Loading Success and other states], Drop-down refresh to implement complex status pages, to support free-switching states (Loading, Loading Success, Loading Failure, No network, etc.), to expand functionality [Support drag-and-drop, Side-slide deletion]It can be added optionally.Specific use methods can be directly referred to demo cases.
  • Support complex type pages, such as adding custom HeaderView and bottom layout FooterView, supporting horizontal sliding list, pasting header list [like WeChat Friend Grouping], supporting irregular waterfall streaming effect, and supporting side sliding deletion function.

2. Advantage highlights of this library

2.1 supports multiple state transition management

  • Supports customizing view s in layouts or code settings for different states. One line of code can switch between different states, which is very convenient.
  • For a custom status view or layout, interactive functions can be implemented, such as when switching to a page with network anomalies, clicking on the page control to refresh the data or jumping to set the network page

2.2 Support for adding multiple header s and footer s

  • Support for adding multiple custom header header layout, you can customize footer bottom layout.It is very convenient to implement the layout page of complex type s, with clear hierarchy and easy maintenance.
  • Supports complex interface use, such as pages with a rotation map, button combinations, horizontal sliding lists, and complex lists, which can be accomplished with this control.

2.3 Support for side sliding and dragging

  • Lightweight Side Slide Delete menu, directly nested item layout, easy to use
  • Item drag sorting of RecyclerView entries is achieved by customizing ItemTouchHelper, only setting whether or not to drag, setting the background color of the dragged item, optimizing the drag effect, such as setting the zoom and gradient effect of the item during the drag process

2.4 Introduction to Other Highlights

  • Supports pull-up loading and drop-down refreshing.When pull-up loads have more failures or exceptions, you can set a custom load with more failures or exception layouts (such as scenarios when there is no network), and click on the exception or failure layout to resume loading more data; when pull-up loads more data without more data, you can set a custom load with more data layouts.
  • You can set a pull-up load to automatically load the next page of data after more loads, or you can pull-up load to manually trigger the load of the next page of data after more loads.When loading more on a pull-up, you can set up to load more layouts to support load monitoring.
  • Supports the desired effect of pasting the head, which is similar to the functional interface of WeChat Friends Grouping.
  • Supports insertion, updating a specified index or data data, or deleting a single data, and deleting all data.At the same time, under multithreaded conditions, a lock mechanism is added to avoid data confusion!
  • Supports horizontal sliding list effects, waterfall flow effects, and cool effects combined with CoordinatorLayout.This works especially well...
  • Has been used in the real development project investment community, budding, Dune University...And after nearly three years of iteration and maintenance, continuous updating and maintenance!

3. How to use the introduction

3.1 Basic Use

  • First in Integration:

    • implementation 'org.yczbj:YCRefreshViewLib:2.5.8'
  • In Layout

    <org.yczbj.ycrefreshviewlib.YCRefreshView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_progress="@layout/view_custom_loading_data"
        app:layout_empty="@layout/view_custom_empty_data"
        app:layout_error="@layout/view_custom_data_error"/>
  • In the code, initialize recyclerView

    adapter = new PersonAdapter(this);
    recyclerView.setAdapter(adapter);
    final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    adapter.addAll(data);
  • In the code, create an adapter to implement RecyclerArrayAdapter <T>

    public class PersonAdapter extends RecyclerArrayAdapter<PersonData> {
    
        public PersonAdapter(Context context) {
            super(context);
        }
    
        @Override
        public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
            return new PersonViewHolder(parent);
        }
    
        public class PersonViewHolder extends BaseViewHolder<PersonData> {
    
            private ImageView iv_news_image;
    
            PersonViewHolder(ViewGroup parent) {
                super(parent, R.layout.item_news);
                iv_news_image = getView(R.id.iv_news_image);
            }
    
            @Override
            public void setData(final PersonData person){
    
            }
        }
    }

3.2 Add drop-down refresh and load more monitoring

  • Drop-down refresh listening operation

    //Set refresh listener
    recyclerView.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            //Refresh operation
        }
    });
    //Set whether to refresh
    recyclerView.setRefreshing(false);
    //Set refresh color
    recyclerView.setRefreshingColorResources(R.color.colorAccent);
  • Drop-Up Load More Listening Operations

    • In the first case, pull-up loads more data and automatically loads the next page
    //Set the layout when pull-up loads more, and listen for events
    adapter.setMore(R.layout.view_more, new OnLoadMoreListener() {
        @Override
        public void onLoadMore() {
            //You can request the next page
        }
    });
    • In the second case, the pull-up loading of more data triggers the loading of the next page manually
    adapter.setMore(R.layout.view_more2, new OnMoreListener() {
        @Override
        public void onMoreShow() {
            //Do not process
        }
    
        @Override
        public void onMoreClick() {
            //Click Trigger to Load Next Page Data
        }
    });
  • When more data is loaded in the pull-up, there may be no more data, or the pull-up loading fails. What should I do?

    //No more data listening for Settings pull-up loading
    adapter.setNoMore(R.layout.view_no_more, new OnNoMoreListener() {
        @Override
        public void onNoMoreShow() {
            //Pull-up loading, no more data to show, this method can pause or stop loading data
            adapter.pauseMore();
        }
    
        @Override
        public void onNoMoreClick() {
            //This method is to click on an operation that shows the layout without more data, such as making toast, etc.
            Log.e("Comma ratio","No more data");
        }
    });
    //Set Up to Load More Exception Listening Data Listening
    adapter.setError(R.layout.view_error, new OnErrorListener() {
        @Override
        public void onErrorShow() {
            //Pull-up loading to load more data exceptions, which can pause or stop loading data
            adapter.pauseMore();
        }
    
        @Override
        public void onErrorClick() {
            //This method is to click Load More Data to show the layout, such as restore Load More, etc.
            adapter.resumeMore();
        }
    });

3.3 Add header and footer operations

  • Add headerView action.As for adding a footerView, it is almost the same as adding a header step.

    • Add a plain layout [not a listView or RecyclerView layout]
    adapter.addHeader(new InterItemView() {
        @Override
        public View onCreateView(ViewGroup parent) {
            View inflate = LayoutInflater.from(context).inflate(R.layout.header_view, null);
            return inflate;
        }
    
        @Override
        public void onBindView(View headerView) {
            TextView tvTitle = headerView.findViewById(R.id.tvTitle);
        }
    });
    • Add a list layout [with horizontal recyclerView as an example]
    adapter.addHeader(new InterItemView() {
        @Override
        public View onCreateView(ViewGroup parent) {
            RecyclerView recyclerView = new RecyclerView(parent.getContext()){
                //To not disturb the sliding operation of the horizontal RecyclerView, this can be done
                @SuppressLint("ClickableViewAccessibility")
                @Override
                public boolean onTouchEvent(MotionEvent event) {
                    super.onTouchEvent(event);
                    return true;
                }
            };
            return recyclerView;
        }
    
        @Override
        public void onBindView(View headerView) {
            //Don't forget to handle it here
            ((ViewGroup)headerView).requestDisallowInterceptTouchEvent(true);
        }
    });
  • Points to Note

    • If you add a HeaderView, any positions you get through the ViewHolder will need to reduce the number of HeaderViews to get the correct position.

3.4 Set up data and refresh

  • Add all data, either a collection or an array

    //Add All Data
    adapter.addAll(data);
    //Add single-handed data
    adapter.add(data);
  • Insert, refresh, and delete data

    //Insert specified index data, single data
    adapter.insert(data, pos);
    //Insert specified index data, multiple data
    adapter.insertAll(data, pos);
    //Refresh specified index data
    adapter.update(data, pos);
    //Delete data, specify data
    adapter.remove(data);
    //Delete data, specify index
    adapter.remove(pos);
    //Empty all data

3.5 Set adapter

  • Note that custom adapter s need to implement RecyclerArrayAdapter <T>, where T is generic and is the type of bean data you want to use

    public class PersonAdapter extends RecyclerArrayAdapter<PersonData> {
    
        public PersonAdapter(Context context) {
            super(context);
        }
    
        @Override
        public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
            return new PersonViewHolder(parent);
        }
    
        public class PersonViewHolder extends BaseViewHolder<PersonData> {
    
            private TextView tv_title;
            private ImageView iv_news_image;
    
            PersonViewHolder(ViewGroup parent) {
                super(parent, R.layout.item_news);
                iv_news_image = getView(R.id.iv_news_image);
                tv_title = getView(R.id.tv_title);
    
                //Add a child's click event
                addOnClickListener(R.id.iv_news_image);
                addOnClickListener(R.id.tv_title);
            }
    
            @Override
            public void setData(final PersonData person){
                Log.i("ViewHolder","position"+getDataPosition());
                tv_title.setText(person.getName());
            }
        }
    }

3.6 Set item Click Event [item Click Event, item Child view Click Event]

  • Entry Click Event, Long Press Event [Omit, you can see the code yourself]

    adapter.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(int position) {
            if (adapter.getAllData().size()>position && position>=0){
                //Handle Click Event Logic
            }
        }
    });
  • Click events for children in entries

    //Add a child's click event to see 3.5 settings for adapter
    addOnClickListener(R.id.iv_news_image);
    addOnClickListener(R.id.tv_title);
    
    //Set children's click events
    adapter.setOnItemChildClickListener(new OnItemChildClickListener() {
        @Override
        public void onItemChildClick(View view, int position) {
            switch (view.getId()){
                case R.id.iv_news_image:
                    Toast.makeText(HeaderFooterActivity.this,
                            "Click on the picture",Toast.LENGTH_SHORT).show();
                    break;
                case R.id.tv_title:
                    Toast.makeText(HeaderFooterActivity.this,
                            "Click on the title",Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;
            }
        }
    });

3.7 Set Side Slide Delete Function [QQ Side Slide Delete]

  • In the layout file, omit some code here

    <org.yczbj.ycrefreshviewlib.swipeMenu.YCSwipeMenu
        android:orientation="horizontal">
        <!--item content-->
        <RelativeLayout
        </RelativeLayout>
    
        <!-- Side Slide Menu -->
        <Button
            android:id="@+id/btn_del"/>
        <Button
            android:id="@+id/btn_top"/>
    </org.yczbj.ycrefreshviewlib.swipeMenu.YCSwipeMenu>
  • Set in Code

    • Define interfaces in adapter
    private OnSwipeMenuListener listener;
    public void setOnSwipeMenuListener(OnSwipeMenuListener listener) {
        this.listener = listener;
    }
    • Set Click Event on adapter
    View.OnClickListener clickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.btn_del:
                    if (null != listener) {
                        listener.toDelete(getAdapterPosition());
                    }
                    break;
                case R.id.btn_top:
                    if (null != listener) {
                        listener.toTop(getAdapterPosition());
                    }
                    break;
            }
        }
    };
    btn_del.setOnClickListener(clickListener);
    btn_top.setOnClickListener(clickListener);
  • Handling top-set or deleted functions

    adapter.setOnSwipeMenuListener(new OnSwipeMenuListener() {
        //Delete function
        @Override
        public void toDelete(int position) {
    
        }
    
        //Top setting function
        @Override
        public void toTop(int position) {
    
        }
    });

3.8 Lightweight Drag Sort and Slide Delete

  • Handles long press and drag, sliding delete function.Lightweight, free to choose whether or not to achieve.

    mCallback = new DefaultItemTouchHelpCallback(new DefaultItemTouchHelpCallback
                            .OnItemTouchCallbackListener() {
        @Override
        public void onSwiped(int adapterPosition) {
            // Remove from database, data source, and refresh UI when sliding delete
        }
    
        @Override
        public boolean onMove(int srcPosition, int targetPosition) {
            return false;
        }
    });
    mCallback.setDragEnable(true);
    mCallback.setSwipeEnable(true);
    mCallback.setColor(this.getResources().getColor(R.color.colorAccent));
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);

4. About state switching

4.1 About Layout Content

  • YCRecyclerView is a composite custom control with the following layout

     <!--Refresh Control Omit Part Code-->
    <android.support.v4.widget.SwipeRefreshLayout>
        <FrameLayout>
            <!--RecyclerView control-->
            <android.support.v7.widget.RecyclerView/>
            <!--Layout when loading data is empty-->
            <FrameLayout/>
            <!--Loading Layout in Data-->
            <FrameLayout/>
            <!--Layout when loading errors: network error or request data error-->
            <FrameLayout/>
        </FrameLayout>
    </android.support.v4.widget.SwipeRefreshLayout>

4.2 Ideas for implementation

  • Ideas on page state switching

    • The first way: include these interfaces directly into the main interface, then switch the interfaces dynamically. Later, it was found that this process is not easy to reuse into other projects, and the display and hiding of these states in the activity is confusing.
    • Second, use subclasses to inherit parent attributes, write toggle states in the parent, but some interfaces do not inherit the parent, what to do
  • The way of thinking of this library

    • Four different types of layouts are written in a frame layout FrameLayout: normal layout, empty layout, loading loading layout, incorrect layout [network exception, loading data exception]
    • Of course, you can also customize the layout of these states by adding different state layouts to the corresponding FrameLayout in the form of addView.To switch status, you just need to set the layout display or hide it.

4.3 About state switch api calls

  • As shown below

    //Set load data completion status
    recyclerView.showRecycler();
    //Set load data to empty state
    recyclerView.showEmpty();
    //Set Load Error Status
    recyclerView.showError();
    //Set loading data state
    recyclerView.showProgress();

4.4 About customizing the status layout

  • As shown below

    //Set Empty State Page Custom Layout
    recyclerView.setEmptyView(R.layout.view_custom_empty_data);
    recyclerView.setEmptyView(view);
    //Get Empty Page Custom Layout
    View emptyView = recyclerView.getEmptyView();
    
    //Set Exception Status Page Custom Layout
    recyclerView.setErrorView(R.layout.view_custom_data_error);
    recyclerView.setErrorView(view);
    
    //Set Load loading Status Page Custom Layout
    recyclerView.setProgressView(R.layout.view_progress_loading);
    recyclerView.setProgressView(view);

4.5 About custom layout interaction event handling

  • Sometimes, an exception occurs on the load page, such as when no network displays a custom network exception page.Now you need to click on the Exception Page button and so on, so what can you do?

    //Attention needs
    LinearLayout ll_error_view = (LinearLayout) recyclerView.findViewById(R.id.ll_error_view);
    ll_error_view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //For example, jump to the network settings page, refresh the data again, or other operations, and so on
        }
    });

5. Introduction to common api

  • State Switching Method Description

    //Set load data completion status
    recyclerView.showRecycler();
    //Set load data to empty state
    recyclerView.showEmpty();
    //Set Load Error Status
    recyclerView.showError();
    //Set loading data state
    recyclerView.showProgress();
    //Setting up a custom layout is the same for several other methods
    recyclerView.setEmptyView(R.layout.view_custom_empty_data);
  • viewHolder method description

    //Subclass Setting Data Method
    setData Method
    //findViewById method
    iv_news_image = getView(R.id.iv_news_image);
    //Get Context
    Context context = getContext();
    //Get the location of the data index
    int dataPosition = getDataPosition();
    //Click event to add item subcontrol
    addOnClickListener(R.id.tv_title);
  • adapter method description

    //Delete data at index
    adapter.remove(0);
    //Trigger Cleanup of All Data
    adapter.removeAll();
    //Add data, note that this is added at the last index
    adapter.add(new PersonData());
    //Add All Data
    adapter.addAll(DataProvider.getPersonList(0));
    //insert data
    adapter.insert(data,3);
    //Insert Collection Data at an Index
    adapter.insertAll(data,3);
    //Get item index location
    adapter.getPosition(data);
    //Trigger emptying all data
    adapter.clear();
    //Get all the data
    adapter.getAllData();
    
    //Clear all footer s
    adapter.removeAllFooter();
    //Clear all header s
    adapter.removeAllHeader();
    //Add footerView
    adapter.addFooter(view);
    //Add headerView
    adapter.addHeader(view);
    //Remove a headerView
    adapter.removeHeader(view);
    //Remove a footerView
    adapter.removeFooter(view);
    //Get the headerView at an index
    adapter.getHeader(0);
    //Get the footerView at an index
    adapter.getFooter(0);
    //Get the number of footer s
    adapter.getFooterCount();
    //Get the number of header s
    adapter.getHeaderCount();
    
    //Settings pull-up to load more custom layouts and listeners
    adapter.setMore(R.layout.view_more,listener);
    //Settings pull-up to load more custom layouts and listeners
    adapter.setMore(view,listener);
    //No more data layouts for Settings pull-up loading
    adapter.setNoMore(R.layout.view_nomore);
    //No more data layouts for Settings pull-up loading
    adapter.setNoMore(view);
    //No more data listening for Settings pull-up loading
    adapter.setNoMore(R.layout.view_nomore,listener);
    //Set layout for pull-up load exceptions
    adapter.setError(R.layout.view_error);
    //Set layout for pull-up load exceptions
    adapter.setError(view);
    //Set up layout and exception monitoring for pull-up load exceptions
    adapter.setError(R.layout.view_error,listener);
    //Pause pull-up to load more
    adapter.pauseMore();
    //Stop pull-up loading more
    adapter.stopMore();
    //Restore pull-up to load more
    adapter.resumeMore();
    
    //Get Context
    adapter.getContext();
    //This should be used to get the number of item s
    adapter.getCount();
    //Refresh adapter after setting operation data [add delete check]
    adapter.setNotifyOnChange(true);
    
    //Set Child Click Events
    adapter.setOnItemChildClickListener(listener);
    //Set Entry Click Event
    adapter.setOnItemClickListener(listener);
    //Set entry length by event
    adapter.setOnItemLongClickListener(listener);
  • Explanation of Split Line Method

    //Split lines that can set line color and width
    //Four parameters, context, direction, line width, color
    final RecycleViewItemLine line = new RecycleViewItemLine(this, LinearLayout.HORIZONTAL,
            (int)AppUtils.convertDpToPixel(1,this),
            this.getResources().getColor(R.color.color_f9f9f9));
    recyclerView.addItemDecoration(line);
    
    //Spacing settings for waterfall streams
    SpaceViewItemLine itemDecoration = new SpaceViewItemLine(
            (int) AppUtils.convertDpToPixel(8,this));
    itemDecoration.setPaddingEdgeSide(true);
    itemDecoration.setPaddingStart(true);
    itemDecoration.setPaddingHeaderFooter(true);
    recyclerView.addItemDecoration(itemDecoration);
    
    //Line color and width can be set, and spacing can be set about a distance
    DividerViewItemLine itemDecoration = new
            DividerViewItemLine( this.getResources().getColor(R.color.color_f9f9f9)
            , LibUtils.dip2px(this, 1f),
            LibUtils.dip2px(this, 72), 0);
    itemDecoration.setDrawLastItem(false);
    recyclerView.addItemDecoration(itemDecoration);
  • Other api instructions

6. wiki documentation for recyclerView [in update]

Introduction of 6.1 Packaging Library

  • 01. Overall packaging ideas
  • 02. Add a drop-down refresh
  • 03. Add header and footer
  • 04. Add a pull-up load
  • 05. Interface Separation Rule
  • 06. Application of Generics in Framework
  • 07. Encapsulate adapter
  • 08. Encapsulate ViewHolder
  • 09. State management switching
  • 10.View Event Distribution Utilization
  • 11. Side Slide Delete Function
  • 12.Item Drag Sort and Slide Delete
  • 13. Customize ItemDecoration

6.2 Introduction to Optimized Processing Logic

  • 01. Interface Separation Optimization
  • 02. Remove pale yellow warning
  • 03.SparseArray replaces HashMap
  • 04. Waterfall flow picture confusion problem solving
  • 05. Optimize where click events are placed
  • 06.ViewHolder optimization
  • 07. Continuous pull-up loading for more optimizations
  • 08. Drag Sort and Slide Delete Optimization
  • 09. Pause or stop loading data optimization
  • 10. Interactive optimization of state switching
  • 11. Save state under abnormal circumstances
  • 12. Optimize inserting data under multiple threads
  • 13.recyclerView Slide Carton Optimization

6.3 recyclerView related classes

  • 01.recyclerView
  • 02.layoutManager
  • 03.adapter
  • 04.viewHolder
  • 05.SnapHelper
  • 06.ItemTouchHelper
  • 07.SpanSizeLookup
  • 08.ItemDecoration

6.4 recyclerView Slide Conflict

  • 01. How to determine if the RecyclerView control slides to the top and bottom
  • 02.RecyclerView Nested RecyclerView Entry Auto-Roll-Up Bug
  • 03.ScrollView Nested RecyclerView Slide Conflict
  • 04.ViewPager nested horizontal RecyclerView slides horizontally to the bottom without sliding ViewPager
  • 05.RecyclerView Nested RecyclerView Slide Conflict Problem
  • 06.RecyclerView uses Glide to load pictures causing the picture to be confused problem solving

6.5 recyclerView Cache Mechanism

  • 01. How to optimize performance
  • 02.RecyclerView drawing schematic
  • 03. Drawing principle analysis process
  • 04. Caching mechanism
  • 05. Screen sliding analysis

7. Realize the effect display

7.1 Case code that used the YCRefreshView Library

7.2 Picture Display Effect












7.3 Partial Case Diagram Display [Some cases can refer to 7.1]


8. Version update instructions

  • v1.0 updated November 2, 2016
  • v1.1 Updated March 13, 2017
  • v1.3 Updated August 9, 2017
  • v1....Updated January 5, 2008
  • v2.2 Updated January 17, 2008
  • v2.3 Updated February 9, 2008
  • v2.4 Updated March 19, 2008
  • v2.5.6 Updated August 6, 2018
  • v2.5.7 Updated March 3, 2019
  • v2.5.8 Updated March 4, 2019

9. Reference Explanation

10. Additional information

01. About Blog Summary Links

02. About My Blog

Open source library address [most recyclerView use cases can be downloaded directly demo]: https://github.com/yangchong2...

Posted by mhouldridge on Sat, 11 May 2019 21:44:31 -0700