A view processing method and apparatus, an electronic device, and a computer-readable medium

By receiving view processing requests, obtaining child view identifiers, listening to changes in parent view attributes, and creating an observer object associated with the parent view, the problem of repeatedly retrieving list display status in application software is solved, thus simplifying code maintenance and accurately displaying status retrieval.

CN114528517BActive Publication Date: 2026-01-20BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210119125.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-08
Publication Date
2026-01-20
Estimated Expiration
2042-02-08

AI Technical Summary

Technical Problem

The existing application software uses a lot of repetitive work to obtain the current list display status. It requires processing every place where visible content needs to be obtained, making code maintenance cumbersome.

Method used

By receiving view processing requests, obtaining the child view identifier, determining the parent view identifier, calling the listening mechanism to listen for changes in the parent view's properties, updating the child view's properties in response to property changes, creating an observation object that is an associated object of the parent view, and removing the listener in response to destruction events, the child view can observe the destruction of the parent view's properties using the associated object mechanism.

Benefits of technology

It supports a wider range of scrolling scenarios, reduces repetitive work, simplifies code maintenance, and can accurately obtain the display status and size of the list content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114528517B_ABST
    Figure CN114528517B_ABST
Patent Text Reader

Abstract

The application discloses a view processing method and device, electronic equipment and a computer readable medium, relates to the technical field of computers, and the method comprises the following steps: receiving a view processing request, and acquiring a corresponding sub-view identifier; determining a parent view identifier corresponding to the sub-view identifier, calling a listening mechanism according to the sub-view identifier and the parent view identifier, listening to a parent view target object attribute corresponding to the parent view identifier, in response to determining that the parent view target object attribute changes, calling a callback mechanism to update a sub-view target object attribute corresponding to the sub-view identifier; creating an observation object, adding the observation object as an associated object of the parent view based on an associated object mechanism, and in response to the destruction of the observation object, calling the callback mechanism to remove the listening to the parent view target object attribute. The associated object is used to realize the destruction observation of the target object attribute of the parent view by the sub-view, the repeated work is less, the code maintenance is simple, and the display state and display part size of the sub-view are accurately acquired.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a view processing method, apparatus, electronic device, and computer-readable medium. Background Technology

[0002] Currently, content in applications (Apps) is typically displayed as a list. In some scenarios, such as exposure statistics, it's necessary to know the status of the content currently displayed in the list: whether it's fully visible, partially visible, or invisible, and if partially visible, what portion is visible. Existing methods involve a lot of repetitive work, requiring processing at every point where visible content needs to be obtained, resulting in cumbersome code maintenance.

[0003] In the process of developing this application, the inventors discovered at least the following problems in the prior art:

[0004] The existing methods for handling the status of the currently displayed content in the application software involve a lot of repetitive work. Every place where visible content needs to be retrieved must be processed, making code maintenance cumbersome. Summary of the Invention

[0005] In view of this, embodiments of this application provide a view processing method, apparatus, electronic device, and computer-readable medium, which can solve the problems of repetitive work, the need to process the view in each place where visible content needs to be obtained, and the cumbersome code maintenance in existing methods of obtaining the status of the current list displayed in application software.

[0006] To achieve the above objectives, according to one aspect of an embodiment of this application, a view processing method is provided, comprising:

[0007] Receive view processing requests and obtain the corresponding subview identifier;

[0008] Determine the parent view identifier corresponding to the child view identifier. Based on the child view identifier and the parent view identifier, invoke the listening mechanism to listen for the properties of the parent view target object corresponding to the parent view identifier. In response to the determination that the properties of the parent view target object have changed, invoke the callback mechanism to update the properties of the child view target object corresponding to the child view identifier.

[0009] Create an observer object, add the observer object as an associated object of the parent view based on the associated object mechanism, and call the callback mechanism in response to the destruction of the observer object to remove the listening to the target object property of the parent view.

[0010] Optionally, before updating the target object property in the subview corresponding to the subview identifier, the method further includes:

