Method for optimizing use performance of RecyclerView control

A performance and initialization technology, which is applied in the field of Android system partition and data security, can solve problems such as inability to find ViewHolder, failure of multiplexing mechanism, slow page initialization speed, etc., to improve user experience, optimize performance, and optimize memory The effect of occupation

Inactive Publication Date: 2021-02-12
SICHUAN CHANGHONG ELECTRIC CO LTD
View PDF6 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0004] The purpose of the present invention is to provide a method for optimizing the performance of the RecyclerView control, in order to solve the problem that when the RecyclerView list page is initialized, the main thread loads the sub-View layout to create the ViewHolder, which takes time and causes the page initialization speed to be slow; the ViewHolder created without the adapter After recycling into the cache pool, RecyclerView cannot find a reusable ViewHolder, and needs to create a ViewHolder, which causes the problem that the reuse mechanism does not achieve the effect; in the process of fast sliding list, because the default cache number of each itemViewType in the cache pool is small, Causes RecyclerView to frequently create ViewHolder, causing the UI interface to freeze and not smooth

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method for optimizing use performance of RecyclerView control

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0018] In the prior art, when entering the RecyclerView list page and initially creating ViewHolders, if too many ViewHolders need to be created, the main thread will take a lot of time to load the layout, resulting in slower page initialization and affecting user experience. We hope that the main thread only handles UI events to avoid being blocked by time-consuming operations, thereby improving the application startup speed and optimizing user experience.

[0019] When refreshing the view, if the ViewHolder is not created through the adapter, the itemViewType used to store in the cache pool and look up the ViewHolder will be different. RecyclerView cannot find a reusable ViewHolder in the cache pool, so it needs to create a ViewHolder. The effect cannot be achieved by the mechanism. And we hope to make full use of the reuse characteristics of RecyclerView, avoid creating a large number of ViewHolders to consume memory, optimize memory usage, and display a large amount of dat...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a method for optimizing the use performance of a RecyclerView control, and belongs to the technical field of software. The detection method comprises the following steps of S1,before an interface is started, creating a sub-thread, asynchronously initializing a sub-View layout in the sub-thread, and generating a ViewHolder; and S2, storing the ViewHolder into a cache pool to be used by the Recycler View. The optimized Recycler View control has the advantages that the accommodating quantity of cache pools is increased, a large quantity of ViewHolders are pre-created in sub-threads and stored in the cache pools, the value of intemViewType of the ViewHolders is modified into the type value of the target ViewHolder by utilizing a reflection mechanism, the consistency ofthe stored and searched intemViewType is kept and the effect of reuse is achieved. And enough ViewHolder is created in the sub-thread, and a main thread is not occupied to execute a task, so that thepage initialization speed is increased.

Description

technical field [0001] The invention relates to the technical field of Android system partition and data security, and more specifically relates to a method for optimizing the performance of a RecyclerView control. Background technique [0002] RecyclerView has a four-level cache mechanism to cache ViewHolder. ViewHolder encapsulates the View view. When switching views, the ViewHolder is recycled and reused, and a large amount of data is displayed by maintaining a small amount of View. The RecyclerView caching process is: during the sliding process, the recycled View view will be cached in the CacheView first. The default size of the CacheView is 2. If it exceeds the maximum capacity, it will be saved in the RecycledViewPool. The cache pool is saved according to the viewType type of the ItemView. The default cache number of each itemViewType is 5, and if it exceeds, it will be recycled by GC. [0003] Currently, the ViewHolder reused by RecyclerView mainly exists in the ca...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F16/957
CPCG06F16/9574
Inventor 雷媛媛李金国
Owner SICHUAN CHANGHONG ELECTRIC CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products