View interface updating method and vehicle
Patent Information
- Application Number
- CN202610918627.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-24
- Publication Date
- 2026-08-18
AI Technical Summary
[0003]现有技术中的安卓多媒体应用在进行界面切换时,一般采用适配器结合观察者模式实现,采用数据差异比对、消息队列分发及全局通知刷新机制;该方式中数据更新时需重组数据集、遍历视图、比对差异、分发变更任务,然后执行全局更新,整个过程严重依赖队列调度,因此在界面高频变化场景下会存在延迟明显、易卡顿的现象,而且因为需要触发整体数据重组与视图刷新,频繁绘制也会导致系统性能下降、易出现状态错乱的问题
本申请实施例提供的一种视图界面更新方法,通过条目管理器根据自身的绑定位置直接订阅对应的业务数据流,当业务数据发生更新时,业务数据流会将最新状态值直接推送至条目管理器,进而条目管理器能够直接将该最新状态值更新至界面列表中所关联条目的目标控件,进而本申请实施例中,条目管理器只需要关注与自身绑定位置对应的数据更新,并且直接点对点地获取更新内容,然后控制对应条目的控件进行更新,该方法相对于现有技术中界面更新时需要重组数据、遍历试图、分发变更任务等的执行流程相比,能够更加灵活和高效地按照条目进行独立更新,无需频繁调用列表适配器,尤其适用于在高频刷新的场景,具有保证系统性能不下降和界面更新准确高效的积极效果。
Smart Images