[0011] Real-time detection of the scroll offset of the parent view corresponding to the parent view identifier; in response to a change in the scroll offset, a change in the attribute of the parent view's target object.

[0012] Optionally, update the properties of the subview target object corresponding to the subview identifier, including:

[0013] Determine the coordinate system of the current parent view corresponding to the parent view identifier and the scroll direction of the current parent view;

[0014] Based on the coordinate system and scrolling direction, determine the position coordinates of the subview corresponding to the subview identifier;

[0015] Update the properties of the subview target object corresponding to the subview identifier based on the location coordinates.

[0016] Optionally, update the properties of the subview target object corresponding to the subview identifier based on the position coordinates, including:

[0017] Determine the size of the subview's display portion within the current parent view based on its position coordinates;

[0018] Based on the size of the displayed portion, update the properties of the subview target object corresponding to the subview identifier.

[0019] Optionally, based on the size of the displayed portion, update the properties of the subview target object corresponding to the subview identifier, including:

[0020] If the size of the displayed portion is determined to be smaller than a preset threshold, the display state is determined to be invisible; otherwise, it is visible.

[0021] Optionally, based on the size of the displayed portion, update the properties of the subview target object corresponding to the subview identifier, including:

[0022] In response to determining that the size of the displayed portion is greater than a preset threshold, the scroll offset of the subview corresponding to the subview identifier is determined based on the size of the displayed portion, and then the target object property of the subview corresponding to the subview identifier is updated.

[0023] Optionally, remove the listener for the parent view's target object's properties, including:

[0024] In response to the detection that the preset callback function corresponding to the associated object has been called, and the determination that the parent view corresponding to the parent view identifier has been destroyed, the listener on the target object property of the parent view is removed.

[0025] In addition, this application also provides a view processing apparatus, including:

[0026] The receiving unit is configured to receive view processing requests and obtain the corresponding subview identifier;

[0027] The update unit is configured to determine the parent view identifier corresponding to the child view identifier, and based on the child view identifier and the parent view identifier, call the listening mechanism to listen for the parent view target object property corresponding to the parent view identifier. In response to determining that the parent view target object property has changed, call the callback mechanism to update the child view target object property corresponding to the child view identifier.

[0028] The removal unit is configured to create an observer object. Based on the associated object mechanism, the observer object is added as an associated object of the parent view corresponding to the parent view identifier. In response to the destruction of the observer object, the callback mechanism is invoked to remove the listening to the parent view target object property.

[0029] Optionally, the update unit is further configured to:

[0030] Real-time detection of the scroll offset of the parent view corresponding to the parent view identifier; in response to a change in the scroll offset, a change in the attribute of the parent view's target object.

[0031] Optionally, the update unit is further configured to:

[0032] Determine the coordinate system of the current parent view corresponding to the parent view identifier and the scroll direction of the current parent view;

[0033] Based on the coordinate system and scrolling direction, determine the position coordinates of the subview corresponding to the subview identifier;

[0034] Update the properties of the subview target object corresponding to the subview identifier based on the location coordinates.

[0035] Optionally, the update unit is further configured to:

[0036] Determine the size of the subview's display portion within the current parent view based on its position coordinates;

[0037] Based on the size of the displayed portion, update the properties of the subview target object corresponding to the subview identifier.

[0038] Optionally, the update unit is further configured to:

[0039] If the size of the displayed portion is determined to be smaller than a preset threshold, the display state is determined to be invisible; otherwise, it is visible.

[0040] Optionally, the update unit is further configured to:

[0041] In response to determining that the size of the displayed portion is greater than a preset threshold, the scroll offset of the subview corresponding to the subview identifier is determined based on the size of the displayed portion, and then the target object property of the subview corresponding to the subview identifier is updated.

[0042] Optionally, the removal unit is further configured to:

[0043] In response to the detection that the preset callback function corresponding to the associated object has been called, and the determination that the parent view corresponding to the parent view identifier has been destroyed, the listener on the target object property of the parent view is removed.

[0044] In addition, this application also provides a view processing electronic device, including: one or more processors; and a storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the view processing method as described above.

[0045] In addition, this application also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the view processing method as described above.

