Page display method, electronic equipment and storage medium
By caching the view layout in an asynchronous prefetch thread, the stuttering and frame dropping issues when scrolling the screen are resolved, resulting in smoother page display and a better user experience.
Patent Information
- Application Number
- CN202410103894.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-24
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-01-24
AI Technical Summary
Users often experience frame drops and stuttering when swiping on electronic device screens, affecting the smoothness of page display and user experience.
By fetching the view layout in an asynchronous prefetch thread and caching it to a cache list, we can ensure that the required view layout can be quickly obtained when the view items are displayed on the page, thus reducing the processing load on the main thread.
It improved the page display response speed, reduced lag and frame drops, and enhanced the user experience.
Smart Images

Figure CN119271320A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of intelligent terminals, and in particular to a page display method, an electronic device and a storage medium. Background Art
[0002] With the development of electronic devices, there are more and more applications (APPs) in electronic devices. At present, users can view the content of various applications through the display screen of electronic devices, such as viewing dynamic information posted by friends through social APPs, understanding various information through news APPs, browsing various products through shopping APPs, previewing various audio and video animations through audio and video APPs, etc.
[0003] When users browse content in an application, they can slide the screen to display more content in the application. However, when users slide the screen, frame loss and freeze often occur. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a page display method, an electronic device and a storage medium. In the method, the electronic device can store the view layout corresponding to the view item in the cache before displaying the view item on the page, so that the view layout can be directly obtained from the cache when the view item is displayed on the page, so that the electronic device can quickly display the view item, improve the response speed of the page display, make the page display smoother, and improve the user experience.
[0005] In a first aspect, an embodiment of the present application provides a page display method, which is applied to an electronic device. The method includes: in response to a first operation on a target application, the electronic device obtains at least one view layout through a first thread, and the at least one view layout includes a target view layout; the electronic device caches at least one view layout in a corresponding cache list according to the view type through the first thread, and the target view layout is cached in the target cache list; in response to a second operation on the target application, the electronic device determines that the view item to be displayed is the target view item through a second thread; the electronic device obtains the target view layout in the target cache list through the second thread, and generates an application interface including the target view item according to the target view layout; the electronic device displays the application interface.
[0006] The first thread and the second thread are threads for asynchronous processing, and the second thread is the main thread of the target application. Exemplarily, the first thread may be an asynchronous prefetch thread in RecyclerView.
[0007] The second operation is later than the first operation. For example, the first operation may be an operation of the user clicking an application control or an operation of the user sliding the screen. The second operation may be an operation of the user sliding the screen.
[0008] Specifically, when the first operation and the second operation are both operations of the user sliding the screen, the second operation may be any sliding operation of the screen after the first operation. For example, assuming that the first operation is the user sliding the screen for the first time, the second operation may be the user sliding the screen for the second time, or the third time, or the fourth time, and this application does not limit this.
[0009] Specifically, the view layout, also known as ViewHolder, can be used to determine the layout of displayed data.
[0010] The target view layout may be a target layout in the view layouts obtained by the asynchronous processing thread. The target cache list may be a cache list corresponding to the view type of the target view layout. The target view item may be a view item to be displayed on the screen of the electronic device in response to the second operation. Specifically, the target view item corresponds to the target view layout.
[0011] In this way, before the electronic device displays the application interface containing the view item in the page, it obtains the ViewHolder through an asynchronous thread and stores the obtained ViewHolder in the cache, so that when the electronic device displays the view item in the page, it can directly obtain the ViewHolder corresponding to the view item in the cache, so that the electronic device can quickly display the view item in the page, improve the response speed of the page display, make the page display smoother, and improve the user experience.
[0012] According to the first aspect, the electronic device further comprises a recycling pool;
[0013] The electronic device obtains at least one view layout through the first thread, which may include: the electronic device determines first position data and second position data through the first thread, and sequentially uses each position data between the first position data and the second position data as current position data; the first thread obtains the view layout corresponding to the current position data through the recycling pool according to the current view type corresponding to the current position data.
[0014] Specifically, the recycling pool, also known as Recycler, can be used to recycle ViewHolder.
[0015] The first position data may be a view item position corresponding to the first view layout obtained by the first thread, for example, a pre-fetch start position. The second position data may be a view item position corresponding to the last view layout obtained by the first thread, for example, a pre-fetch end position. It is understandable that the view item position is a positive integer.
[0016] The current view type may be the view type of the view item corresponding to the current position data.
[0017] In this way, the electronic device can determine multiple current position data through the first thread, and thus sequentially obtain the view layout corresponding to each current position data.
[0018] According to the first aspect, or any implementation manner of the first aspect above, the electronic device determines the first position data and the second position data through the first thread, which may include: the electronic device obtains the first threshold through the first thread, and determines the position data corresponding to the first view item, and the position data corresponding to the second view item; the electronic device determines the first position data and the second position data through the first thread according to the position data of the first view item and the first threshold when the first operation is a first type of operation; the electronic device determines the first position data and the second position data through the first thread according to the position data corresponding to the first view item, the position data corresponding to the second view item and the first threshold when the first operation is a second type of operation.
[0019] The first threshold may be a pre-set threshold of a view item position corresponding to the view layout. Exemplarily, the first threshold may be a pre-fetch upper limit threshold.
[0020] The first view item is a view item with the largest position data among the view items displayed on the screen. Specifically, the first view item is the last view item displayed on the screen. It can be understood that the screen can display multiple view items, and the last view item can be the one with the largest position data among the view items.
[0021] The second view item is a view item with the largest position data among the view items stored in the cache. Specifically, the second view item is the last view item stored in the cache. It can be understood that the cache can store multiple view items, and the position data corresponding to the last view item is the largest. That is, the second view item can be the view item corresponding to the last view layout obtained by the first thread when the electronic device responds to the previous operation adjacent to the first operation.
[0022] The first type of operation may be an operation in which the user clicks on an application control. The second type of operation may be an operation in which the user slides the screen. That is, the first type of operation may start a target application, and after the target application is started, the user may perform the second type of operation.
[0023] In this way, the electronic device can determine the position data corresponding to the view layout obtained by the first thread under different types of user operations to ensure that sufficient view layouts are stored in the cache, so that the electronic device can display the picture more smoothly in response to the user sliding the screen.
[0024] According to the first aspect, or any implementation of the first aspect above, the electronic device determines the first position data and the second position data based on the position data of the first view item and the first threshold, which may include: the electronic device determines the sum of the position data of the first view item and a fixed value as the first position data, and determines the sum of the position data of the first view item and the first threshold as the second position data.
[0025] The fixed value may be any fixed value. For example, the fixed value may be 1.
[0026] In this way, after the user clicks the application control to start the target application, the electronic device can determine the position data corresponding to the view layout acquired by the first thread to acquire the view layout corresponding to each position data.
[0027] According to the first aspect, or any implementation of the first aspect, before the electronic device determines the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item, and the first threshold, the electronic device may further include: the electronic device determines an operation direction of the first operation;
[0028] When the operation direction of the first operation of the electronic device is the first direction, determining the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item and the first threshold value may include: the electronic device determines the maximum value between the position data corresponding to the first view item and the position data corresponding to the second view item, and determines the sum of the maximum value and the fixed value as the first position data; the electronic device determines the sum of the position data of the first view item and the first threshold value as the second position data.
[0029] The operation direction of the first operation may be the direction in which the screen slides when the first operation is a user sliding the screen. The first direction may be when the user slides the screen upward or leftward. It is understandable that when the user slides the screen upward or leftward, the page displayed on the screen can be refreshed.
[0030] In this way, when the user slides the screen upward or leftward, the electronic device can determine the position data corresponding to the view layout acquired by the first thread to acquire the view layout corresponding to each position data.
[0031] According to the first aspect, or any implementation manner of the first aspect above, when the operation direction of the first operation is the second direction, the electronic device determines the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item and the first threshold value, which may include: the electronic device determines the difference between the position data corresponding to the first view item and the first threshold value as the first position data; the electronic device determines the minimum value between the position data corresponding to the first view item and the position data corresponding to the second view item as the second position data.
[0032] The second direction may be that the user slides the screen downward or to the right. It is understandable that the user slides the screen downward or to the right to view the page previously displayed on the screen.
[0033] In this way, when the user slides the screen downward or rightward, the electronic device can determine the position data corresponding to the view layout acquired by the first thread to acquire the view layout corresponding to each position data.
[0034] According to the first aspect, or any implementation of the first aspect above, the electronic device may further include an adapter;
[0035] The electronic device obtains the view layout corresponding to the current position data based on the current view type corresponding to the current position data, which may include: the electronic device determines the current number of view layouts in the cache list corresponding to the current view type; when the current number is less than a second threshold, the electronic device creates the view layout corresponding to the current position data through an adapter.
[0036] Specifically, an adapter can be used to create a ViewHolder and bind the ViewHolder to the data in the database.
[0037] The current number may be the number of view layouts in the cache list corresponding to the current view type. The second threshold may be a preset maximum number of ViewHolders stored in the cache list corresponding to each view type, for example, a preset number threshold.
[0038] In this way, when the view layout data in the cache list is insufficient, the electronic device can create a view layout through the adapter, so that enough ViewHolders can be stored in the cache, and then when the view item is displayed in the page, the ViewHolder corresponding to the view item can be obtained in the cache, thereby improving the response speed of the page display.
[0039] According to the first aspect, or any implementation of the first aspect above, before the electronic device creates the view layout corresponding to the current position data through the adapter, the electronic device may further include: the electronic device acquires a lock corresponding to the current position data;
[0040] After the electronic device creates the view layout corresponding to the current position data through the adapter, the electronic device may further include: releasing the lock corresponding to the current position data.
[0041] In this way, the electronic device obtains the lock corresponding to the current position data before creating the view layout corresponding to the current position data, and releases the lock corresponding to the current position data after creating the view layout corresponding to the current position data, thereby avoiding the situation where multiple threads concurrently access the current position data (such as the first thread and the second thread accessing it at the same time).
[0042] According to the first aspect, or any implementation of the first aspect above, the electronic device responds to a first operation on a target application and obtains at least one view layout through a first thread, which may include: the electronic device responds to the first operation on the target application and sends a view layout acquisition request to the first thread through a second thread; the electronic device obtains at least one view layout according to the view layout acquisition request through the first thread.
[0043] The view layout acquisition request may be a request for acquiring the view layout sent by the second thread to the first thread.
[0044] In this way, the electronic device can respond to the user operation and send a view layout acquisition request to the first thread through the second thread, so that the first thread acquires the view layout according to the view layout acquisition request.
[0045] According to the first aspect, or any implementation of the first aspect above, the electronic device responds to a first operation on a target application and sends a view layout acquisition request to the first thread through a second thread, which may include: the electronic device determines the state of the first thread through the second thread when the first operation is a second type of operation; the electronic device determines, through the second thread, a data difference between position data corresponding to the second view item and position data corresponding to the third view item when the state of the first thread is the second state; and the electronic device sends the view layout acquisition request to the first thread through the second thread when the data difference is less than a third threshold.
[0046] The state of the first thread may be a working state of the first thread, for example, a busy state or an idle state. The second state may be an idle state.
[0047] The third view item is the first view item to be displayed on the screen in response to the first operation. It can be understood that the third view item can be the next view item of the last view item displayed on the screen.
[0048] The third threshold may be another preset threshold of the view item position corresponding to the view layout. Exemplarily, the third threshold may be a pre-fetch lower limit threshold.
[0049] In this way, when the first thread is idle and there are fewer view layouts in the cache, the electronic device can send a view layout acquisition request to the first thread through the second thread to obtain the view layout through the first thread, thereby avoiding congestion and ensuring that there are enough view layouts in the cache.
[0050] According to the first aspect, or any implementation of the first aspect above, the electronic device responds to a first operation on a target application, and the second thread sends a view layout acquisition request to the first thread, which can include: the electronic device creates the first thread through the second thread when the first operation is a first type of operation; and the electronic device sends the view layout acquisition request to the first thread through the second thread when the first thread is successfully created.
[0051] The first thread and the second thread have the same priority.
[0052] In this way, the electronic device can execute the task of obtaining the view layout more quickly by creating an asynchronous thread with the same priority as the main thread of the target application, thereby improving the response speed of the asynchronous thread.
[0053] According to the first aspect, or any implementation of the first aspect above, the method may also include: after receiving a view layout acquisition request through the first thread, the electronic device sends a first instruction to the second thread, and updates the state of the first thread to the first state through the second thread according to the first instruction; after caching all acquired view layouts to a corresponding cache list through the first thread, the electronic device sends a second instruction to the second thread, and updates the state of the first thread to the second state through the second thread according to the second instruction.
[0054] The first instruction may be an instruction for the first thread to start executing the task of obtaining the view layout, and the second instruction may be an instruction for the first thread to end executing the task of obtaining the view layout.
[0055] The first state may be a busy state.
[0056] Specifically, if the first thread is executing the task of acquiring the view layout, the state of the first thread is a busy state. If the first thread is not executing the task of acquiring the view layout, the state of the first thread is an idle state.
[0057] In this way, the electronic device can update the state of the first thread according to the instruction of the first thread through the second thread, so as to determine whether the task of obtaining the view layout is currently being executed according to the state of the first thread.
[0058] According to the first aspect, or any implementation method of the first aspect above, after the second thread of the electronic device obtains the target view layout in the target cache list, it may also include: when the electronic device fails to obtain the target view layout, the second thread obtains the lock of the position data corresponding to the target view item through the recycling pool; the second thread creates the target view layout through the adapter, and releases the lock of the position data corresponding to the target view item through the recycling pool.
[0059] In this way, when the electronic device fails to obtain the target view layout in the cache, it can create the target view layout through the adapter, thereby ensuring that the electronic device can display the view items corresponding to the target view layout in the page.
[0060] According to the first aspect, or any implementation of the first aspect above, after the second thread obtains the lock of the position data corresponding to the target view item through the recycling pool, the electronic device may further include: the electronic device obtains the target view layout in the target cache list through the second thread;
[0061] The second thread creates a target view layout through an adapter and releases a lock on position data corresponding to a target view item through a recycling pool, which may include: when the electronic device fails to acquire the target view layout, the second thread creates a target view layout through an adapter and releases a lock on position data corresponding to a target view item through a recycling pool.
[0062] It can be understood that if the electronic device successfully obtains the target view layout from the target cache list again after the second thread obtains the lock of the position data corresponding to the target view item through the recycling pool, it is not necessary to create the target view layout through the adapter and the lock of the position data corresponding to the target view item can be released directly through the recycling pool.
[0063] In this way, after acquiring the lock of the position data corresponding to the target view item, the electronic device can try to acquire the target view layout in the cache again, thereby determining whether the target view layout is stored in the cache during the process of acquiring the lock.
[0064] In a second aspect, an embodiment of the present application provides an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device executes the page display method of the first aspect and any one of the first aspects.
[0065] The second aspect and any implementation of the second aspect correspond to the first aspect and any implementation of the first aspect respectively. The technical effects corresponding to the second aspect and any implementation of the second aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.
[0066] In a third aspect, an embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium includes a computer program, and when the computer program is executed on an electronic device, the electronic device executes the page display method of the first aspect and any one of the first aspects.
[0067] The third aspect and any implementation of the third aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation of the third aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here.
[0068] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed, enables a computer to execute a page display method as described in the first aspect or any one of the first aspects.
[0069] The fourth aspect and any implementation of the fourth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fourth aspect and any implementation of the fourth aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.
[0070] In a fifth aspect, the present application provides a chip, the chip comprising a processing circuit and a transceiver pin, wherein the transceiver pin and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the page display method of the first aspect or any one of the first aspects to control the receiving pin to receive a signal, and to control the sending pin to send a signal.
[0071] The fifth aspect and any implementation of the fifth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fifth aspect and any implementation of the fifth aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 This is a schematic diagram showing the working principle of RecyclerView.
[0073] Figure 2 is a schematic diagram of the hardware structure of an electronic device shown as an example;
[0074] Figure 3 A schematic diagram of the software structure of an electronic device is shown as an example;
[0075] Figure 4 An application scenario is shown as an example;
[0076] Figure 5a A schematic diagram of a flow chart of loading a view item in a page is shown as an example;
[0077] Figure 5b A schematic diagram of module interaction of an exemplary page display method;
[0078] Figure 6 A schematic diagram of a flow chart of loading view items in another page shown as an example;
[0079] Figure 7 The module interaction diagram for creating an asynchronous prefetch thread is shown as an example;
[0080] Figure 8 The figure is a schematic diagram of module interaction for executing an asynchronous prefetch task as an example;
[0081] Figure 9-10 The figure is a schematic diagram of module interaction for exemplifying another page display method. DETAILED DESCRIPTION
[0082] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0083] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0084] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.
[0085] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0086] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.
[0087] Some terms used in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.
[0088] RecyclerView (display list control) is a control for displaying large amounts of data. It can be used to display data in list or grid form, such as text or photos.
[0089] ViewHolder can be a layout that displays data. Each ViewHolder in RecyclerView is displayed as a view item. Each ViewHolder is an independent view object that contains a specific layout. In other words, each view can correspond to a ViewHolder object.
[0090] Item (data item) can be the data to be displayed in the database. Each item represents an independent data entity, which can be text, picture or other custom components. Usually, each item corresponds to a view item, which is used to display the content and style of the data entity. Moreover, each item has a corresponding position in the database. The position of the item in the database can be called the data position or the view item position. For example, if there are 100 items (item1-item100) in the database, the position of the second item can be 2.
[0091] ViewType can be used to distinguish different layout types. Each data item has a corresponding layout type, that is, each view item has a corresponding layout type. The layout type corresponding to a data item (or view item) can be determined based on the location of the data item.
[0092] If there are multiple layout types in RecyclerView, you need to assign a ViewType to each layout type. That is, a ViewHolder of a layout type corresponds to a ViewType. The ViewHolder of each layout type can include one or more ViewHolder objects.
[0093] RecyclerView can flexibly display various types of data by using ViewHolder and item binding of different layout types. When RecyclerView needs to display a data item, it will find the corresponding ViewHolder according to the ViewType of the data item, and then bind the data item to the ViewHolder to display it on the interface.
[0094] LayoutManager is responsible for managing the layout of data and can control the layout style of each item in RecyclerView, such as linear layout, table layout, waterfall layout, etc. It can determine how the view is displayed according to the different types and arrangements of data.
[0095] Recycler (recycling pool) can be used to recycle ViewHolder. In fact, only a small number of view items can be displayed on the mobile phone screen. When the user slides the mobile phone screen, the view items will slide out of the screen. RecyclerView can recycle the ViewHolder corresponding to the view items that slide out of the screen and cache them in the Recycler cache, and take them out of the Recycler cache when needed. Specifically, the Recycler cache can cache ViewHolders of different ViewTypes.
[0096] Adapter can create ViewHolder and bind ViewHolder to the data in the database. Specifically, Adapter can include onCreateViewHolder method and onBindViewHolder method. Among them, onCreateViewHolder method is used to create and initialize ViewHolder and its associated view items. However, onCreateViewHolder method does not fill the view content of ViewHolder. onBindViewHolder method is used to extract appropriate data and fill the view content of ViewHolder.
[0097] Reference Figure 1 When RecyclerView needs to display a view item, the Recycler in RecyclerView calls the onCreateViewHolder method of the Adapter to create a new ViewHolder object, which will contain the content of the view item. The onCreateViewHolder method usually returns a ViewHolder object. When ViewHolder needs to bind data, the Recycler in RecyclerView can call the onBindViewHolder method of the Adapter to obtain data from the database, and bind the data to the view item through the Adapter, so that the data can be displayed on the screen after the view is filled.
[0098] The page display method provided in the embodiment of the present application can be applied to electronic devices. Optionally, the electronic device in the embodiment of the present application can be a mobile phone with a touch display function, a sports camera (GoPro), a digital camera, a tablet computer, a handheld computer, a vehicle-mounted device, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) / virtual reality (VR) device, etc. The embodiment of the present application does not impose any special restrictions on the specific form of the electronic device.
[0099] In order to better understand the embodiments of the present application, the structure of the electronic device in the embodiments of the present application is introduced below:
[0100] like Figure 2 The figure shows a schematic diagram of the structure of the electronic device 100. Optionally, the electronic device 100 may be a terminal, which may also be referred to as a terminal device, and the terminal may be a device with a touch display function such as a cellular phone or a tablet computer (pad), which is not limited in the present application.
[0101] It should be understood that Figure 2 The electronic device 100 shown is only one example of an electronic device, and the electronic device 100 may have more or fewer components than shown in the figure, may combine two or more components, or may have a different configuration of components. Figure 2 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0102] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor, a gyroscope sensor, an acceleration sensor, a temperature sensor, a motion sensor, an air pressure sensor, a magnetic sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
[0103] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0104] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0105] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.
[0106] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0107] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0108] The mobile communication module 150 may provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc.
[0109] The wireless communication module 160 can provide wireless communication solutions for application in the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.
[0110] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.
[0111] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0112] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0113] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0114] The ISP is used to process the data fed back by the camera 193. The ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0115] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0116] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement a data storage function.
[0117] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121, such as enabling the electronic device 100 to implement the page display method in the embodiment of the present application. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0118] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0119] The pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor can be arranged on the display screen 194. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor.
[0120] The touch sensor is also called a "touch panel". The touch sensor can be set on the display screen 194. The touch sensor and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor is used to detect a touch operation on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
[0121] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0122] Figure 3 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
[0123] The layered architecture of the electronic device 100 divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android Runtime) and the system library, the hardware abstraction layer (HAL) and the kernel layer.
[0124] The application layer can include a series of application packages.
[0125] like Figure 3 As shown, the application package may include a camera, a gallery, and third-party applications, etc. Exemplarily, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message microblog, WeChat, headlines and other applications.
[0126] In the embodiment of the present application, the application layer may also include RecyclerView, Adapter, and database.
[0127] Among them, RecyclerView can be used to display data on the screen of an electronic device.
[0128] Specifically, RecyclerView can include an application interface module, an asynchronous prefetch module, a LayoutManager, and a Recycler. The application interface module can be used to interact with the application and send a request to the asynchronous prefetch module to perform an asynchronous prefetch task. The LayoutManager can be used to manage the layout of the data displayed on the display screen. When a view item on the mobile phone screen slides out of the screen, the Recycler can be used to recycle the ViewHolder corresponding to the view item that slides out of the screen, and store the ViewHolder obtained by the asynchronous prefetch module.
[0129] The asynchronous pre-fetch module can be used to obtain the ViewHolder corresponding to the data at the preset position, and cache the obtained ViewHolder in the Recycler. In the embodiment of the present application, the asynchronous pre-fetch module can also be understood as an asynchronous pre-fetch thread.
[0130] The Adapter can create a ViewHolder. The Adapter can also obtain data from the database and bind the data to the view items in the ViewHolder.
[0131] The database is used to store data, which can be the content displayed by the application on the display screen.
[0132] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer, including various components and services to support developers' Android development. The application framework layer includes some predefined functions.
[0133] like Figure 3 As shown, the application framework layer may include a window manager, a content provider, a view system, a resource manager, a notification manager, a camera service, etc.
[0134] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0135] Content providers are used to store and retrieve data and make it accessible to applications. The data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0136] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0137] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0138] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0139] The camera service is used to call the camera (including the front camera and / or the rear camera) in response to a request from an application.
[0140] Android Runtime includes core libraries and virtual machines. Android Runtime is responsible for scheduling and management of the Android system.
[0141] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0142] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0143] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0144] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0145] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0146] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0147] A 2D graphics engine is a drawing engine for 2D drawings.
[0148] The HAL layer is an interface layer between the operating system kernel and the hardware circuit. The HAL layer includes but is not limited to: a camera HAL module and an audio HAL module. The camera HAL module is used to process the image stream, and the audio HAL module is used to process the audio stream (for example, noise reduction, directional enhancement, etc.).
[0149] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, audio driver, image sensor driver module, etc.
[0150] The hardware includes at least processor, display, camera, sensor equipment, etc.
[0151] Understandably, Figure 3 The layers in the software structure shown and the components included in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer layers than shown, and each layer may include more or fewer components, which is not limited in the present application.
[0152] It is understandable that, in order to implement the page display method in the embodiment of the present application, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.
[0153] Combine the following Figure 4 The application scenario of the page display method of the embodiment of the present application is described. In this scenario, the electronic device is a mobile phone as an example for explanation.
[0154] Reference Figure 4, users can view the content of each application through the electronic device. Generally, the user can slide the screen vertically (such as up and down) or horizontally (such as left and right) on the page displayed by the electronic device to browse more content in the application.
[0155] Users can Figure 4 In the mobile phone interface shown in (1) of FIG, you can browse the dynamic information posted by Weibo users in the Weibo application, or you can browse the dynamic information posted by Weibo users in the mobile phone interface shown in (1) of FIG. Figure 4 In the mobile phone interface shown in (2), news information in the news application is browsed. Figure 4 As shown in (1) and (2) in FIG, when a user browses microblog dynamic information or news information, he or she can browse more content by sliding the screen up and down.
[0156] Users can also Figure 4 In the mobile phone interface shown in (3) of the figure, you can browse the product information in the shopping application, or you can browse the product information in the mobile phone interface shown in (3) of the figure. Figure 4 In the mobile phone interface shown in (4), the video and audio animation in the video application is browsed. Figure 4 As shown in (3) and (4) in FIG, when a user browses product information or video animations, he or she can browse more content by sliding the screen left or right.
[0157] It should be noted that Figure 4 Only the application scenarios of sliding the screen up and down and sliding the screen left and right are shown as examples. In fact, the electronic device can set the sliding mode of the screen through the LayoutManager in the RecyclerView to display data by sliding up and down or sliding left and right on the screen. That is, the user can slide the screen up and down or left and right in any application to browse the content in the application. In this way, when the user browses Weibo dynamic information or product information, he can also browse more content by sliding the screen left and right. Similarly, when the user browses news information or audio and video animations, he can also browse more content by sliding the screen up and down.
[0158] The following uses a specific example to explain how a mobile phone displays a page when a user slides the screen.
[0159] Figure 5a FIG. 1 is a flow chart showing an exemplary process of loading a view item in a page. Figure 5a As shown, the view type of the ViewHolder corresponding to the view items Item1, Item2, Item3, and Item5 is ViewType1. The view type of the ViewHolder corresponding to the view item Item4 is ViewType2. Among them, the view item ItemN is the view item corresponding to the data at position N in the database.
[0160] The cache of the Recycler in the electronic device includes the cache list of ViewType1 and the cache list of ViewType2. When the user slides the screen along the sliding direction, the electronic device responds to the user operation and slides the view item Item1 out of the page, and the ViewHolder corresponding to the view item Item1 is recycled by the Recycler to the cache list of ViewType1. At this time, no ViewHolder of the ViewType2 view type is recycled by the Recycler, so the cache list of ViewType2 is empty.
[0161] When the user slides the screen along the sliding direction, the electronic device responds to the user operation and obtains the ViewHolder corresponding to the view item Item6 through the Recycler.
[0162] If the view type of the ViewHolder corresponding to the view item Item6 is ViewType1, when the ViewHolder corresponding to the view item Item6 is obtained through the Recycler, since there is a recycled ViewHolder in the cache list of ViewType1, the Recycler can directly obtain the ViewHolder with the view type of ViewType1 in the cache list of ViewType1.
[0163] If the view type of the ViewHolder corresponding to the view item Item6 is ViewType2, when the ViewHolder corresponding to the view item Item6 is obtained through the Recycler, since there is no recycled ViewHolder in the cache list of ViewType2, the Recycler cannot obtain the ViewHolder of the view type ViewType2 in the cache list of ViewType2. Therefore, the Recycler needs to call Adpter to create a ViewHolder of the view type ViewType2 through Adpter.
[0164] After obtaining the ViewHolder corresponding to the view item Item6, the electronic device can bind the ViewHolder to the data in the database, and after the data binding, the view item Item6 can be displayed on the mobile phone screen.
[0165] The following is a detailed introduction to the specific process of "how the phone displays a page when the user slides the phone screen".
[0166] Figure 5b FIG. 1 is a schematic diagram showing the module interaction of a page display method. Figure 5bThe specific process of "how the phone displays the page when the user slides the phone screen" includes:
[0167] S101. The application responds to the user's screen sliding operation and sends a user sliding event to the application interface module in the RecyclerView.
[0168] The user sliding event may be an event generated by the application in response to the user sliding screen operation. The user sliding screen operation may be an operation of the user sliding the screen up and down or left and right, which is not limited in this application.
[0169] After the user slides the screen, the electronic device can generate a user sliding event in response to the user operation through the application, and send the user sliding event to the application interface module in the RecyclerView through the application.
[0170] Specifically, the process of an electronic device generating a user sliding event in response to a user operation through an application may include: when the user slides the screen, the touch screen driver captures the user operation, generates an input event based on the user operation, and then sends the input event to the input system; the input system converts the input event into a message that the application layer can understand, and sends it to the application; when the application receives the Vysnc signal, it generates a user sliding event based on the message sent by the input system.
[0171] It should be noted that after the user slides the screen and lets go, the page on the screen can be scrolled and refreshed. Thus, the application can respond to the user operation and continue to send the user sliding event to the application interface module in the RecyclerView when receiving the Vysnc signal.
[0172] S102. The application interface module in RecyclerView calculates the sliding distance according to the user sliding event, and sends the sliding distance to LayoutManager.
[0173] The sliding distance may include a sliding distance in a vertical direction and a sliding distance in a horizontal direction.
[0174] After receiving the user sliding event sent by the application, the application interface module in RecyclerView calculates the vertical sliding distance and the horizontal sliding distance, and sends the vertical sliding distance and the horizontal sliding distance to LayoutManager. For the relevant processing flow of calculating the sliding distance by the application interface module in RecyclerView, please refer to the existing technology, which will not be repeated here.
[0175] S103. LayoutManager determines the position of the new view item corresponding to the new view item according to the sliding distance, and generates a new view item acquisition request according to the position of the new view item.
[0176] New view items refer to the view items that are added and need to be displayed on the mobile phone screen after the user slides the screen, such as Figure 5a The view item Item6 in the new view item. The location of the new view item refers to the location of the data corresponding to the new view item in the database. For example, Figure 5a The position of the data corresponding to the view item Item6 in the database may be 6. It can be understood that each piece of data in the database has a corresponding position, and the electronic device can read the data in the database according to the position of the data.
[0177] The newly added view item acquisition request may be a request for acquiring the newly added view item. It is understandable that the electronic device may display the newly added view item on the mobile phone screen only after the LayoutManager acquires the newly added view item.
[0178] After receiving the sliding distance, LayoutManager can determine the position of the newly added view item corresponding to the newly added view item according to the sliding distance, and generate a request for obtaining the newly added view item according to the position of the newly added view item. The request for obtaining the newly added view item includes the position of the newly added view item. The relevant processing flow of LayoutManager determining the position of the newly added view item corresponding to the newly added view item can refer to the existing technology and will not be repeated here.
[0179] S104. LayoutManager sends the generated new view item acquisition request to Recycler. After receiving the new view item acquisition request, Recycler sends the new view item position in the new view item acquisition request to the adapter.
[0180] S105. The Adapter determines the target view type according to the position of the newly added view item, and sends the target view type to the Recycler.
[0181] The target view type can be the type of the view item corresponding to the newly added view item position. RecyclerView can include multiple view types, each view type can correspond to one or more view items, and one view item can correspond to one ViewHolder object. In other words, each view type can correspond to one or more ViewHolder objects.
[0182] After receiving the position of the newly added view item, the Adapter determines the target view type according to the position of the newly added view item and sends the target view type to the Recycler. Specifically, the Adapter can determine the target view type according to the position of the newly added view item through the getItemViewType method.
[0183] S106. Recycler determines whether there is a target ViewHolder of the target view type in the cache; if so, execute S107; if not, execute S108.
[0184] The target ViewHolder can be a ViewHolder of the target view type.
[0185] After receiving the target view type sent by the Adapter, the Recycler can determine whether there is a target ViewHolder in the cache.
[0186] If there is a target ViewHolder of the target view type in the cache, the Recycler can directly get the target ViewHolder in the cache.
[0187] If there is no target ViewHolder of the target view type in the cache, the Recycler can send a request to create a target ViewHolder to the Adapter to create the target ViewHolder through the Adapter.
[0188] S107. Recycler obtains the target ViewHolder in the cache.
[0189] S108. Recycler sends a target ViewHolder creation request to Adapter. After receiving the target ViewHolder creation request sent by Recycler, Adapter creates a target ViewHolder and sends the target ViewHolder to Recycler.
[0190] If there is no target ViewHolder of the target view type in the cache, the Recycler can send a request to the Adapter to create the target ViewHolder. After receiving the request to create the target ViewHolder sent by the Recycler, the Adapter creates the target ViewHolder and sends the target ViewHolder to the Recycler.
[0191] Regarding the relevant processing flow of Adapter creating the target ViewHolder, you can refer to the existing technology and will not go into details here.
[0192] S109. After obtaining the target ViewHolder, the Recycler determines whether the target ViewHolder has been bound to data; if not, execute S110; if so, execute S112.
[0193] S110 , the Recycler sends a target ViewHolder binding data request to the Adapter. After receiving the target ViewHolder binding data request sent by the Recycler, the Adapter obtains the target data from the database.
[0194] The data binding request may be a request to bind the target ViewHolder with corresponding data. The target data may be data corresponding to the position of the newly added view item that needs to be displayed on the mobile phone screen.
[0195] S111. The Adapter performs data binding on the target data obtained from the database and the view items in the target ViewHolder, and sends the data-bound target ViewHolder to the Recycler.
[0196] S112, Recycler sends the target ViewHolder bound to the data to LayoutManager, and LayoutManager performs layout rendering on the newly added view items according to the target ViewHolder. LayoutManager sends the layout rendered newly added view items to the application through the application interface module in RecyclerView, so as to display the newly added view items on the mobile phone screen.
[0197] Regarding the relevant processing flow of LayoutManager for layout rendering of newly added view items, please refer to the existing technology and will not be repeated here.
[0198] In the process of the electronic device responding to the user's operation to display the page, if there is no target ViewHolder of the target view type in the Recycler's cache, the Recycler cannot obtain the target ViewHolder in the cache. For example, Figure 5a When the view type of the ViewHolder corresponding to the view item Item6 is ViewType2, the Recycler cannot obtain the ViewHolder of view type ViewType2 in the cache list of ViewType2.
[0199] At this point, the main thread of the application can send a target ViewHolder creation request to the Adapter through the Recycler to create the target ViewHolder through the Adapter. However, the process of the Adapter creating the target ViewHolder will take time, and the more complex the view items corresponding to the target ViewHolder are, the more time it will take to create the target ViewHolder.
[0200] Therefore, when the electronic device responds to user operations to display a page, if there is no target ViewHolder in the Recycler's cache, the main thread of the application may take a long time to create the target ViewHolder through the Adapter, resulting in freezes and frame drops when the page is displayed, affecting the user experience.
[0201] In order to solve the above technical problems, an embodiment of the present application provides a page display method. In this method, the electronic device creates a ViewHolder by calling the Adapter in an asynchronous prefetch thread, and caches the created ViewHolder in the Recycler, so that there are enough ViewHolders in the Recycler's cache. Furthermore, when the electronic device displays a page in response to the user's sliding screen operation, it can ensure that there are enough ViewHolders in the Recycler's cache, so that the electronic device can obtain the ViewHolder in the Recycler's cache, without calling the Adapter in the main thread of the application to create the ViewHolder, thereby avoiding the page display freeze, frame loss, etc. caused by time-consuming, making the page display smoother and improving the user experience.
[0202] The following is an explanation of the specific process of the page display method of the embodiment of the present application.
[0203] Figure 6 FIG. 1 is a flow chart showing another exemplary process of loading view items in a page. Figure 6 As shown, view item Item21, view item Item22, view item Item23 and view item Item24 are displayed on the mobile phone screen.
[0204] When the user slides the mobile phone screen along the sliding direction, the electronic device responds to the user operation, obtains the ViewHolder corresponding to the view item Item25 through the Recycler, and binds the ViewHolder to the data in the database. After the data is bound, the view item Item25 can be displayed on the mobile phone screen.
[0205] When the electronic device responds to the user sliding the screen, it can call the Adapter to create a ViewHolder (such as Figure 6 The created ViewHolder is cached in the Recycler. Among them, "A" in view item ItemA is greater than "25" in view item Item25, and "B" in view item ItemB is greater than "A" in view item ItemA. That is, the position of the data in the database corresponding to view item ItemA is behind the position of the data in the database corresponding to view item Item25. The position of the data in the database corresponding to view item ItemB is behind the position of the data in the database corresponding to view item ItemA.
[0206] Specifically, when the electronic device calls the Adapter to create a ViewHolder through an asynchronous prefetch thread, it can create ViewHolders corresponding to multiple view items, that is, there can be several view items between view item ItemA and view item ItemB. In addition, different view items can correspond to ViewHolders of different view types, and ViewHolders of different view types can be cached in different cache lists in the Recycler.
[0207] Reference Figure 6 , the asynchronous prefetch thread can call the Adapter to create a ViewHolder corresponding to the view item ItemA. Among them, the view type of the view item ItemA is ViewType2. After creating the ViewHolder corresponding to the view item ItemA, the asynchronous prefetch thread can cache the ViewHolder corresponding to the view item ItemA into the cache list of ViewType2 in the Recycler.
[0208] Continue to refer to Figure 6 , the asynchronous prefetch thread can also call the Adapter to create a ViewHolder corresponding to the view item ItemB. Among them, the view type of the view item ItemB is ViewType1. After creating the ViewHolder corresponding to the view item ItemB, the asynchronous prefetch thread can cache the ViewHolder corresponding to the view item ItemB into the cache list of ViewType1 in the Recycler.
[0209] Before the electronic device calls the Adapter to create the ViewHolder through the asynchronous prefetch thread, it needs to create an asynchronous prefetch thread. Figure 7 The interactive process diagram of each module shown in FIG. 1 is used to explain the relevant process of creating an asynchronous prefetch thread in an electronic device. Figure 7 , specifically including:
[0210] S201. The application responds to the user clicking on the application control and sends a RecyclerView creation request to the application interface module in the RecyclerView to create the RecyclerView through the application interface module.
[0211] The user clicks the application control, and the electronic device responds to the user's click operation to start the application, so that the user can view the content of the application on the mobile phone screen. After the application is started, the main thread of the application can send a RecyclerView creation request to the application interface module in the RecyclerView.
[0212] The application interface module in RecyclerView can create RecyclerView after receiving the RecyclerView creation request sent by the main thread of the application. For the relevant processing flow of creating RecyclerView, please refer to the existing technology, which will not be repeated here.
[0213] S202: The application interface module creates an asynchronous prefetch thread and determines a prefetch upper threshold and a prefetch lower threshold.
[0214] The priority of the asynchronous prefetch thread is consistent with the priority of the main thread of the application program, so as to ensure that the asynchronous prefetch thread can execute the asynchronous prefetch task faster and improve the response speed of the asynchronous prefetch thread.
[0215] In this implementation example, the asynchronous prefetch thread is an asynchronous processing thread of the main thread of the application program.
[0216] The asynchronous prefetch thread can be used to prefetch the ViewHolder corresponding to the view item, and cache the obtained ViewHolder in the Recycler. Specifically, when the asynchronous prefetch thread prefetches the ViewHolder corresponding to the view item, the corresponding ViewHolder can be obtained according to the view item position corresponding to the view item.
[0217] The prefetch upper limit threshold may be the upper limit threshold of the view item position corresponding to the view item when the pre-set asynchronous prefetch thread executes the asynchronous prefetch task. Specifically, the prefetch upper limit threshold may be used to terminate the currently executing prefetch task, that is, after obtaining the ViewHolder corresponding to the prefetch upper limit threshold, the currently executing prefetch task is terminated.
[0218] The prefetch lower limit threshold may be the lower limit threshold of the view item position corresponding to the view item when the pre-set asynchronous prefetch thread executes the asynchronous prefetch task. Specifically, the prefetch lower limit threshold may be used to start the prefetch task, that is, when the calculated position difference is less than the prefetch lower limit threshold, the prefetch task is started. The calculated position difference may be the difference between the view item position corresponding to the newly added view item on the screen and the view item position corresponding to the last ViewHolder prefetched in the last asynchronous prefetch task.
[0219] S203: After the asynchronous prefetch thread is created, the application interface module sends an asynchronous prefetch task execution request to the asynchronous prefetch module, and executes the asynchronous prefetch task through the asynchronous prefetch module.
[0220] The asynchronous prefetch task is the task of obtaining the ViewHolder and caching the ViewHolder to the Recycler performed by the asynchronous prefetch module.
[0221] After creating the asynchronous prefetch thread, the application interface module can send an asynchronous prefetch task execution request to the asynchronous prefetch module. After receiving the asynchronous prefetch task execution request, the asynchronous prefetch module executes the first asynchronous prefetch task after the application is started, so that after the user starts the application and before sliding the mobile phone screen, the ViewHolder is pre-acquired and cached in the Recycler. Then, when the user slides the mobile phone screen, the ViewHolder can be obtained in the Recycler's cache.
[0222] S204 . After receiving the instruction sent by the asynchronous prefetch module to start executing the asynchronous prefetch task, the application interface module sets the asynchronous prefetch task flag to a corresponding identifier in task execution.
[0223] The instruction to start executing the asynchronous prefetch task may be an instruction sent by the asynchronous prefetch module when the asynchronous prefetch task starts to be executed. The asynchronous prefetch task flag may be used to identify whether there is an asynchronous prefetch task being executed.
[0224] Exemplarily, the corresponding flag in the task execution may be 1, that is, when the asynchronous prefetch task flag is 1, it indicates that there is an asynchronous prefetch task being executed.
[0225] When the asynchronous prefetch task starts to execute, the asynchronous prefetch module sends an instruction to start executing the asynchronous prefetch task to the application interface. After receiving the instruction to start executing the asynchronous prefetch task, the application interface module sets the asynchronous prefetch task flag to the corresponding identifier in the task execution.
[0226] S205 . After receiving the instruction sent by the asynchronous prefetch module to end the execution of the asynchronous prefetch task, the application interface module sets the asynchronous prefetch task flag to an identification corresponding to the task execution completion.
[0227] The instruction for ending the execution of the asynchronous prefetch task may be an instruction sent by the asynchronous prefetch module when the asynchronous prefetch task ends execution.
[0228] Exemplarily, the flag corresponding to the task execution completion may be 0, that is, when the asynchronous prefetch task flag is 0, it indicates that there is no asynchronous prefetch task being executed.
[0229] When the asynchronous prefetch task is finished, the asynchronous prefetch module sends an instruction to finish the asynchronous prefetch task to the application interface. After receiving the instruction to finish the asynchronous prefetch task, the application interface module sets the asynchronous prefetch task flag to the corresponding mark of task execution completion.
[0230] The following is a detailed introduction to the specific process of the asynchronous prefetch thread executing the asynchronous prefetch task through a specific example. Figure 8 The figure is a schematic diagram of module interaction for exemplarily performing an asynchronous prefetch task.
[0231] Reference Figure 8 In the embodiment of the present application, the process of the electronic device executing the asynchronous prefetch task through the asynchronous prefetch thread specifically includes:
[0232] S301. The asynchronous prefetch module calculates a prefetch start position and a prefetch end position corresponding to a current asynchronous prefetch task, and determines a current prefetch position.
[0233] The current asynchronous prefetch task may be an asynchronous prefetch task that is currently being executed.
[0234] The prefetch start position, prefetch end position and current prefetch position are all view item positions, that is, the position where the data corresponding to the view item is located. When the current asynchronous prefetch task starts executing, the ViewHolder corresponding to the prefetch start position is obtained, and the current asynchronous prefetch task ends when the ViewHolder corresponding to the prefetch end position is obtained.
[0235] The view item position corresponding to the ViewHolder that the current asynchronous prefetch task is acquiring is the current prefetch position. That is, the current prefetch position may be a view item position between the prefetch start position and the prefetch end position. It is understandable that when the asynchronous prefetch task acquires the first ViewHolder, the current prefetch position may be the prefetch start position.
[0236] If the current asynchronous prefetch task is the first asynchronous prefetch task after the application is started, the asynchronous prefetch module can calculate the prefetch starting position and prefetch ending position of the current asynchronous prefetch task according to the view item position of the last view item displayed on the mobile phone screen and the prefetch upper limit threshold.
[0237] Specifically, assuming that the view item position corresponding to the last view item displayed on the mobile phone screen is a and the pre-fetch upper threshold is b, the pre-fetch start position is a+1 and the pre-fetch end position is a+b. For example, assuming that the view item position corresponding to the last view item displayed on the mobile phone screen is 5 and the pre-fetch upper threshold is 100, the pre-fetch start position is 6 and the pre-fetch end position is 105.
[0238] If the current asynchronous prefetch task is not the first asynchronous prefetch task after the application is started, the asynchronous prefetch module can calculate the prefetch starting position and prefetch ending position of the current asynchronous prefetch task based on the view item position of the last view item displayed on the mobile phone screen, the prefetch ending position of the previous asynchronous prefetch task, and the prefetch upper limit threshold.
[0239] It is understandable that if the current asynchronous prefetch task is not the first asynchronous prefetch task after the application is started, the current asynchronous prefetch task will be executed only after the user slides the phone screen. However, the prefetch start position and the prefetch end position will be different depending on the sliding direction when the user slides the phone screen.
[0240] Specifically, assume that the view item position corresponding to the last view item displayed on the mobile phone screen is a, the prefetch end position of the last prefetch task is c, and the prefetch upper threshold is b. When the user slides the mobile phone screen upward (or right), the prefetch start position is the maximum value of c+1 and a+1, and the prefetch end position is a+b. When the user slides the mobile phone screen downward (or left), the prefetch start position is ab, and the prefetch end position is the minimum value of c and a.
[0241] For example, suppose the view item position corresponding to the last view item displayed on the mobile phone screen is 150, the prefetch end position of the last prefetch task is 170, and the prefetch upper threshold is 100. When the user slides the mobile phone screen upward (or right), the prefetch start position is 171 and the prefetch end position is 250. When the user slides the mobile phone screen downward (or left), the prefetch start position is 50 and the prefetch end position is 150.
[0242] For another example, suppose the view item position corresponding to the last view item displayed on the mobile phone screen is 150, the prefetch end position of the last prefetch task is 120, and the prefetch upper threshold is 100. When the user slides the mobile phone screen upward (or right), the prefetch start position is 151 and the prefetch end position is 250. When the user slides the mobile phone screen downward (or left), the prefetch start position is 50 and the prefetch end position is 120.
[0243] S302: The asynchronous prefetch module sends the current prefetch position to the Adapter through the Recycler. The Adapter determines the current view type according to the current prefetch position and sends the current view type to the Recycler.
[0244] The current view type may be a view type of a view item corresponding to the current prefetch position.
[0245] The asynchronous prefetch module sends the current prefetch position to the Adapter through the Recycler. After receiving the current prefetch position, the Adapter determines the current view type according to the current prefetch position and sends the current view type to the Recycler.
[0246] S303, Recycler determines whether the number of ViewHolders of the current view type in the cache is greater than a preset number threshold; if so, execute S307; if not, execute S304.
[0247] The number of ViewHolders of the current view type in the cache, that is, the number of ViewHolders in the cache list corresponding to the current view type.
[0248] The preset quantity threshold may be a preset maximum number of ViewHolders stored in the cache list corresponding to each view type in the cache. For example, the preset quantity threshold may be 5, which means that a maximum of 5 ViewHolders can be stored in the cache list corresponding to each view type in the Recycler. Specifically, the preset quantity threshold may be set according to actual needs, and this application does not limit it.
[0249] After receiving the current view type, the Recycler can determine whether the number of ViewHolders of the current view type in the cache is greater than a preset number threshold, that is, determine whether there are enough ViewHolders of the current view type in the cache.
[0250] If the number of ViewHolders of the current view type in the cache is greater than the preset threshold, it means that there are enough ViewHolders of the current view type in the Recycler cache, and the Recycler does not need to call the Adapter to create a ViewHolder of the current view type.
[0251] If the number of ViewHolders of the current view type in the cache is less than the preset threshold, it means that there are not enough ViewHolders of the current view type in the Recycler cache, and the Recycler needs to call the Adapter to create a ViewHolder of the current view type.
[0252] S304, Recycler obtains the lock corresponding to the current pre-fetch position and sends a pre-fetch ViewHolder creation request to the Adapter.
[0253] The lock corresponding to the current prefetch position may be a lock for the data corresponding to the current prefetch position. Since both the asynchronous prefetch thread and the main thread of the application program will operate on the data corresponding to the current prefetch position, the data corresponding to the current prefetch position is locked for protection to avoid concurrent access.
[0254] When the asynchronous prefetch thread and the main thread of the application program simultaneously operate on the data corresponding to the current prefetch position, the thread holding the lock can first operate on the data corresponding to the current prefetch position, and the thread not holding the lock needs to wait for the thread holding the lock to release the lock before it can operate on the data corresponding to the current prefetch position.
[0255] The pre-fetch ViewHolder creation request may be a request to create a pre-fetch ViewHolder. Specifically, the pre-fetch ViewHolder may be a ViewHolder pre-acquired when executing an asynchronous pre-fetch task. It is understandable that the pre-fetch ViewHolder is a ViewHolder object in the ViewHolder of the current view type.
[0256] If the number of ViewHolders of the current view type in the cache is less than the preset number threshold, the Recycler acquires the lock corresponding to the current prefetch position and sends a prefetch ViewHolder creation request to the Adapter.
[0257] S305 , after receiving the pre-fetch ViewHolder creation request, the Adapter creates a pre-fetch ViewHolder and sends the pre-fetch ViewHolder to the Recycler.
[0258] S306 . The Recycler releases the lock corresponding to the current pre-fetched position, and stores the pre-fetched ViewHolder into the cache list corresponding to the current view type.
[0259] After caching the pre-fetched ViewHolder in the cache list, the Recycler may send an instruction to the asynchronous pre-fetch module that the pre-fetched ViewHolder cache is completed.
[0260] S307 . After the asynchronous prefetching module completes prefetching the ViewHolder cache, it updates the current prefetching position.
[0261] After prefetching the ViewHolder cache is completed, the asynchronous prefetch module can update the current prefetch position to obtain the ViewHolder corresponding to the updated current prefetch position.
[0262] In the embodiment of the present application, the asynchronous prefetch module updates the current prefetch position by adding 1 to the current prefetch position, that is, updating the next position of the current prefetch position as the current prefetch position.
[0263] Exemplarily, assuming that the current prefetch position is 51, the updated current prefetch position is 52.
[0264] S308, the asynchronous prefetch module determines whether the current prefetch position exceeds the prefetch end position; if so, execute S309; if not, return to execute S302.
[0265] After updating the current prefetch position, the asynchronous prefetch module may determine whether the updated current prefetch position exceeds the prefetch end position.
[0266] If the updated current prefetch position does not exceed the prefetch end position, the asynchronous prefetch module can be returned to execute the operation of sending the current prefetch position to the Adapter through the Recycler.
[0267] If the updated current prefetch position exceeds the prefetch end position, the asynchronous prefetch module may end the current asynchronous prefetch task.
[0268] S309: The asynchronous prefetch module ends the current asynchronous prefetch task.
[0269] When the updated current prefetch position exceeds the prefetch end position, the asynchronous prefetch module may end the current asynchronous prefetch task.
[0270] The following uses a specific example to introduce in detail the specific process of "when the user slides the phone screen, the application responds to the user operation to display the page". Figure 9-10 The following is a schematic diagram of the interaction between modules.
[0271] Reference Fig. 9 The process of the page display method provided in the embodiment of the present application specifically includes:
[0272] S401: In response to a user sliding screen operation, the application sends a user sliding event to an application interface module.
[0273] S402: The application interface module calculates a sliding distance according to a user sliding event, and sends the sliding distance to the LayoutManager.
[0274] S403. LayoutManager determines the position of the new view item corresponding to the new view item according to the sliding distance, and generates a new view item acquisition request according to the position of the new view item.
[0275] S404. LayoutManager sends the generated new view item acquisition request to Recycler. After receiving the new view item acquisition request, Recycler sends the new view item position in the new view item acquisition request to the adapter.
[0276] S405. The Adapter determines the target view type according to the position of the newly added view item, and sends the target view type to the Recycler.
[0277] The specific processing flow of steps S401-S405 is the same as that of steps S101-S105, and will not be repeated here.
[0278] S406. After receiving the target view type sent by the Adapter, the Recycler obtains the target ViewHolder of the target view type.
[0279] Reference Fig.10 , the process of Recycler obtaining the target ViewHolder of the target view type includes:
[0280] S4061. Recycler determines whether there is a target ViewHolder of the target view type in the cache; if so, execute S4066; if not, execute S4062.
[0281] If the Recycler determines that a target ViewHolder of the target view type exists in the cache, the Recycler can directly obtain the target ViewHolder in the cache.
[0282] If the Recycler determines that the target ViewHolder of the target view type does not exist in the cache, the Recycler can obtain the lock corresponding to the position of the newly added view item.
[0283] S4062. Recycler obtains the lock corresponding to the position of the newly added view item.
[0284] When the Recycler determines that the target ViewHolder of the target view type does not exist in the cache, the Recycler can obtain the lock corresponding to the position of the newly added view item.
[0285] When the Recycler fails to obtain the lock corresponding to the position of the newly added view item, it means that other threads (such as asynchronous prefetch threads) are holding the lock. In this case, the Recycler can enter a waiting state until the lock corresponding to the position of the newly added view item is released, and then successfully obtain the lock corresponding to the position of the newly added view item.
[0286] S4063. Recycler obtains the target ViewHolder from the cache.
[0287] After the Recycler obtains the lock corresponding to the position of the newly added view item, it tries again to obtain the target ViewHolder in the cache to determine whether the target ViewHolder is cached in the Recycler during the process of the Recycler obtaining the lock corresponding to the position of the newly added view item.
[0288] It is understandable that if the Recycler fails to obtain the lock corresponding to the newly added view item position, and another thread is holding the lock, it means that the thread holding the lock is creating the ViewHolder corresponding to the newly added view item position. The thread holding the lock releases the lock after creating the ViewHolder, and the Recycler can successfully obtain the lock corresponding to the newly added view item position. Therefore, after the Recycler obtains the lock corresponding to the newly added view item position, it can try to obtain the target ViewHolder in the cache again.
[0289] If the Recycler successfully obtains the target ViewHolder in the cache, it means that the target ViewHolder is cached in the Recycler during the process of the Recycler obtaining the lock corresponding to the position of the newly added view item. Then, the target ViewHolder of the target view type can be directly obtained from the cache.
[0290] If the Recycler fails to obtain the target ViewHolder in the cache, it means that no target ViewHolder is cached in the Recycler during the process of the Recycler obtaining the lock corresponding to the position of the newly added view item. In this case, it is necessary to request the Adapter to create a target ViewHolder of the target view type.
[0291] S4064: If the Recycler fails to obtain the target ViewHolder in the cache, the Recycler sends a target ViewHolder creation request to the Adapter, and creates the target ViewHolder through the Adapter. After the Adapter creates the target ViewHolder, it sends the target ViewHolder to the Recycler.
[0292] When the Recycler fails to obtain the target ViewHolder in the cache, the Recycler can send a target ViewHolder creation request to the Adapter so that the Adapter creates the target ViewHolder according to the target ViewHolder creation request.
[0293] S4065. Recycler releases the lock corresponding to the position of the newly added view item.
[0294] After the Recycler successfully obtains the target ViewHolder in the cache, it can release the lock corresponding to the position of the newly added view item. In addition, after the Recycler receives the target ViewHolder sent by the Adapter, it can also release the lock corresponding to the position of the newly added view item.
[0295] S4066. Recycler obtains the target ViewHolder in the cache.
[0296] When the Recycler determines that a target ViewHolder of the target view type exists in the cache, the Recycler can directly obtain the target ViewHolder in the cache.
[0297] S407. After obtaining the target ViewHolder, Recycler determines whether the target ViewHolder has been bound to data; if not, execute S408; if so, execute S410.
[0298] S408, Recycler sends a target ViewHolder binding data request to Adapter. After receiving the target ViewHolder binding data request sent by Recycler, Adapter obtains the target data from the database.
[0299] S409, the Adapter performs data binding on the target data obtained from the database and the view items in the target ViewHolder, and sends the data-bound target ViewHolder to the Recycler.
[0300] S410. Recycler sends the target ViewHolder to LayoutManager. LayoutManager performs layout rendering on the newly added view items according to the target ViewHolder, and sends the newly added view items and the positions of the newly added view items after layout rendering to the application interface module.
[0301] S411, the application interface module determines whether there is an asynchronous prefetch task being executed; if so, execute S417; if not, execute S412.
[0302] After receiving the newly added view item sent by LayoutManager, the application interface module determines whether there is an asynchronous prefetch task in execution.
[0303] In the embodiment of the present application, the application interface module can determine whether there is an asynchronous prefetch task in execution according to the asynchronous prefetch task flag.
[0304] Exemplarily, the flag corresponding to the task execution can be 1, that is, when the asynchronous prefetch task flag is 1, RecyclerView can determine that there is an asynchronous prefetch task in execution. Correspondingly, the flag corresponding to the task execution completion can be 0, that is, when the asynchronous prefetch task flag is 0, RecyclerView can determine that there is no asynchronous prefetch task in execution.
[0305] If the application interface module determines that there is an asynchronous prefetch task in execution, the application interface module will not execute the asynchronous prefetch task again after receiving the newly added view item sent by LayoutManager.
[0306] If the application interface module determines that there is no asynchronous prefetch task in execution, the application interface module may execute an asynchronous prefetch task after receiving the newly added view item sent by LayoutManager.
[0307] S412: The application interface module determines a position difference between the position of the newly added view item and the prefetching end position of the last asynchronous prefetching task.
[0308] When the application interface module determines that there is no asynchronous prefetch task being executed, the application interface module determines the position difference between the position of the newly added view item and the prefetch end position of the last asynchronous prefetch task.
[0309] For example, assuming that the position of the newly added view item is 50 and the prefetch end position of the last asynchronous prefetch task is 60, the position difference is 10.
[0310] S413, the application interface module determines whether the position difference is less than the pre-fetch lower limit threshold; if so, execute S414; if not, execute S417.
[0311] After determining the position difference between the position of the newly added view item and the prefetching end position of the last asynchronous prefetching task, the application interface module may determine whether the position difference is less than the prefetching lower limit threshold.
[0312] If the application interface module determines that the position difference is less than the prefetch lower limit threshold, the application interface module can send an asynchronous prefetch task execution request to the asynchronous prefetch module. For example, assuming that the position difference is 10 and the prefetch lower limit threshold is 50, the application interface module can send an asynchronous prefetch task execution request to the asynchronous prefetch module.
[0313] It is understandable that if the position difference is less than the pre-fetch lower limit threshold, it means that the number of ViewHolders in the Recycler cache is small. At this time, it is necessary to execute an asynchronous pre-fetch task to obtain the ViewHolder and cache the ViewHolder in the Recycler.
[0314] If the application interface module determines that the position difference is greater than the prefetch lower limit threshold, the application interface module may not perform the asynchronous prefetch task. For example, assuming that the position difference is 80 and the prefetch lower limit threshold is 50, the application interface module does not perform the asynchronous prefetch task.
[0315] It is understandable that if the position difference is greater than the pre-fetch lower threshold, it means that there are a large number of ViewHolders in the Recycler cache, and there is no need to obtain the ViewHolder.
[0316] S414: The application interface module sends an asynchronous prefetch task execution request to the asynchronous prefetch module. After receiving the asynchronous prefetch task execution request, the asynchronous prefetch module executes the asynchronous prefetch task.
[0317] When the application interface module determines that the position difference is less than the prefetch lower limit threshold, the application interface module sends an asynchronous prefetch task execution request to the asynchronous prefetch module. After receiving the asynchronous prefetch task execution request, the asynchronous prefetch module executes the asynchronous prefetch task through the asynchronous prefetch thread.
[0318] S415 . After receiving the instruction sent by the asynchronous prefetch module to start executing the asynchronous prefetch task, the application interface module sets the asynchronous prefetch task flag to a corresponding identifier in task execution.
[0319] When the asynchronous prefetch module starts to execute the asynchronous prefetch task, it can send an instruction to the application interface module to start executing the asynchronous prefetch task. When the application interface module receives the instruction, it sets the asynchronous prefetch task flag to the corresponding mark in the task execution.
[0320] S416. After receiving the instruction sent by the asynchronous prefetch module to end the execution of the asynchronous prefetch task, the application interface module sets the asynchronous prefetch task flag to an identification corresponding to the task execution completion.
[0321] When the asynchronous prefetch module finishes executing the asynchronous prefetch task, it can send an instruction to the application interface module to finish executing the asynchronous prefetch task. When receiving the instruction, the application interface module sets the asynchronous prefetch task flag to the mark corresponding to the task execution completion.
[0322] S417. The application interface module sends the newly added view item to the application, and the newly added view item is displayed on the mobile phone screen through the application.
[0323] When the application interface module determines that there is an asynchronous prefetch task being executed, the application interface module may send the newly added view item to the application.
[0324] Alternatively, when the application interface module determines that the position difference is greater than the pre-fetch lower limit threshold, the application interface module may also send the newly added view item to the application.
[0325] Furthermore, when the application module sets the asynchronous pre-fetch task flag to an identifier corresponding to task execution completion, the application interface module may also send the newly added view item to the application.
[0326] This embodiment also provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the page display method in the above-mentioned embodiment.
[0327] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the page display method in the above-mentioned embodiment.
[0328] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer execution instructions, and when the device is running, the processor can execute the computer execution instructions stored in the memory so that the chip executes the page display method in the above-mentioned method embodiments.
[0329] Among them, the electronic device (such as a mobile phone, etc.), computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0330] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0331] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0332] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A page display method, characterized in that: Applied in an electronic device, the method comprises: In response to a first operation on a target application, the first thread obtains at least one view layout, where the at least one view layout includes a target view layout; The first thread caches the at least one view layout into a corresponding cache list according to the view type; wherein the target view layout is cached into the target cache list; In response to a second operation on the target application, the second thread determines that a view item currently to be displayed is a target view item, and the target view item corresponds to the target view layout; The second thread obtains the target view layout in the target cache list, and generates an application program interface including the target view item according to the target view layout; Displaying the application program interface; The first thread and the second thread are asynchronously processed threads, the second thread is the main thread of the target application; and the second operation is later than the first operation.
2. The method according to claim 1, characterized in that The electronic device also includes a recycling pool; The first thread obtains at least one view layout, including: The first thread determines first position data and second position data, and sequentially uses each position data between the first position data and the second position data as current position data; The first thread obtains the view layout corresponding to the current position data through the recycling pool according to the current view type corresponding to the current position data.
3. The method according to claim 2, characterized in that The first thread determines the first position data and the second position data, including: The first thread obtains a first threshold, and determines position data corresponding to the first view item and position data corresponding to the second view item; When the first operation is a first type of operation, the first thread determines the first position data and the second position data according to the position data of the first view item and the first threshold; When the first operation is a second type of operation, the first thread determines the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item, and the first threshold; The first view item is a view item with the largest position data among all view items displayed on the screen; the second view item is a view item with the largest position data among all view items stored in the cache.
4. The method according to claim 3, characterized in that: The determining the first position data and the second position data according to the position data of the first view item and the first threshold comprises: Determine the sum of the position data of the first view item and a fixed value as the first position data; The sum of the position data of the first view item and the first threshold is determined as the second position data.
5. The method according to claim 3, characterized in that: Before determining the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item and the first threshold, the method further includes: determining an operation direction of the first operation; When the operation direction of the first operation is the first direction, determining the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item, and the first threshold, includes: determining a maximum value between the position data corresponding to the first view item and the position data corresponding to the second view item, and determining a sum of the maximum value and a fixed value as the first position data; The sum of the position data of the first view item and the first threshold is determined as the second position data.
6. The method according to claim 5, characterized in that When the operation direction of the first operation is the second direction, determining the first position data and the second position data according to the position data corresponding to the first view item, the position data corresponding to the second view item, and the first threshold, includes: determining a difference between the position data corresponding to the first view item and the first threshold as the first position data; The minimum value between the position data corresponding to the first view item and the position data corresponding to the second view item is determined as the second position data.
7. The method according to claim 2, characterized in that The electronic device further comprises an adapter; The acquiring, according to the current view type corresponding to the current position data, the view layout corresponding to the current position data includes: Determine the current number of view layouts in the cache list corresponding to the current view type; When the current number is less than a second threshold, a view layout corresponding to the current position data is created by the adapter.
8. The method according to claim 7, characterized in that Before creating the view layout corresponding to the current position data through the adapter, the method further includes: Obtaining a lock corresponding to the current position data; After creating the view layout corresponding to the current position data through the adapter, the method further includes: The lock corresponding to the current position data is released.
9. The method according to claim 1, characterized in that: In response to a first operation on a target application, the first thread obtains at least one view layout, including: In response to a first operation on a target application, the second thread sends a view layout acquisition request to the first thread; The first thread obtains at least one view layout according to the view layout acquisition request.
10. The method according to claim 9, characterized in that In response to a first operation of the target application, the second thread sending a view layout acquisition request to the first thread includes: In case the first operation is a second type of operation, the second thread determines a state of the first thread; The second thread, when the state of the first thread is the second state, determines a data difference between the position data corresponding to the second view item and the position data corresponding to the third view item; The second thread, when the data difference is less than a third threshold, sends a view layout acquisition request to the first thread; The second view item is a view item with the largest position data among the view items stored in the cache; the third view item is the first view item to be displayed in response to the first operation.
11. The method according to claim 9, characterized in that In response to a first operation of the target application, the second thread sending a view layout acquisition request to the first thread includes: When the first operation is a first type of operation, the second thread creates the first thread; wherein the first thread and the second thread have the same priority; When the first thread is successfully created, the second thread sends a view layout acquisition request to the first thread.
12. The method according to claim 9, characterized in that The method further comprises: After receiving the view layout acquisition request, the first thread sends a first instruction to the second thread; The second thread updates the state of the first thread to a first state according to the first instruction; After the first thread caches all acquired view layouts into a corresponding cache list, the first thread sends a second instruction to the second thread; The second thread updates the state of the first thread to a second state according to the second instruction.
13. The method according to claim 1, characterized in that After the second thread obtains the target view layout in the target cache list, the method further includes: In the case where the target view layout acquisition fails, the second thread acquires a lock of the position data corresponding to the target view item through a recycling pool; The second thread creates the target view layout through the adapter, and releases the lock of the position data corresponding to the target view item through the recycling pool.
14. The method according to claim 13, characterized in that After the second thread obtains the lock of the position data corresponding to the target view item through the recycling pool, the method further includes: The second thread obtains the target view layout from the target cache list; The second thread creates the target view layout through the adapter, and releases the lock of the position data corresponding to the target view item through the recycling pool, including: In the case where the target view layout fails to be acquired, the second thread creates the target view layout through an adapter, and releases the lock of the position data corresponding to the target view item through the recycling pool.
15. An electronic device, characterized in that: include: one or more processors; Memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device executes the page display method as described in any one of claims 1-14.
16. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program is executed on an electronic device, the electronic device executes the page display method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Video frame decoding display method and device
CN108347645A
Method for optimizing use performance of RecyclerView control
CN112364276A
Network data processing method and device and storage medium
CN112395076A
Memory missing page exception processing method and device, equipment and storage medium
CN114253458A
Webpage Display System Leveraging OSGI
US20140344664A1