Figure CN122593893A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent cockpit media application technology, and in particular to a view interface update method and a vehicle. Background Technology
[0002] With the development of autonomous driving systems, people's requirements for intelligent cockpits are also gradually increasing. An intelligent cockpit includes the driver's cabin and central control system in the car, mainly consisting of a central control screen, instrument panel, vehicle infotainment system, and various multimedia applications.
[0003] In existing Android multimedia applications, when switching interfaces, an adapter combined with the observer pattern is generally used, employing data difference comparison, message queue distribution, and global notification refresh mechanisms. In this approach, data updates require reorganizing the dataset, traversing the view, comparing differences, distributing change tasks, and then performing a global update. The entire process heavily relies on queue scheduling, which can lead to significant delays and stuttering in scenarios with frequent interface changes. Furthermore, because it requires triggering overall data reorganization and view refresh, frequent drawing can also cause system performance degradation and potential state inconsistencies.
[0004] Therefore, existing technologies cannot meet the actual needs of low latency and low performance loss in smart cockpit multimedia applications that require high-frequency playback and rapid, accurate view updates. Summary of the Invention
[0005] In order to solve the above-mentioned technical problems, or at least partially solve the above-mentioned technical problems, this application provides a data update output method, apparatus, electronic device and storage medium.
[0006] Firstly, this application provides a method for updating an interface, including: The item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates based on its own bound position; wherein, the item manager is a management component for a single item in the interface list; When business data changes, the item manager receives the latest status value of the business data pushed by the business data stream; After receiving the latest status value, the item manager verifies the validity of the latest status value; If the verification passes, the item manager updates the target control of the corresponding item in the current list in the interface according to the latest status value.
[0007] In one possible implementation of this application, the method further includes: The item manager obtains the identifier of the page lifecycle manager from the list adapter of the page and binds the subscription relationship with the business data flow to the lifecycle manager; then, when the interface lifecycle ends, the lifecycle manager automatically triggers the termination of the subscription relationship. In one possible implementation of this application, after receiving the latest status value, the entry manager verifies the validity of the latest status value, including: The item manager determines whether the list position corresponding to the latest status value matches its own bound position, and whether the current item is in a valid display state; If the list position corresponding to the latest status value matches its own bound position, and the current item is in a valid display state, then the verification passes; otherwise, the verification fails, and the item manager does not perform any operation.
[0008] In one possible implementation of this application, if the verification passes, the item manager updates the target control for the corresponding item in the current list item in the interface, including: If the verification passes, the target control of the entry associated with the latest status value is determined, and the target control is a text control or an image control within the entry; The item manager updates the content of the target control according to the latest status value.
[0009] In one possible implementation of this application, the item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates, including: During the list item binding phase, the item manager searches for the business data stream corresponding to the binding position from the data source based on its own binding position in the list; Establish a point-to-point subscription relationship between the item manager and the business data stream, so that data changes are directly pushed to the item manager without going through the list scheduler.
[0010] In one possible implementation of this application, the method further includes: When the item manager is reused to a new list position, the current state data stream subscription is canceled, and the corresponding state data stream is resubscribed according to the new binding position.
[0011] In one possible implementation of this application, the status data stream supports configuring the number of retained states, and the method further includes: When the item manager subscribes to the status data stream, it obtains the status value of the most recent one or more data stream pushes as the initial display content.
[0012] In one possible implementation of this application, the method further includes: The item manager maintains the active view state of the current list item; when the item manager receives the latest state value, it compares the latest state value with the active view state; if they match, the item manager skips the update and does not perform the drawing operation; if they do not match, the item manager performs the update operation.
[0013] In one possible implementation of this application, the method further includes: When an entry's business status is increased, the entry manager adds a corresponding status data stream subscription, thus eliminating the need to modify the list scheduler's configuration logic and binding relationships.
[0014] Secondly, this application provides a vehicle, including a vehicle body and electronic devices, wherein the electronic devices include a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; When a processor executes a program stored in memory, it implements the interface update method according to any one of claims 1 to 9. Thirdly, this application provides a computer-readable storage medium storing a program for a view interface update method, wherein when the program for the view interface update method is executed by a processor, it implements the steps of the view interface update method described in any of the first aspects.
[0015] The beneficial effects of this invention are: This application provides a view interface update method. An item manager directly subscribes to the corresponding business data stream based on its bound position. When the business data is updated, the business data stream pushes the latest status value directly to the item manager. The item manager can then directly update the target control of the associated item in the interface list with this latest status value. Therefore, in this embodiment, the item manager only needs to focus on data updates corresponding to its bound position and directly obtain the updated content point-to-point, then control the corresponding item's control to update. Compared to the existing technology's execution flow, which requires data reorganization, view traversal, and distribution of change tasks during interface updates, this method allows for more flexible and efficient independent updates by item, without frequent calls to the list adapter. It is particularly suitable for high-frequency refresh scenarios, ensuring that system performance does not degrade and that interface updates are accurate and efficient. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart illustrating a view interface update method provided in a specific embodiment of this application; Figure 2 A schematic diagram of a view interface provided for a specific embodiment of this application; Figure 3 This is a flowchart illustrating the verification of the validity of the latest status value according to a specific embodiment of this application. Figure 4 A flowchart illustrating a view interface update method provided in another specific embodiment of this application; Figure 5 A schematic diagram of a subscription service data flow provided for a specific embodiment of this application; Figure 6 A flowchart illustrating a view interface update method provided in another specific embodiment of this application; Figure 7 This is a structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] In existing technologies, the view interface update and switching process of vehicle infotainment systems is generally implemented based on the adapter difference comparison (DiffUtil) payload update mechanism. This method has the following core drawbacks: 1. Poor sensitivity to data changes After each data change, the entire dataset needs to be reorganized to match and find the corresponding changed views, and then attempt to distribute the local change task. The whole process relies heavily on message queue scheduling and cannot respond to individual data changes in real time.
[0021] 2. The view positioning logic is complex. View retrieval relies on the previous state register; without a state register, anonymous views cannot be associated, and the visible area must be traversed one by one for matching. Meanwhile, the distributed payload needs to be precisely located at the differentiated fields, making the location logic cumbersome and error-prone.
[0022] 3. Delayed updates When data changes frequently, even if only one view is associated with that data change, the following steps must be executed sequentially: organizing data, comparing differences, finding the target view, distributing payload tasks, processing message queues, receiving difference change notifications, and executing view updates. This lengthy process chain causes view updates to lag significantly.
[0023] Based on this, this application provides a view interface update method and a vehicle; the following detailed description of the application solution is provided through specific embodiments.
[0024] Figure 1 A flowchart illustrating a view interface update method according to a specific embodiment of this application; see reference Figure 1 As shown, a view interface update method in this application embodiment includes the following steps S10-S40: S10. The item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates based on its own bound position; wherein, the item manager is a management component for a single item in the interface list.
[0025] Figure 2 A schematic diagram of a view interface provided in a specific embodiment of this application; see reference Figure 2 As shown, in smart cockpit applications, the terminal view interface typically contains a list. This list displays multiple items, with each item corresponding to a row of content in the list. For example, in a car music playback interface, the song list contains multiple songs, each occupying one item in the list. Each item displays the song name, artist information, playback status, etc. The item manager is the component that manages a single item, responsible for holding the relationships between the controls within that item and updating the control content according to data changes.
[0026] Furthermore, the main interface refers to the interface that hosts the list. In Android, the main interface can be an Activity or a Fragment, where the aforementioned item manager ViewHolder can also be called a view holder. The list refers to the area within the main interface used to display multiple rows of similar content, corresponding to RecyclerView in Android. The list scheduler is the component responsible for creating and managing the item manager, corresponding to Adapter in Android. The data source refers to the source of business data, corresponding to ViewModel in Android, which contains multiple business data streams, each corresponding to a channel for pushing changes in business state.
[0027] The binding position of an item manager refers to the index of the item currently managed by that item manager within the list. For example, if there are 50 songs in the list, the binding position of the first item manager is 0 (corresponding to the first song), the binding position of the second item manager is 1 (corresponding to the second song), and so on. Based on its binding position, the item manager finds the corresponding business data stream from the data source and actively subscribes to it. The subscription operation means that the item manager registers with the business data stream, "I am following changes in this data stream," and subsequently, when the data in that data stream changes, the latest value will be automatically pushed to all subscribers.
[0028] Taking an in-car music player as an example, the data source contains multiple business data streams. For instance, the "playback status data stream" is used to push the play / pause status of each song. When the item manager's binding position is 3 (corresponding to the 4th song), the item manager subscribes to the playback status data stream corresponding to the 4th song. Subsequently, when the playback status of the 4th song changes, the item manager will directly receive the latest status value.
[0029] This embodiment differs from existing solutions in that, in existing solutions, the item manager does not actively subscribe to the data stream but passively waits for notifications from the list scheduler. After data changes, it needs to go through the following steps before reaching the item manager: (1) the list scheduler receives the data change notification; (2) the list scheduler organizes the new data and compares it with the old data to calculate the difference; (3) the list scheduler determines the position of the item that needs to be updated based on the difference; (4) the list scheduler encapsulates the difference information into a payload and distributes it through a message queue; (5) the item manager can only update after receiving the notification from the message queue. The entire chain involves multiple steps such as data reorganization, difference comparison, view retrieval, and message queuing. In this process, the item manager is always in a passive state, and the timeliness of data updates heavily depends on the processing efficiency of the list scheduler and the queuing status of the message queue. When data changes frequently, these steps become obvious performance bottlenecks. In the embodiment of this application, the item manager actively subscribes to the data stream, and data changes are directly pushed to the item manager without going through the list scheduler, realizing point-to-point direct transmission of data to the view.
[0030] S20. When business data changes, the item manager receives the latest status value of the business data pushed by the business data stream.
[0031] In this embodiment, when the business data stream changes, it sends the latest status value to all subscribers who have subscribed to the data stream. The latest status value refers to the current value after the business data changes. For example, its data type can be integer, string, boolean, etc. For instance, the status values pushed by the playback status data stream may include string values such as "playing", "paused", and "stopped".
[0032] Because the item manager subscribes to the corresponding business data stream, it receives the latest status value immediately when the business data stream emits it. This receiving process is initiated by the data stream; the item manager does not need to poll or actively query.
[0033] S30. After receiving the latest status value, the item manager verifies the validity of the latest status value.
[0034] Because the business data stream is broadcast, meaning the latest status value emitted by the data stream is received by all item managers subscribed to that stream, each item manager needs to verify the validity of the received value. This verification aims to prevent item managers from responding to data changes that do not belong to them, thus preventing erroneous view updates and resource waste.
[0035] Figure 3A flowchart illustrating the verification of the validity of the latest status value is provided in a specific embodiment of this application; see reference. Figure 3 As shown, in this embodiment, after the item manager receives the latest status value, it verifies the validity of the latest status value in step S30, specifically including the following steps S301-S302: S301. The item manager determines whether the list position corresponding to the latest status value matches its own bound position, and whether the current item is in a valid display state.
[0036] S302. If the list position corresponding to the latest status value matches its own bound position, and the current item is in a valid display state, then the verification passes; otherwise, the verification fails, and the item manager does not perform any operation.
[0037] Therefore, in this embodiment, after receiving the latest status value, the item manager verifies the validity of the latest status value, which involves judging two dimensions: First dimension: Location matching verification The latest status value emitted by the business data stream carries the corresponding list position information, indicating which position in the list the status value belongs to. The item manager compares this list position with its own bound position to determine if they match.
[0038] Because the business data stream is broadcast, all item managers that have subscribed to the stream will receive the latest status value, but not every item manager needs to respond to it. Only when the list position corresponding to the latest status value matches the bound position of the item manager does it indicate that the data change belongs to an item managed by the current item manager, and only then does the item manager need to process it.
[0039] For example, a playback status data stream emits "the playback status at position 5 has changed to 'playing'", and a total of 8 item managers in the list subscribe to this data stream. Among them, the item manager bound to position 5 checks for a position match and passes the verification; the item managers bound to positions 0, 1, 2, 3, 4, 6, and 7 check for a position mismatch and fail the verification, and are directly ignored.
[0040] Second dimension: Effective display status verification The item manager also needs to determine whether the current item is in a valid display state, that is, whether the current item is still within the screen's visible area and has not been reclaimed. During list scrolling, some items may slide out of the screen's visible area. Although the corresponding item manager still maintains the subscription relationship, the items it manages are no longer visible. Performing a view update on invisible items at this time, while not causing a visual error, would waste computing resources.
[0041] The item manager will only respond to the latest status value and update the target control when both of the above-mentioned validations pass—that is, the list position corresponding to the latest status value matches the bound position of the item manager, and the current item is in a valid display state. If either validation fails, the item manager will not perform any operation to avoid erroneous updates and wasted resources.
[0042] Taking a car music player as an example, a user is browsing a song list, with songs 10-17 displayed on the screen. At this moment, the playback status data stream emits a message indicating that the playback status at position 2 has changed to "paused". Although the item manager bound to position 2 receives this value, the item it manages (song 3) has already slid out of the visible screen area and is not in a valid display state. Therefore, the verification fails, and the item manager does not perform any operation, avoiding invalid updates to invisible items.
[0043] Furthermore, this embodiment uses location matching verification to ensure that each item manager only responds to data changes belonging to the items it manages, avoiding cross-item erroneous updates caused by broadcast pushes. By effectively verifying display status, view updates for invisible items are skipped, avoiding unnecessary rendering overhead for user-invisible areas and saving computing resources. This two-way verification mechanism ensures that only item managers with matching locations and valid status perform updates, avoiding data and view inconsistencies caused by item reuse.
[0044] S40. If the verification passes, the item manager updates the target control of the corresponding item in the current list in the interface according to the latest status value.
[0045] In this embodiment, the target control refers to the control within an entry that is associated with the latest status value, such as a text control (displaying the song name), an image control (displaying a playback status icon, a favorite icon), etc. After determining that the latest status value is valid, the entry manager finds the associated target control based on that value and updates the content of the target control.
[0046] The item manager only updates the target controls, without refreshing the entire item or calling any refresh methods of the list scheduler. In traditional solutions, even if the content of only one control changes, the list scheduler's `notifyItemChanged` method needs to be used to trigger a refresh of the entire item, causing unchanged controls within the item to be redrawn, resulting in unnecessary performance overhead. In this embodiment, the item manager directly calls the update methods of the target controls, such as the `setText` method of text controls and the `setImageBitmap` method of image controls, achieving the smallest possible local update.
[0047] Taking a car music player as an example, when the playback status of the third song changes from "paused" to "playing," the item manager only changes the playback status icon from "paused" to "playing." "Updated to" Song titles and artist information are unaffected and do not trigger the playlist scheduler's refresh process.
[0048] Furthermore, this embodiment can effectively reduce view update latency and improve update efficiency, especially in scenarios with high-frequency data changes, such as rapid switching of media playback status. Moreover, by simplifying the data transmission chain, the traditional solution's data transmission chain is: data change - list scheduler - difference comparison - message queue - item manager - view update. This embodiment simplifies it to: data change - business data flow - item manager - view update, resulting in a shorter chain, clearer logic, and fewer points of failure.
[0049] Figure 4 This is a flowchart illustrating a view interface update method provided in another specific embodiment of this application; see reference. Figure 4 As shown, in this embodiment, after the item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source according to its own bound position in step S10 above to obtain data updates, the method further includes the following step S10': S10' The item manager obtains the identifier of the page lifecycle manager from the list adapter of the page and binds the subscription relationship with the business data flow to the lifecycle manager; then when the interface lifecycle ends, the lifecycle manager automatically triggers the termination of the subscription relationship. In the Android system, each UI (Activity or Fragment) holds a LifecycleOwner, which tracks the UI's state. The UI's lifecycle includes states such as creation, visibility, interactivity, inactivity, visibility, and destruction.
[0050] In this embodiment, the item manager needs to use the list scheduler as an intermediary to obtain the identifier of the interface's lifecycle manager from the list scheduler. The identifier of the lifecycle manager refers to the information that can locate the lifecycle manager. Through this identifier, the item manager can bind the subscription relationship with the corresponding lifecycle manager, so that the lifecycle of the subscription relationship is associated with the lifecycle of the interface. When the interface is destroyed, the subscription relationship automatically terminates.
[0051] For example, when the interface lifecycle ends, the lifecycle manager detects the event and automatically triggers the termination of all subscription relationships bound to it. After the subscription relationship is terminated, the business data stream no longer pushes data to the item manager, and the item manager no longer receives any data updates.
[0052] Therefore, in this embodiment, by binding the subscription relationship to the interface lifecycle, it ensures that the subscription relationship automatically terminates when the interface is destroyed, releasing all related references and eliminating the risk of memory leaks at the source, thus reducing the risk of crashes caused by memory overflows. Furthermore, the termination of the subscription relationship is automatically triggered by the lifecycle manager, eliminating the need for developers to manually write unsubscribe code when the interface is destroyed, reducing the risk of omissions and development costs. Taking a car music player as an example, when a user navigates from the playlist interface to the navigation interface, the playlist interface is destroyed. If the subscription relationship of the item manager is not bound to the lifecycle, the playback status data stream will continue to push data to the destroyed interface, causing a memory leak. In this embodiment, however, the lifecycle manager automatically triggers the termination of the subscription relationship when the interface is destroyed, the playback status data stream no longer pushes data to the destroyed interface, and the memory is reclaimed normally.
[0053] In a specific embodiment of this application, if the above step S40, "If the verification passes," the item manager updates the target control of the corresponding item in the current list item in the interface, specifically including the following steps C10-C20: Step C10: If the verification passes, determine the target control of the entry associated with the latest status value. The target control is a text control or an image control within the entry.
[0054] Step C20: The item manager updates the content of the target control according to the latest status value.
[0055] Specifically, an entry contains multiple controls, each responsible for displaying a type of information. For example, an entry in a music playlist contains the following controls: song title text control (displaying the song name), artist text control (displaying the artist name), playback status image control (displaying the play / pause icon), and favorites image control (displaying the favorites icon).
[0056] Once the item manager receives and validates the latest status value, it determines the target control associated with that value. The target control is a single control within the item, which can be a text control (such as a TextView) or an image control (such as an ImageView), and is the smallest updatable unit within the item.
[0057] The item manager updates the content of only the target controls based on the latest state value. The specific update method depends on the control type and the content of the latest state value. For example: If the target control is a text control and its latest state value is "Sunny", the item manager will call the text control's text setting method to update the displayed content to "Sunny". If the target control is an image control and its latest status value is "playing", the item manager calls the image control's image settings method to update the play icon to the icon of the play status; If the target control is an image control and its latest status value is "favorited", the item manager calls the image control's method to update the favorite icon to the "favorited" status.
[0058] In this embodiment, the item manager only updates the target control, without refreshing the entire item or calling the list scheduler's refresh methods (such as notifyItemChanged, notifyDataSetChanged, etc.). In traditional solutions, even if only the content of a single control changes, the list scheduler's refresh method triggers a redraw of the entire item, resulting in all controls within the item (including unchanged controls) being redrawn. This embodiment achieves minimal-granularity local updates by only updating the target control, avoiding invalid drawing of unchanged controls.
[0059] Therefore, the technical effects of this embodiment are as follows: (1) Minimal granularity update: Only the target control that has changed is updated, which realizes the minimum granularity update at the control level and avoids invalid redrawing of other unchanged controls in the entry.
[0060] (2) Reduced rendering overhead: Compared with the traditional method of refreshing the entire entry, the update range of this embodiment is smaller and the rendering overhead is lower, which is especially obvious in high-frequency update scenarios.
[0061] (3) Avoid screen flickering. In traditional solutions, redrawing the entire item may cause brief screen flickering, affecting the user experience. This embodiment only updates a single control, avoiding the screen flickering problem caused by overall redrawing.
[0062] (4) Without relying on the list scheduler to refresh, the item manager directly updates the target control without calling the refresh method of the list scheduler, thus avoiding the extra layout calculation and drawing process triggered by the refresh method.
[0063] Figure 5 A flowchart illustrating a subscription service data flow is provided for a specific embodiment of this application; see reference. Figure 5 As shown, in this embodiment, step S10 above, where the item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates, includes: S101. During the list item binding phase, the item manager searches for the business data stream corresponding to the binding position in the data source based on its own binding position in the list.
[0064] S102. Establish a point-to-point subscription relationship between the item manager and the business data stream, so that data changes are directly pushed to the item manager without going through the list scheduler.
[0065] For example, the list item binding phase described above refers to the phase where the list scheduler associates the item manager with data at a specific position in the list. In the Android system, this phase corresponds to the `onBindViewHolder` callback method of `RecyclerView.Adapter`. During this phase, the list scheduler assigns the item manager to a specific position in the list, and the item manager determines its own binding position accordingly, then retrieves the corresponding business data stream from the data source based on that binding position.
[0066] The data source contains multiple business data streams, each corresponding to a data change push channel for a specific position or business status in the list. The item manager locates its corresponding business data stream in the data source based on its bound position. For example, an item manager bound to position 3 will search the data source for the playback status data stream, favorites status data stream, etc., corresponding to position 3.
[0067] In this embodiment, establishing a point-to-point subscription relationship means that the item manager directly establishes a data transmission channel with the business data stream. This channel connects only the item manager and the business data stream, without going through the list scheduler. Data emitted by the data stream is directly pushed to the item manager through this channel, and the list scheduler does not participate in the data transmission and distribution process.
[0068] Taking a car music player as an example, when a user quickly switches songs, the playback status data stream transmits status values at a high frequency (e.g., multiple times per second). In traditional solutions, each status change requires the playlist scheduler to reorganize the data, compare differences, and distribute notifications. In high-frequency scenarios, the playlist scheduler's processing speed cannot keep up with the speed of data changes, resulting in a significant delay in view updates. In this embodiment, however, each status change is directly pushed to the item manager, achieving point-to-point direct transmission. The item manager responds instantly, and view updates are almost synchronized with data changes, significantly improving the user experience.
[0069] In one specific embodiment of this application, the method further includes the following step A10: Step A10: When the item manager is reused to a new list position, the current state data stream subscription is canceled, and the corresponding state data stream is resubscribed according to the new binding position.
[0070] For example, during list scrolling, the item manager corresponding to an item that scrolls out of the visible area of the screen is recycled and reused by the list scheduler. Reuse means that the recycled item manager is reassigned to a new position in the list to display the data content corresponding to that new position. This reuse mechanism avoids the frequent creation and destruction of item managers, improving the smoothness of list scrolling.
[0071] Because the binding position of the item manager changes after reuse. For example, if item manager A was originally bound to position 2 (corresponding to the 3rd song), and after the user scrolls down the list, item manager A is recycled and reused to binding position 10 (corresponding to the 11th song). At this time, the subscription relationship of item manager A still points to the business data stream corresponding to position 2. If the old subscription is not removed, the following problem will occur: First, the old subscription remains active, and when the business data flow at location 2 changes, item manager A will still receive push notifications. Although the verification mechanism will determine that the location does not match and ignore the value, receiving and processing push notifications itself consumes computing resources.
[0072] Second, if multiple item managers hold old subscriptions to the same location's business data stream, the number of subscribers to the same data stream will continue to grow, increasing the burden of data stream push.
[0073] Therefore, in this embodiment, when the item manager is reused, the current state data stream subscription is first canceled, the connection with the old location service data stream is disconnected, and then the corresponding service data stream is resubscribed according to the new bound location, establishing a point-to-point connection with the new location service data stream.
[0074] Taking a car music player as an example, if the screen height can display 8 songs simultaneously, and the playlist scheduler creates 10 item managers (8 for display + 2 for buffering), as the user scrolls down the list: (1) Item manager A was originally bound to position 0 (the first song), and subscribed to the playback status data stream and song title data stream at position 0; (2) The first song slides off the screen, and Item Manager A is recycled; (3) The list scheduler reuses item manager A to the binding position 8 (the 9th song); (4) Item manager A unsubscribes from the playback status data stream and song title data stream at position 0; (5) Item manager A resubscribes to the playback status data stream and song title data stream of position 8 based on the new binding position 8; (6) Item Manager A retrieves the current status of the 9th song from the newly subscribed data stream and updates the view display.
[0075] Through the above process, the item manager can correctly subscribe to the business data stream corresponding to the new location after reuse, ensuring that the view content and data status are consistent, while avoiding resource waste caused by old subscription residues.
[0076] Furthermore, in this embodiment, after the item manager is reused, the old subscription is canceled and a new subscription is created to ensure that the view content is consistent with the data status of the newly bound position. This avoids data corruption caused by the residue of the old subscription. Moreover, the correct management of subscription relationships enables the item manager to quickly obtain data from the new position and update the view when reused, ensuring a smooth experience of list scrolling.
[0077] In one specific embodiment of this application, the status data stream supports configuring the number of retained states, and the method further includes the following step B10: Step B10: When the item manager subscribes to the status data stream, it obtains the status value of the most recent one or more data stream pushes as the initial display content.
[0078] For example, the number of retained states refers to the ability of a business data stream to retain the most recent N emitted state values after they have been emitted, where N is a configurable number of retention values. When N=0, the business data stream does not retain any emitted state values; new subscribers can only receive state values emitted after subscription, and values emitted before subscription are unavailable. When N≥1, the business data stream retains the most recent N emitted state values, and new subscribers can obtain these retained historical state values immediately upon subscription.
[0079] When subscribing to a business data stream, if the number of retained entries N ≥ 1, the Item Manager can obtain the status values of the most recent N emitted entries at the moment of subscription. The Item Manager extracts the latest status value from these and uses it as the initial display content for the current entry, thereby initializing the display of the target control.
[0080] The technical problem to be solved in this embodiment is that when the item manager is first created and subscribed to the business data stream, the business data stream may have already emitted a status value (i.e., the business data is already in a certain state). If the business data stream does not retain historical status values, the item manager cannot obtain the current business data status after subscribing, and the target control can only display blank or default value until the business data changes again and a new status value is received and the display is updated.
[0081] Taking a car music player as an example, if the third song is currently playing and the playback status data stream has already emitted the "playing" status value, and the user scrolls down the list, item manager A is reused to manage the third song: If the number of retained playback status data streams N=0, the item manager A cannot obtain the "playing" status value after subscribing, and the playback status icon will be blank until the user operates the play / pause button again to display the correct status. If the number of retained playback status data streams N=1, after subscription, item manager A immediately obtains the most recently emitted "playing" status value, and the playback status icon immediately displays "playing". ", consistent with the actual playback status.
[0082] Therefore, configuring the retention count N≥1 ensures that the item manager displays the correct content from the moment of subscription, without waiting for the data to change again.
[0083] In practice, the specific configuration of the above retention count depends on the actual business needs. For example, for scenarios where only the latest value is needed for playback status, N=1 is sufficient. For scenarios that require displaying the history of status changes, such as real-time data curves that require the most recent N data points, a larger N value can be configured. No limitation is made here.
[0084] Furthermore, in this embodiment, since the item manager can obtain historical state values the moment it subscribes to the business data stream, it ensures that the target control presents the correct content from the first moment it is displayed, avoiding the display of blank or default values and improving the user experience.
[0085] Figure 6 A flowchart illustrating a view interface update method provided in another specific embodiment of this application; see reference. Figure 6 As shown, in this embodiment, the method further includes the following steps S50-S70: S50. The item manager maintains the active view status of the current list item. When the item manager receives the latest status value, it compares the latest status value with the active view status. S60. If they match, the item manager skips this update and does not perform a drawing operation. S70. If there is a discrepancy, the item manager performs an update operation.
[0086] In this embodiment, the "effective view state" refers to the state value corresponding to the content already displayed by the target control in the current entry. After each successful update of the target control, the entry manager records the latest effective state value as the "effective view state." When the entry manager receives the latest state value again, it first compares it with the "effective view state" to determine if they match.
[0087] Consistency means that the latest state value is the same as the already effective view state, indicating that the target control is currently displaying the content corresponding to that state value and does not need to be updated again; inconsistency means that the latest state value is different from the already effective view state, indicating that the displayed content of the target control needs to be updated.
[0088] In traditional solutions, when the list scheduler receives a data change notification, it triggers the rebinding and redrawing of the item regardless of whether the data has actually changed (i.e., whether the new value differs from the old value). This is because the difference comparison in traditional solutions occurs at the list scheduler level, and the comparison granularity is the entire item, which cannot accurately compare the state values of individual controls. This embodiment achieves deduplication updates at the control level by maintaining and comparing the state of the active view at the item manager level.
[0089] In a specific embodiment of this application, the above method further includes the following step C10: Step C10: When an item's business status is increased, the item manager adds a corresponding status data stream subscription, thus eliminating the need to modify the list scheduler's configuration logic and binding relationships. In this embodiment, "business status" refers to a certain business data state that an item needs to display. For example, in a music playlist, the initial business status includes two types: "song title" and "playback status." The item manager subscribes to the song title data stream and the playback status data stream. When the product requires the addition of a "favorite" function, a new "favorite status" business status needs to be added.
[0090] In this embodiment, the process for adding a new service status is as follows: (1) Add a collection status data stream to the data source; (2) Add a subscription to the collection status data stream in the item manager to establish the association between the collection status value and the collection icon control.
[0091] In this embodiment, the list scheduler requires no modification because it does not participate in data distribution; its responsibility is limited to creating and managing the entry manager. Data distribution is handled independently by the business data stream, and the entry manager obtains data directly from the business data stream through subscription relationships. Therefore, adding a new business status only requires adding a subscription relationship to the entry manager; the list scheduler's configuration logic and binding relationships remain unchanged.
[0092] Therefore, in this embodiment, when adding a new business state, only one subscription relationship needs to be added in the item manager, without modifying the configuration logic and binding relationship of the list scheduler, which greatly reduces the development workload; and it supports incremental expansion: the subscription relationship of each business state is independent, adding a subscription does not affect existing subscriptions, supports incremental expansion of business functions, and is suitable for agile development mode.
[0093] The following is a specific example to illustrate the process of this solution: Step 1: UI Lifecycle The Activity / Fragment interface serves as the page carrier and holds the LifecycleOwner, providing a foundation for the automatic management of subsequent subscription relationships.
[0094] Step 2: The list scheduler receives the lifecycle manager. The list scheduler adapter obtains the lifecycle manager's identifier from the interface and acts as an intermediary, enabling the item manager to indirectly access the interface's lifecycle information.
[0095] Step 3: Item Manager obtains lifecycle identifier The ViewHolder item manager obtains the identifier of the UI lifecycle manager through the list scheduler, which is used to bind the subscription relationship to the UI lifecycle later.
[0096] Step 4: The item manager actively subscribes to the business data stream ViewModel.flow Based on its binding position in the list, the item manager retrieves the corresponding business data flow from the data source ViewModel and establishes a point-to-point subscription relationship. Data changes will be directly pushed to the item manager without going through the list scheduler.
[0097] Step 5: Data Flow Emits Data Changes When the backend business data changes, the business data stream will send the latest status value to all subscribers.
[0098] Step 6: The item manager receives new data. As a subscriber, the item manager directly receives the latest status values pushed by the business data stream.
[0099] Step 7: The item manager determines its own status. After receiving new data, the item manager performs validity checks, including: whether the current binding adapter position matches the list position corresponding to the data, and whether the current item is in a valid display state.
[0100] Step 8: Branching Valid and matching: The item manager updates the target control of the corresponding item according to the latest status value, completing the view content update; Invalid or mismatched: The item manager does nothing to avoid performing abnormal updates on invalid or invisible items. Furthermore, in the overall process, the item manager autonomously completes the entire chain of "subscription-receive-verify-update", without the need for the list scheduler to participate in data distribution and view positioning, thus realizing point-to-point direct transmission and update of data to the view.
[0101] In yet another embodiment of this application, a vehicle is provided, which includes a vehicle body and electronic devices; Figure 7 A structural diagram of an electronic device provided in an embodiment of this application; see reference Figure 7 As shown in the embodiment of this application, the electronic device includes a processor 1110, a communication interface 1120, a memory 1130, and a communication bus 1140, wherein the processor 1110, the communication interface 1120, and the memory 1130 communicate with each other through the communication bus. Memory 1130 is used to store computer programs; Processor 1110, when executing a program stored in memory, implements the view interface update method described in any of the foregoing method embodiments, including: The item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates based on its own bound position; wherein, the item manager is a management component for a single item in the interface list; When business data changes, the item manager receives the latest status value of the business data pushed by the business data stream; After receiving the latest status value, the item manager verifies the validity of the latest status value; If the verification passes, the item manager updates the target control of the corresponding item in the current list in the interface according to the latest status value.
[0102] In one possible implementation, after the item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates, the method further includes: The item manager obtains the identifier of the page lifecycle manager from the list adapter of the page and binds the subscription relationship with the business data flow to the lifecycle manager; then, when the interface lifecycle ends, the lifecycle manager automatically triggers the termination of the subscription relationship. In one possible implementation, after receiving the latest status value, the item manager verifies the validity of the latest status value, including: The item manager determines whether the list position corresponding to the latest status value matches its own bound position, and whether the current item is in a valid display state; If the list position corresponding to the latest status value matches its own bound position, and the current item is in a valid display state, then the verification passes; otherwise, the verification fails, and the item manager does not perform any operation.
[0103] In one possible implementation, if the verification passes, the item manager updates the target control for the corresponding item within the current list item in the interface, including: If the verification passes, the target control of the entry associated with the latest status value is determined, and the target control is a text control or an image control within the entry; The item manager updates the content of the target control according to the latest status value.
[0104] In one possible implementation, the item manager in the main interface subscribes to the business data stream corresponding to the bound location from the data source to obtain data updates, including: During the list item binding phase, the item manager searches for the business data stream corresponding to the binding position from the data source based on its own binding position in the list; Establish a point-to-point subscription relationship between the item manager and the business data stream, so that data changes are directly pushed to the item manager without going through the list scheduler.
[0105] In one possible implementation, the method further includes: When the item manager is reused to a new list position, the current state data stream subscription is canceled, and the corresponding state data stream is resubscribed according to the new binding position.
[0106] In one possible implementation, the status data stream supports configuring the number of retained states, and the method further includes: When the item manager subscribes to the status data stream, it obtains the status value of the most recent one or more data stream pushes as the initial display content.
[0107] In one possible implementation, the method further includes: The item manager maintains the active view state of the current list item; when the item manager receives the latest state value, it compares the latest state value with the active view state; if they match, the item manager skips the update and does not perform the drawing operation; if they do not match, the item manager performs the update operation.
[0108] In one possible implementation, the method further includes: When an entry's business status is increased, the entry manager adds a corresponding status data stream subscription, thus eliminating the need to modify the list scheduler's configuration logic and binding relationships.
[0109] The electronic device provided in this invention enables the item manager to focus only on data updates corresponding to its bound position by executing a program stored in the memory. The processor can directly obtain the updated content point-to-point and then control the corresponding item's control to update. Compared with the execution process of the prior art, which requires data reorganization, view traversal, and distribution of change tasks when updating the interface, this method can update independently by item more flexibly and efficiently without frequent calls to the list adapter. It is especially suitable for high-frequency refresh scenarios, ensuring that system performance does not degrade and interface updates are accurate and efficient.
[0110] The communication bus 1140 mentioned in the above-mentioned electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 1140 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0111] The communication interface 1120 is used for communication between the above-mentioned electronic device and other devices.
[0112] The memory 1130 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0113] The processor 1110 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0114] In another embodiment of this application, a computer-readable storage medium is provided, on which a program for a view interface update method is stored. When the program for the view interface update method is executed by a processor, it implements the steps of the view interface update method described in any of the foregoing method embodiments.
[0115] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0116] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for updating a view interface, characterized in that, include: The item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates based on its own bound position; wherein, the item manager is a management component for a single item in the interface list; When business data changes, the item manager receives the latest status value of the business data pushed by the business data stream; After receiving the latest status value, the item manager verifies the validity of the latest status value; If the verification passes, the item manager updates the target control of the corresponding item in the current list in the interface according to the latest status value.
2. The view interface update method according to claim 1, characterized in that, After the item manager in the main interface subscribes to the business data stream corresponding to the bound position from the data source to obtain data updates, the method further includes: The item manager obtains the identifier of the page lifecycle manager from the list adapter of the page and binds the subscription relationship with the business data flow to the lifecycle manager; then, when the interface lifecycle ends, the lifecycle manager automatically triggers the termination of the subscription relationship.
3. The view interface update method according to claim 1, characterized in that, After receiving the latest status value, the entry manager verifies the validity of the latest status value, including: The item manager determines whether the list position corresponding to the latest status value matches its own bound position, and whether the current item is in a valid display state; If the list position corresponding to the latest status value matches its own bound position, and the current item is in a valid display state, then the verification passes; otherwise, the verification fails, and the item manager does not perform any operation.
4. The view interface update method according to claim 1, characterized in that, If the verification passes, the item manager updates the target control for the corresponding item in the current list item in the interface, including: If the verification passes, the target control of the entry associated with the latest status value is determined, and the target control is a text control or an image control within the entry; The item manager updates the content of the target control according to the latest status value.
5. The view interface update method according to claim 1, characterized in that, The item manager in the main interface subscribes to the business data stream corresponding to its bound position from the data source to obtain data updates, including: During the list item binding phase, the item manager searches for the business data stream corresponding to the binding position from the data source based on its own binding position in the list; Establish a point-to-point subscription relationship between the item manager and the business data stream, so that data changes are directly pushed to the item manager without going through the list scheduler.
6. The view interface update method according to claim 1, characterized in that, The method further includes: When the item manager is reused to a new list position, the current state data stream subscription is canceled, and the corresponding state data stream is resubscribed according to the new binding position.
7. The view interface update method according to claim 1, characterized in that, The status data stream supports configuring the number of retained states, and the method further includes: When the item manager subscribes to the status data stream, it obtains the status value of the most recent one or more data stream pushes as the initial display content.
8. The view interface update method according to claim 1, characterized in that, The method further includes: The item manager maintains the active view state of the current list item; when the item manager receives the latest state value, it compares the latest state value with the active view state; if they match, the item manager skips the update and does not perform the drawing operation; if they do not match, the item manager performs the update operation.
9. The view interface update method according to claim 1, characterized in that, The method further includes: When an entry's business status is increased, the entry manager adds a corresponding status data stream subscription, thus eliminating the need to modify the list scheduler's configuration logic and binding relationships.
10. A vehicle, characterized in that, It includes a vehicle body and electronic devices, wherein the electronic devices include a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the interface update method according to any one of claims 1 to 9.