[0046] One embodiment of the above invention has the following advantages or beneficial effects: This application receives a view processing request and obtains the corresponding subview identifier; determines the parent view identifier corresponding to the subview identifier; and, based on the subview identifier and the parent view identifier, calls a listening mechanism to listen for the parent view target object attribute corresponding to the parent view identifier. In response to determining that the parent view target object attribute has changed, a callback mechanism is called to update the subview target object attribute corresponding to the subview identifier. An observation object is created; based on the association object mechanism, the observation object is added as an association object of the parent view. In response to the destruction of the observation object, a callback mechanism is called to remove the listening to the parent view target object attribute. By utilizing association objects to enable the subview to observe the destruction of the parent view's target object attribute, it supports a wider range of scrolling scenarios, reduces repetitive work, simplifies code maintenance, and provides a general solution for accurately obtaining the display status and size of the subview in real time.

[0047] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0048] The accompanying drawings are provided to better understand this application and do not constitute an undue limitation thereof. Wherein:

[0049] Figure 1 This is a schematic diagram of the main flow of the view processing method according to the first embodiment of this application;

[0050] Figure 2 This is a schematic diagram of the main flow of the view processing method according to the second embodiment of this application;

[0051] Figure 3 This is a schematic diagram illustrating an application scenario of the view processing method according to the third embodiment of this application;

[0052] Figure 4This is a schematic diagram of the main units of a view processing apparatus according to an embodiment of this application;

[0053] Figure 5 This is an exemplary system architecture diagram to which embodiments of this application can be applied;

[0054] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers in the embodiments of this application. Detailed Implementation

[0055] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of this application, including various details to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0056] Figure 1 This is a schematic diagram of the main flow of the view processing method according to the first embodiment of this application, as shown below. Figure 1 As shown, the view processing methods include:

[0057] Step S101: Receive a view processing request and obtain the corresponding subview identifier.

[0058] In this embodiment, the execution entity of the view processing method (e.g., the processor of a terminal) can receive view processing requests sent by the user via a wired or wireless connection. Specifically, the view processing request can be a request to obtain the content display status of a subview in a scrolling view and display the content in the subview based on that content display status. Specifically, the content display status can include the content being fully visible, partially visible, and invisible; when it is partially visible, the extent of the visible portion, etc. The subview identifier can be, for example, the position coordinates of the subview, the name of the subview, or the size of the subview, etc. This embodiment does not limit the specific content of the subview identifier.

[0059] Step S102: Determine the parent view identifier corresponding to the child view identifier. Based on the child view identifier and the parent view identifier, call the listening mechanism to listen for the properties of the parent view target object corresponding to the parent view identifier. In response to the determination that the properties of the parent view target object have changed, call the callback mechanism to update the properties of the child view target object corresponding to the child view identifier.

[0060] A subview is a smaller view within a parent view (i.e., a scrolling view). The specific content displayed in a subview is not limited; it can display text, an image, or a video. This embodiment of the application does not specifically limit the content displayed in a subview.

[0061] The executing entity can determine the corresponding parent view identifier, such as A, based on the child view identifier, such as 'a'. The executing entity can then call the listener corresponding to both the child view identifier and the corresponding parent view identifier to monitor the target object property of the parent view based on the listener's monitoring mechanism. This target object property could be, for example, `contentOffset`, a property of `UIScrollView` (the parent view) representing the scroll offset of `UIScrollView` (the parent view). When a change in the parent view's scroll offset is detected (i.e., when the parent view is scrolling), the executing entity will update the value of this target object property.

[0062] Specifically, update the properties of the subview target object corresponding to the subview identifier, including:

[0063] Determine the coordinate system and scroll direction of the current parent view corresponding to the parent view identifier; based on the coordinate system and scroll direction, determine the position coordinates of the child view corresponding to the child view identifier; update the target object properties of the child view corresponding to the child view identifier based on the position coordinates.

[0064] For example, the executing entity can first obtain the latest scroll offset of the parent view, i.e., the latest contentOffset of the UIScrollView, by listening to the KVO of the parent view's contentOffset property. Then, the executing entity can transform the coordinates of the current subview (i.e., the child view) to the UIScrollView coordinate system, calculate the X or Y position of the subview in the UIScrollView according to the scrolling direction of the UIScrollView, and obtain the current state of the subview (the current state of the subview can include whether the content is fully visible, partially visible, or invisible; when it is partially visible, how much of the content is visible, etc.) and its display size. The calculation result is then passed to the user via a callback.

[0065] Specifically, updating the properties of the subview target object corresponding to the subview identifier based on the position coordinates includes:

[0066] Based on the position coordinates, the size of the displayed portion of the subview within the current parent view is determined. This displayed portion size includes, for example, the dimensions of the subview's top, bottom, left, and right margins relative to the current parent view. The execution body can then update the subview target object properties corresponding to the subview identifier within the parent view based on these displayed portion sizes. The subview target object properties are the scroll offset of the subview corresponding to the subview identifier relative to the parent view. This allows for accurate positioning of the subview's content display state and its exact location within the parent view.

[0067] Specifically, based on the size of the displayed portion, update the properties of the subview target object corresponding to the subview identifier, including:

[0068] In response to determining that the size of the displayed portion is less than a preset threshold, the display state is set to invisible; otherwise, it is set to visible. Specifically, when the size of the displayed portion of a subview is too small, such that it is less than the preset threshold, the display state of the subview's content is set to invisible, meaning the subview's content is not displayed. The preset threshold can be a preset size for the corresponding visible displayed portion of the content. In other words, the target object property of the subview corresponding to the subview identifier is updated to invisible, and the subview corresponding to the subview identifier is not displayed.

[0069] Specifically, based on the size of the displayed portion, update the properties of the subview target object corresponding to the subview identifier, including:

[0070] In response to the determination that the size of the displayed portion is greater than a preset threshold, the scroll offset of the subview corresponding to the subview identifier is determined based on the size of the displayed portion, and then the target object property of the subview corresponding to the subview identifier is updated accordingly. That is, based on the determined scroll offset of the subview corresponding to the subview identifier, the display state of the subview content is determined as fully visible, partially visible, or invisible. If it is partially visible, the size of the visible portion is determined, and the target object property of the subview corresponding to the subview identifier at the current time (i.e., the scroll offset of the subview) is updated accordingly, thereby updating the content and position of the corresponding subview.

[0071] Step S103: Create an observer object. Based on the associated object mechanism, add the observer object as the associated object of the parent view corresponding to the parent view identifier. In response to the destruction of the observer object, call the callback mechanism to remove the listening to the parent view target object property.

[0072] Specifically, the executing entity can add a custom `AssociatedObject` (observation object) to the parent view `UIScrollView` object, and based on the association mechanism, add this observation object as an associated object of the parent view to listen for whether the page corresponding to the parent view is closed and whether the page view resources are destroyed. When the `UIScrollView` is destroyed, its `AssociatedObject` is also destroyed, and the KVO listener is removed in the `dealloc` method of `AssociatedObject`. For example, the executing entity can add a class to the parent view to observe the destruction of a specified object, and issue a notification or callback when the specified object (i.e., the observed object) is destroyed. For example: create a new class named `JDObjectDeallocWatcher`, and add the method `WatchObjectDealloc:callback`: This method has two parameters: the first parameter `WatchObject Dealloc`: is the observed object; the second parameter `callback` is the callback function, which handles the callback when the object is destroyed. `Dealloc`: The method executed when the object is destroyed, in which the callback passed in `watchObjectDealloc:callback` is executed. When a child view adds a listener to a UIScrollView, it can simultaneously create a JDObjectDeallocWatcher object (this object is the aforementioned associated object of the UIScrollView, its purpose is to obtain the destruction time of the UIScrollView, used to remove the KVO listener on the UIScrollView when the UIScrollView is destroyed; when the UIScrollView is destroyed, its associated object is also destroyed, and the dealloc method is executed when the associated object is destroyed, the execution body can remove the UIScroll's KVO listener in the associated object's dealloc method), and call the watchObjectDealloc:callback: method, passing in the UIScrollView and a callback to perform KVO removal. The execution body adds the created JDObjectDeallocWatcher object as an associated object of the UIScrollView and specifies its memory strategy as Retain. Retain means holding; when an associated object is added to a UIScrollView, using this strategy, the UIScrollView (i.e., the parent view) will retain its holding relationship with its associated object to ensure that its associated object exists while the UIScrollView exists.

[0073] Specifically, removing listeners to the parent view's target object's properties includes:

[0074] In response to the detection that the preset callback function corresponding to the associated object has been called, the executing entity determines that the parent view corresponding to the parent view identifier has been destroyed, and then destroys the associated object (e.g., JDObjectDeallocWatcher), and removes the child view's listening to the parent view's target object property.

[0075] In this embodiment, Objective-C is a programming language primarily used for developing iOS system applications. KVO (Key-Value Observing) is an event notification mechanism that allows listening for changes to specific properties of another object and receiving events when those properties change. Due to its implementation mechanism, KVO only works on properties; generally, objects inheriting from NSObject support KVO by default. Category is a feature in the Objective-C programming language that adds methods to existing classes. UIScrollView is a view that allows its contained views to scroll or scale within its bounds. It is the parent class of UITableView, UICollectionView, UITextView, and other scrollable views. ContentOffset is a property of UIScrollView that represents the scroll offset of the UIScrollView. UIView is a view object, the object that displays UI elements on the screen and manages the display of its content. NSObject is the root class of object types in the Objective-C programming language type system; all object types inherit from this type. AssociatedObject: A feature in Objective-C that allows multiple objects to be associated, enabling the dynamic addition of properties to objects. Method swizzle: A mechanism that allows the replacement of existing methods. dealloc: The system default method, executed when an object is destroyed. This method can be overridden during development to clean up related resources when an object is destroyed. Retain: An object reference management strategy in Objective-C, representing a strong reference.

[0076] This embodiment receives a view processing request and obtains the corresponding subview identifier; determines the parent view identifier corresponding to the subview identifier; and, based on the subview identifier and parent view identifier, invokes a listening mechanism to monitor the properties of the parent view target object corresponding to the parent view identifier. In response to a change in the parent view target object property, a callback mechanism is invoked to update the subview target object property corresponding to the subview identifier. An observer object is created; based on the association object mechanism, the observer object is added as an association object of the parent view. In response to the destruction of the observer object, a callback mechanism is invoked to remove the monitoring of the parent view target object property. By utilizing association objects to enable subviews to observe the destruction of parent view target object properties, this approach supports a wider range of scrolling scenarios, reduces repetitive work, simplifies code maintenance, and provides a precise solution for obtaining the display status and size of the subview in real time, offering a general solution for accurately acquiring the display status and information of list content in real time.

[0077] Figure 2 This is a schematic flowchart of the view processing method according to the second embodiment of this application, as shown below. Figure 2 As shown, the view processing methods include:

[0078] Step S201: Receive view processing request and obtain the corresponding subview identifier.

[0079] The principle of step S201 is similar to that of step S101, and will not be repeated here.

[0080] Step S202: Determine the parent view identifier corresponding to the child view identifier. Based on the child view identifier and the parent view identifier, call the listening mechanism to listen to the properties of the parent view target object corresponding to the parent view identifier and detect the scroll offset of the parent view corresponding to the parent view identifier in real time. In response to the determination that the scroll offset has changed, determine that the properties of the parent view target object have changed. In response to the determination that the properties of the parent view target object have changed, call the callback mechanism to update the properties of the child view target object corresponding to the child view identifier.

[0081] Specifically, the parent view, UIScrollView, is the most basic and general scrolling view, from which UITableView and UICollectionView inherit. The `contentOffset` property in UIScrollView represents the scroll offset of the list. By converting and comparing the X or Y coordinates of the child views within the UIScrollView with the `contentOffset`, the precise display state and size of the displayed portion of the child view can be determined. KVO is an observer pattern feature that allows listening to the `contentOffset` property of the parent view, UIScrollView, and executing relevant callbacks whenever the `contentOffset` property changes. The implementation in this embodiment consists of two parts: KVO listening to list scroll calculation processing; and KVO removal. By real-time detection of the scroll offset of the parent view corresponding to the parent view identifier, when a change in the parent view's scroll offset is detected, the execution entity can determine that the target object property of the parent view has changed, thereby determining the approximate scroll offset of the parent view. Based on the scroll offset of the parent view, the content display state of the child view and its relative position to the parent view are calculated, thus displaying the child view accordingly.

[0082] Step S203: Create an observer object. Based on the associated object mechanism, add the observer object as the associated object of the parent view corresponding to the parent view identifier. In response to the destruction of the observer object, call the callback mechanism to remove the listening to the target object property of the parent view.

[0083] The principle of step S203 is similar to that of step S103, and will not be repeated here.

[0084] Figure 3 This is a schematic diagram illustrating an application scenario of the view processing method according to the third embodiment of this application. The view processing method of this application embodiment can be applied to scenarios where the display status of scrolling view content in application software needs to be accurately obtained. For example... Figure 3As shown, the processor's handler 302 receives a view processing request 301 and obtains the corresponding subview identifier 303. The handler 302 determines the parent view identifier 304 corresponding to the subview identifier 303. Based on the subview identifier 303 and the parent view identifier 304, it invokes a listening mechanism 305 to listen for the parent view target object attribute 307 in the parent view 306 corresponding to the parent view identifier 304. In response to determining that the parent view target object attribute 307 has changed, it invokes a callback mechanism 308 to update the subview target object attribute 310 in the subview 309 corresponding to the subview identifier 303. The handler 302 creates an observer object 311 and, based on the association object mechanism 312, adds the observer object 311 as an associated object of the parent view 306 corresponding to the parent view identifier 304. In response to the destruction of the observer object 311, it invokes a callback mechanism 313 to remove the listening to the parent view target object attribute 307.

[0085] Figure 4 This is a schematic diagram of the main units of a view processing apparatus according to an embodiment of this application. Figure 4 As shown, the view processing device includes a receiving unit 401, an updating unit 402, and a removing unit 403.

[0086] The receiving unit 401 is configured to receive view processing requests and obtain the corresponding subview identifier.

[0087] Update unit 402 is configured to determine the parent view identifier corresponding to the child view identifier, and based on the child view identifier and the parent view identifier, invoke the listening mechanism to listen for the parent view target object property corresponding to the parent view identifier. In response to determining that the parent view target object property has changed, the callback mechanism is invoked to update the child view target object property corresponding to the child view identifier.

[0088] Remove unit 403, which is configured to create an observer object. Based on the associated object mechanism, the observer object is added as the associated object of the parent view corresponding to the parent view identifier. In response to the destruction of the observer object, the callback mechanism is called to remove the listening to the parent view target object property.

[0089] In some embodiments, the update unit 402 is further configured to: detect the scroll offset of the parent view corresponding to the parent view identifier in real time, and determine that the attribute of the parent view target object has changed in response to determining that the scroll offset has changed.

[0090] In some embodiments, the update unit 402 is further configured to: determine the coordinate system and scroll direction of the current parent view corresponding to the parent view identifier; determine the position coordinates of the subview corresponding to the subview identifier based on the coordinate system and scroll direction; and update the target object attribute of the subview corresponding to the subview identifier based on the position coordinates.

[0091] In some embodiments, the update unit 402 is further configured to: determine the size of the display portion of the subview in the current parent view based on the position coordinates; and update the subview target object attribute corresponding to the subview identifier based on the display portion size.

[0092] In some embodiments, the update unit 402 is further configured to: determine that the display state is invisible in response to determining that the size of the display portion is less than a preset threshold, otherwise it is visible.

[0093] In some embodiments, the update unit 402 is further configured to: in response to determining that the size of the display portion is greater than a preset threshold, determine the scroll offset of the subview corresponding to the subview identifier based on the size of the display portion, and then update the subview target object attribute corresponding to the subview identifier.

[0094] In some embodiments, the removal unit 403 is further configured to: in response to detecting that a preset callback function corresponding to the associated object is called, determine that the parent view corresponding to the parent view identifier has been destroyed, and remove the listening to the parent view target object attribute.

[0095] It should be noted that the view processing method and view processing device in this application are related in terms of specific implementation content, so repeated content will not be described again.

[0096] Figure 5 An exemplary system architecture 500 is shown that can be applied to the view processing method or view processing apparatus of the embodiments of this application.

[0097] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0098] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, and 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0099] Terminal devices 501, 502, and 503 can be various electronic devices with a view processing screen that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0100] Server 505 can be a server providing various services, such as a backend management server supporting view processing requests submitted by users using terminal devices 501, 502, and 503 (for example only). The backend management server can receive view processing requests, obtain the corresponding subview identifier, determine the parent view identifier corresponding to the subview identifier, and, based on the subview identifier and parent view identifier, invoke a listening mechanism to monitor the parent view target object attributes corresponding to the parent view identifier. In response to a change in the parent view target object attributes, a callback mechanism is invoked to update the subview target object attributes corresponding to the subview identifier. An observer object is created, and based on the association object mechanism, the observer object is added as an association object of the parent view. In response to the destruction of the observer object, a callback mechanism is invoked to remove the monitoring of the parent view target object attributes. By utilizing association objects to enable subviews to observe the destruction of parent view target object attributes, a wider range of scrolling scenarios are supported, repetitive work is reduced, code maintenance is simplified, and the precise display status and size of the subview can be obtained, providing a general solution for accurately obtaining the display status and information of list content in real time.

[0101] It should be noted that the view processing method provided in this application embodiment is generally executed by server 505, and correspondingly, the view processing device is generally set in server 505.

[0102] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0103] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing a terminal device according to the embodiments of this application. Figure 6 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0104] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the computer system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0105] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0106] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this application.

[0107] It should be noted that the computer-readable medium shown in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. Computer-readable storage media can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0108] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0109] The units described in the embodiments of this application can be implemented in software or hardware. The described units can also be located in a processor; for example, a processor may be described as including a receiving unit, an updating unit, and a removing unit. The names of these units do not necessarily limit the specific unit itself.

[0110] In another aspect, this application also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to receive a view processing request, obtain the corresponding subview identifier; determine the parent view identifier corresponding to the subview identifier; and, based on the subview identifier and the parent view identifier, invoke a listening mechanism to listen for the parent view target object attribute corresponding to the parent view identifier. In response to determining that the parent view target object attribute has changed, a callback mechanism is invoked to update the subview target object attribute corresponding to the subview identifier. An observer object is created; based on the association object mechanism, the observer object is added as an association object of the parent view. In response to the destruction of the observer object, a callback mechanism is invoked to remove the listening to the parent view target object attribute.

[0111] According to the technical solution of the embodiments of this application, by utilizing associated objects to enable the destruction and observation of the target object attributes of the parent view by the subview, a wider range of scrolling scenarios are supported, repetitive work is reduced, code maintenance is simple, and the accurate display status and display size of the subview can be obtained. This provides a general solution that can accurately obtain the display status and information of list content in real time.

[0112] The specific embodiments described above do not constitute a limitation on the scope of protection of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A view processing method, characterized in that, include: In exposure statistics, receive view processing requests and obtain the corresponding subview identifiers; Determine the parent view identifier corresponding to the child view identifier. Based on the child view identifier and the parent view identifier, invoke a listening mechanism to listen for the parent view target object attribute corresponding to the parent view identifier. In response to determining that the parent view target object attribute has changed, obtain the latest scroll offset of the parent view. Calculate the content display state of the child view and its relative position with respect to the parent view based on the latest scroll offset of the parent view. The content display state includes whether the content currently displayed in the list is fully visible, partially visible, or invisible. Invoke a callback mechanism to update the child view target object attribute corresponding to the child view identifier based on the content display state of the child view and its relative position with respect to the parent view. Create an observation object. Based on the associated object mechanism, add the observation object as the associated object of the parent view corresponding to the parent view identifier. Add a class to the parent view to observe the destruction of the specified object. When the specified object is destroyed, issue a notification or callback. In response to the destruction of the observation object, call the callback mechanism to remove the listening to the target object property of the parent view.

2. The method according to claim 1, characterized in that, Before updating the target object property in the subview corresponding to the subview identifier, the method further includes: The scroll offset of the parent view corresponding to the parent view identifier is detected in real time, and in response to determining that the scroll offset has changed, the attribute of the target object of the parent view has changed.

3. The method according to claim 1, characterized in that, Updating the subview target object property corresponding to the subview identifier includes: Determine the coordinate system of the current parent view corresponding to the parent view identifier and the scroll direction of the current parent view; Based on the coordinate system and the scrolling direction, determine the position coordinates of the subview corresponding to the subview identifier; Update the subview target object properties corresponding to the subview identifier based on the location coordinates.

4. The method according to claim 3, characterized in that, Updating the subview target object attribute corresponding to the subview identifier based on the position coordinates includes: Based on the position coordinates, determine the size of the display portion of the subview within the current parent view; Based on the size of the displayed portion, update the subview target object properties corresponding to the subview identifier.

5. The method according to claim 4, characterized in that, The step of updating the subview target object attribute corresponding to the subview identifier based on the size of the displayed portion includes: In response to determining that the size of the display portion is less than a preset threshold, the display state is determined to be invisible; otherwise, it is visible.

6. The method according to claim 4, characterized in that, The step of updating the subview target object attribute corresponding to the subview identifier based on the size of the displayed portion includes: In response to determining that the size of the display portion is greater than a preset threshold, the scroll offset of the subview corresponding to the subview identifier is determined based on the size of the display portion, and then the target object attribute of the subview corresponding to the subview identifier is updated.

7. The method according to claim 1, characterized in that, The removal of the listener on the parent view target object property includes: In response to the detection that the preset callback function corresponding to the associated object is called, it is determined that the parent view corresponding to the parent view identifier has been destroyed, and the listening to the target object property of the parent view is removed.

8. A view processing apparatus, characterized in that, include: The receiving unit is configured to receive view processing requests and obtain the corresponding subview identifiers in exposure statistics. The update unit is configured to determine the parent view identifier corresponding to the child view identifier, and based on the child view identifier and the parent view identifier, invoke a listening mechanism to listen for the parent view target object attribute corresponding to the parent view identifier. In response to determining that the parent view target object attribute has changed, the unit obtains the latest scroll offset of the parent view, calculates the content display state of the child view and its relative position with respect to the parent view based on the latest scroll offset of the parent view, wherein the content display state includes the content currently displayed in the list being fully visible, partially visible, and invisible, and invokes a callback mechanism to update the child view target object attribute corresponding to the child view identifier based on the content display state of the child view and its relative position with respect to the parent view. The removal unit is configured to create an observation object. Based on the associated object mechanism, the observation object is added as an associated object of the parent view corresponding to the parent view identifier. A class is added to the parent view to observe the destruction of the specified object. When the specified object is destroyed, a notification or callback is issued. In response to the destruction of the observation object, the callback mechanism is called to remove the listening to the target object property of the parent view.

9. The apparatus according to claim 8, characterized in that, The update unit is further configured to: The scroll offset of the parent view corresponding to the parent view identifier is detected in real time, and in response to determining that the scroll offset has changed, the attribute of the target object of the parent view has changed.

10. The apparatus according to claim 8, characterized in that, The update unit is further configured to: Determine the coordinate system of the current parent view corresponding to the parent view identifier and the scroll direction of the current parent view; Based on the coordinate system and the scrolling direction, determine the position coordinates of the subview corresponding to the subview identifier; Update the subview target object properties corresponding to the subview identifier based on the location coordinates.

11. A view processing electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.

12. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Data processing method and device, storage medium and electronic equipment

    CN112835762A

  • Scroll view control method and device, equipment and storage medium

    CN113760163A