Click anti-shake method and related equipment
Through the tangential programming framework and the compilation period code weaving method, a non-invasive and differentiated click-shake strategy is realized, solving the problems of code redundancy and logic coupling in the existing technology, and improving system stability and user experience.
Patent Information
- Application Number
- CN202510404166.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-08-19
AI Technical Summary
In the prior art, the anti-shake handling of click events has problems such as redundant code, high logic coupling, limited scope of application, and difficulty in flexibly configuring anti-shake strategies, which affects system stability and user experience.
The method of tangential programming framework and compilation period code weaving is adopted. The target method is automatically detected through tangential class annotation, the anti-shake parameters are obtained, and the target method is judged based on the parameters, and a non-invasive and differentiated anti-shake strategy is realized to avoid code redundancy and ensure thread safety.
It improves the maintainability and readability of the code, realizes flexible anti-shake strategy adaptation, reduces repetitive labor and resource waste, and improves system stability and user experience.
Smart Images

Figure CN120508335A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Android application software technology, and more specifically, to a click anti-shake method and related equipment. Background Art
[0002] With the rapid development of the mobile internet, interactive methods for smart devices are becoming increasingly diverse. Click events in user interfaces play a crucial role in various application scenarios. Whether in mobile applications, web pages, or embedded systems, frequent user clicks often trigger a series of interactive logic. However, high click frequencies can lead to abnormal interface responses, repeated event triggering, resource waste, and even a negative impact on user experience. Therefore, during application development, how to effectively de-bounce click events becomes a key issue in improving system stability and interactive fluidity.
[0003] In the related art, the anti-shake processing for click events usually relies on manually adding time interval judgment logic in the business code, or using a general anti-shake tool class for encapsulation. Although these methods can reduce the impact of repeated clicks to a certain extent, there are still many shortcomings; for example, manually adding anti-shake logic can easily lead to code redundancy, making the business logic and anti-shake logic highly coupled, reducing the maintainability and scalability of the code; in addition, the general anti-shake tool class can often only act on specific callback methods, and it is difficult to adaptively adjust the anti-shake strategy for different business scenarios, which limits its scope of application. Especially in large projects, different modules may require different anti-shake rules, and existing methods are often unable to flexibly support multiple anti-shake strategies, resulting in large technical challenges in the application development process. That is, there are technical problems in the related art that the anti-shake logic is highly coupled with the business logic, the scope of application is limited, and it is difficult to flexibly configure the anti-shake strategy. Summary of the Invention
[0004] The Summary of the Invention section of this application introduces a series of simplified concepts that will be further described in detail in the Detailed Description of the Invention section. The Summary of the Invention section of this application is not intended to limit the key features and essential technical features of the claimed technical solution, nor is it intended to determine the scope of protection of the claimed technical solution.
[0005] The click anti-shake method and related equipment provided in this application can be based on the aspect-oriented programming framework and compile-time code weaving, can implement non-invasive and differentiated anti-shake strategies, avoid code redundancy, improve maintainability and readability, and ensure thread safety through atomic operations.
[0006] In the first aspect, the present application provides a click anti-shake method, including: when the target method is called, the target method is detected through the aspect class annotation of the aspect-oriented programming framework to determine whether the target method is a preset anti-shake object; when the target method is the preset anti-shake object, the target anti-shake parameters are obtained; according to the target anti-shake parameters, whether to execute the target method is determined.
[0007] In some embodiments, the preset anti-shake object includes a first anti-shake object and a second anti-shake object; the detecting of the target method through the aspect class annotation of the aspect-oriented programming framework to determine whether the target method is the preset anti-shake object includes: detecting the target method through the aspect class annotation of the aspect-oriented programming framework; when it is detected that the target method is set with a custom anti-shake annotation, determining that the target method is the first anti-shake object; when it is detected that the target method is not set with the custom anti-shake annotation, and the target method is the selection method of the tab layout or the click method of the click listener, determining that the target method is the second anti-shake object.
[0008] In some embodiments, when the target method is the preset anti-shake object, obtaining the target anti-shake parameters includes: when the target method is the first anti-shake object, obtaining the target anti-shake parameters by parsing the preset method interception class; when the target method is the second anti-shake object, obtaining the target anti-shake parameters by parsing the preset annotation interception class.
[0009] In some embodiments, the target anti-shake parameters include an anti-shake time threshold and an affinity value; and determining whether to execute the target method based on the target anti-shake parameters includes determining whether to execute the target method based on the anti-shake time threshold and the affinity value.
[0010] In some embodiments, the target anti-shake parameter also includes an anti-shake enabled Boolean value; judging whether to execute the target method based on the anti-shake time threshold and the affinity value includes: when the anti-shake enabled Boolean value is true, judging whether to execute the target method based on the anti-shake time threshold and the affinity value.
[0011] In some embodiments, the target anti-shake parameter also includes an anti-shake rule Boolean value; when the anti-shake enable Boolean value is true, judging whether to execute the target method according to the anti-shake time threshold and the affinity value, including: when the anti-shake enable Boolean value is true and the anti-shake rule Boolean value is true, judging whether to execute the target method according to the pre-anti-shake rule according to the anti-shake time threshold and the affinity value; when the anti-shake enable Boolean value is true and the anti-shake rule Boolean value is false, judging whether to execute the target method according to the post-anti-shake rule according to the anti-shake time threshold and the affinity value.
[0012] In some embodiments, the click anti-shake method further includes: when the target method is called, parsing a first click attribute declared in an extensible markup language layout file; when a second click attribute of the target method is the same as the first click attribute, determining that the target method is the preset anti-shake object.
[0013] In the second aspect, the present application also provides a click anti-shake device, including: a method detection unit, which is used to detect the target method through the aspect class annotation of the aspect-oriented programming framework when the target method is called, and determine whether the target method is a preset anti-shake object; a parameter acquisition unit, which is used to obtain target anti-shake parameters when the target method is the preset anti-shake object; and a method execution unit, which is used to determine whether to execute the target method based on the target anti-shake parameters.
[0014] In a third aspect, the present application further provides an electronic device comprising: a memory and a processor, wherein the processor is configured to implement the steps of the click anti-shake method described in the first aspect when executing a computer program stored in the memory.
[0015] In a fourth aspect, the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the click anti-shake method described in the first aspect.
[0016] In a fifth aspect, the present application also provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the click anti-shake method provided in the embodiment of the present application is implemented.
[0017] In summary, the present application automatically detects the target method through the aspect class annotation of the aspect-oriented programming framework. There is no need to modify the business logic code, and there is no need to manually add anti-shake logic in the business code, which avoids code redundancy and repetitive work. The anti-shake logic is separated from the business logic and unified through the aspect class configuration, which can improve the maintainability and readability of the code; and through the preset anti-shake object classification and target parameter acquisition, differentiated anti-shake strategies can be implemented; and based on compile-time code weaving (non-runtime reflection), anti-shake logic is implanted, and combined with atomic operations, thread safety can be guaranteed. In summary, the click anti-shake method provided by the present application is based on the aspect-oriented programming framework and compile-time code weaving, which can implement non-invasive, differentiated anti-shake strategies, avoid code redundancy, improve maintainability and readability, and ensure thread safety through atomic operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present description. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:
[0019] Figure 1 A flowchart of a click anti-shake method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of the structure of a click stabilization device provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] Terms in the specification, claims, and drawings of this application, such as "first," "second," "third," "fourth," and the like (if any), are used to distinguish between similar objects, rather than to describe a particular order or precedence. Therefore, it is understood that these terms can be used interchangeably where appropriate, so that the embodiments described can be implemented in a different order, unless otherwise specified in the drawings or descriptions. In addition, the terms "is" and "has" and any variations thereof in this application are intended to cover all possible constituent elements on a non-exclusive basis. For example, a process, method, system, product, or apparatus that includes several steps or units is not necessarily limited to the steps or units that are explicitly listed, but may also include other steps or units that are not explicitly listed, or steps or units that are inherent to the process, method, product, or apparatus.
[0023] In this application, a "module" or "unit" refers to a computer program or part of a computer program that has a specific function and works in conjunction with other related parts to achieve a predetermined goal. These modules or units can be implemented by software, hardware (such as processing circuits or memories), or a combination of the two. One or more processors or memories can implement one or more modules or units. At the same time, each module or unit can also be part of a larger module or unit.
[0024] The technical solutions in this application will be described in detail below in conjunction with the accompanying drawings in the embodiments. It should be noted that the embodiments described are only part of this application, not all embodiments. In the following description, the "some embodiments" mentioned are only a subset of all possible embodiments, which may be the same or different subsets, and different embodiments can be combined with each other without conflict.
[0025] Figure 1 This is a flowchart of a click anti-shake method provided by an embodiment of the present application. Figure 1 The click anti-shake method provided in the embodiment of the present application may include the following steps 101 to 103:
[0026] Step 101: When a target method is called, the target method is detected by using the aspect class annotation of the aspect-oriented programming framework to determine whether the target method is a preset anti-shake target;
[0027] In some examples, the target method refers to a method that needs to be executed but may be affected by the de-shake mechanism. It can be a method related to user interaction, such as a button click event, an option switch event, etc. In the Aspect Oriented Programming (AOP) framework, method calls can be intercepted through aspects; the target method is called when the target method is triggered by user interaction or system events during the application running and needs to enter the execution phase; for example, when the user clicks a button, the system calls its bound onClick() method. The aspect-oriented programming framework is a programming paradigm that allows aspects to inject additional logic through compile-time code weaving without modifying the original code; aspect class annotations are annotations used to mark methods that need to be intercepted, so that the aspect-oriented programming framework can automatically identify and execute de-shake logic. The preset de-shake object is a method category that is preset to require de-shake control, such as the onClick() method, the selectTab() method, etc.
[0028] For example, a plug-in of the aspect-oriented programming framework can be used to implement compile-time code weaving and integrated through Gradle configuration. The specific implementation code is as follows:
[0029]
[0030]
[0031] By implementing step 101, the target method can be automatically detected through the aspect-oriented programming mechanism without modifying the business code, avoiding the manual insertion of anti-shake logic in the code. This can improve the maintainability of the code, unify the management of anti-shake rules, ensure the neatness of the code, and reduce duplication of work and redundant code.
[0032] Step 102: When the target method is a preset anti-shake target, obtain target anti-shake parameters;
[0033] In some examples, target anti-shake parameters refer to key parameters that control the anti-shake logic, which may include but are not limited to anti-shake time intervals, anti-shake rules, affinity values, anti-shake enablement status, etc. The target anti-shake parameters determine the execution rhythm of the target method and how to handle repeated triggering situations.
[0034] Through the implementation of step 102, different methods can be configured with different anti-shake parameters, which can flexibly adapt to different business scenarios, avoid the limitations of the global fixed anti-shake strategy, and improve the applicability and scalability of the method.
[0035] Step 103: Determine whether to execute the target method according to the target anti-shake parameter;
[0036] In some examples, after obtaining the target anti-shake parameters, you can first check the last call time of the target method and calculate the time interval between the current call and the last call. If it is less than the anti-shake time threshold set in the target anti-shake parameters, the call is directly intercepted and the target method is not allowed to execute.
[0037] By implementing step 103, repeated triggering can be effectively reduced, user experience can be improved, repeated calls to the same method in a short period of time can be avoided, invalid calculations can be reduced, and application performance can be improved; it can also ensure thread safety, prevent repeated execution or race conditions in a multi-threaded environment, and improve application stability.
[0038] In summary, the embodiment of the present application automatically detects the target method through the aspect class annotation of the aspect-oriented programming framework, without modifying the business logic code, and without manually adding anti-shake logic in the business code, avoiding code redundancy and repetitive work, and the anti-shake logic is separated from the business logic and unified through the aspect class configuration, which can improve the maintainability and readability of the code; and through the preset anti-shake object classification and target parameter acquisition, it can achieve differentiated anti-shake strategies; and based on compile-time code weaving (non-runtime reflection) to implant anti-shake logic, combined with atomic operations, it can ensure thread safety. In summary, the click anti-shake method provided by the embodiment of the present application is based on the aspect-oriented programming framework and compile-time code weaving, which can implement non-invasive, differentiated anti-shake strategies, avoid code redundancy, improve maintainability and readability, and ensure thread safety through atomic operations.
[0039] In some embodiments, the aforementioned preset anti-shake object may include a first anti-shake object and a second anti-shake object; the aforementioned detection of the target method through the aspect class annotation of the aspect-oriented programming framework to determine whether the target method is the preset anti-shake object may include: detecting the target method through the aspect class annotation of the aspect-oriented programming framework; when it is detected that the target method is set with a custom anti-shake annotation, judging that the target method is the first anti-shake object; when it is detected that the target method is not set with a custom anti-shake annotation, and the target method is the selection method of the tab layout or the click method of the click listener, judging that the target method is the second anti-shake object.
[0040] In some examples, the first debounce target refers to a method with a custom debounce annotation (such as @Debounce). Calls to this method are controlled by the annotation parameters, preventing repeated execution within a set time interval. Aspect-oriented programming can intercept method calls and check whether the target method is annotated with the custom debounce annotation. If the method carries the @Debounce annotation, it is identified as the first debounce target and the debounce logic is executed based on the annotation parameters. A custom debounce annotation is an annotation used to mark methods that require debounce control. This annotation can set specific debounce parameters such as the debounce time and strategy, thereby controlling the method's execution frequency. A second debounce target refers to methods that are not explicitly annotated with a custom debounce annotation but belong to specific interactive components, such as the tab layout's selection method and the click listener's click method. Although these methods do not have manual debounce annotations, the aspect-oriented programming framework automatically recognizes them and applies the default debounce strategy. The tab layout's selection method refers to the onTabSelected(Tab tab) method in the TabLayout.OnTabSelectedListener interface, which is triggered when the user switches tabs. The click method of the click listener refers to the onClick(View v) method in the View.OnClickListener interface, which is used to handle click events of buttons or other interactive controls.
[0041] Through the implementation of the above embodiments, different anti-shake rules can be adopted for different target methods, which can enhance the applicability of the method; moreover, anti-shake can be precisely controlled through custom annotations, supporting personalized configuration, which can improve the flexibility of the method; even if anti-shake annotations are not explicitly added, the appropriate anti-shake strategy can be automatically applied to reduce the risk of omissions.
[0042] In some embodiments, the aforementioned step 102 may include: when the target method is the first anti-shake object, obtaining the target anti-shake parameters by parsing the preset method interception class; when the target method is the second anti-shake object, obtaining the target anti-shake parameters by parsing the preset annotation interception class.
[0043] In some examples, the preset method interception class is a class specifically used to parse methods with custom anti-shake annotations. Its function is to parse the anti-shake annotation parameters of the target method and extract the target anti-shake parameters after the first anti-shake object is called. For example, when it is detected that the target method is marked with a custom anti-shake annotation, the preset method interception class will parse the annotation information of the target method and extract the annotation parameters as the target anti-shake parameters. The preset annotation interception class is a custom class specifically used to process methods that do not have custom anti-shake annotations but meet the anti-shake conditions. Its function is to parse the target method through the default strategy and apply the anti-shake parameters preset by the system to it.
[0044] For example, the specific implementation code of the preset method interception class for the click method of the click listener is as follows:
[0045]
[0046]
[0047] For example, the specific implementation code of the preset method interception class for the click method of the click listener is as follows:
[0048]
[0049]
[0050] For example, the specific implementation code of the preset annotation interception class is as follows:
[0051]
[0052]
[0053] Through the implementation of the above embodiments, different types of anti-shake objects can have different parameter parsing methods, which are more adaptable; and customized anti-shake logic is supported, and anti-shake parameters can be obtained through preset method interception classes or annotation parsing classes, which can enhance the scalability of the method; separating anti-shake logic and business logic can reduce coupling and improve code readability and maintainability.
[0054] In some embodiments, the aforementioned target anti-shake parameters may include an anti-shake time threshold and an affinity value; the aforementioned step 103 may include: judging whether to execute the target method according to the anti-shake time threshold and the affinity value.
[0055] In some examples, the de-shake time threshold refers to the minimum time interval that must elapse between two identical operations. If a new operation occurs within a time interval less than the threshold, the new operation will be blocked and not executed. For example, if a button click event has a de-shake time threshold of 800ms, then if a user quickly clicks twice within 500ms, the second click will be blocked to prevent repeated triggering. The affinity value is a numerical parameter used to distinguish the de-shake processing relationship between different interaction events (methods). It is used to determine which other methods the target method should share the same de-shake time threshold with and whether the target method should calculate the de-shake time independently. For example, if the "Submit" button and the "Confirm" button are both set with the same affinity value, then they share the same de-shake time window. That is, if the user clicks "Submit" within the de-shake time threshold and then immediately clicks "Confirm", the latter button will be blocked. If the "Submit" button and the "Cancel" button have different affinity values, then their de-shake time thresholds are independent of each other, and clicking "Submit" will not affect the triggering of "Cancel". When determining whether the target method is executed, it is necessary to check the time interval between the target method and other methods in the same affinity group. If the interval is less than the debounce time threshold, the target method call will be intercepted; otherwise, it will be executed normally.
[0056] Through the implementation of the above embodiments, the use of the anti-shake time threshold can prevent repeated clicks in a short period of time, improve the user experience, and avoid misoperation; the use of the affinity value can allow multiple related events to share the same anti-shake strategy, which can improve the flexibility and accuracy of anti-shake.
[0057] In some embodiments, the aforementioned target anti-shake parameter may further include an anti-shake enabled Boolean value; the aforementioned determination of whether to execute the target method based on the anti-shake time threshold and affinity value may include: when the anti-shake enabled Boolean value is true, determining whether to execute the target method based on the anti-shake time threshold and affinity value.
[0058] In some examples, the de-shake enable Boolean value is a Boolean type parameter used to control whether the target method needs to be de-shaked; when the value is "true", the target method call will be restricted according to the de-shake rules of the target de-shake parameter; when the value is "false", the target method will be executed directly each time it is called.
[0059] Through the implementation of the above embodiments, flexible switch control is provided, anti-shake can be disabled in specific scenarios, adaptability is improved, unnecessary anti-shake can be avoided, interference with business logic is reduced, and user experience is improved.
[0060] In some embodiments, the aforementioned target anti-shake parameters may also include an anti-shake rule Boolean value; the aforementioned when the anti-shake enabled Boolean value is true, judging whether to execute the target method according to the anti-shake time threshold and affinity value, may include: when the anti-shake enabled Boolean value is true and the anti-shake rule Boolean value is true, judging whether to execute the target method according to the pre-anti-shake rule according to the anti-shake time threshold and affinity value; when the anti-shake enabled Boolean value is true and the anti-shake rule Boolean value is false, judging whether to execute the target method according to the post-anti-shake rule according to the anti-shake time threshold and affinity value.
[0061] In some examples, the debounce rule Boolean value is a Boolean parameter that determines whether to use a pre-debounce or post-debounce strategy. When the debounce rule Boolean value is "true," the pre-debounce rule is used, meaning the debounce condition is checked before the method is executed and whether to execute it. When the debounce rule Boolean value is "false," the post-debounce rule is used, meaning the debounce logic is processed after the method is called. The pre-debounce rule is checked before the target method is executed. If the trigger interval is less than the set debounce time threshold, the method is directly intercepted and the target method is not executed. Specifically, before the target method is called, the debounce manager obtains the last method execution time, calculates whether the interval meets the debounce condition, queries the affinity value, and determines whether the component belongs to a shared debounce window. For example, if the debounce time threshold is set to 1000ms and the pre-debounce rule is used, the user clicks the "Submit" button for the first time, and the method executes normally. 500ms later, the user clicks again, but because the debounce time threshold (1000ms) is not exceeded, the method is intercepted and the page does not respond. The post-debounce rule triggers the debounce logic after the method is executed. That is, the target method will be executed, but it will not be triggered again within a certain period of time after execution (within the debounce time threshold). Specifically, after the target method is executed, the debounce manager updates the method call time and intercepts subsequent calls within the debounce window. For example, if the debounce time threshold is set to 1000ms and the post-debounce rule is used, the user clicks "Refresh" for the first time, the method is executed, and the data is refreshed. 800ms later, the user clicks again. Due to the post-debounce logic, the target method has already been executed but is still within the debounce window, so this click is intercepted.
[0062] Through the implementation of the above embodiments, front-end anti-shake is suitable for avoiding high-frequency clicks, such as preventing repeated form submissions or continuous button triggering; post-anti-shake is suitable for scenarios that require waiting for user operations to stabilize before execution, such as search box input anti-shake; configurable anti-shake strategy can select the most appropriate anti-shake method according to business needs to improve user interaction experience.
[0063] In some embodiments, the aforementioned click anti-shake method may further include: when the target method is called, parsing the first click attribute declared in the extensible markup language layout file; when the second click attribute of the target method is the same as the first click attribute, determining that the target method is a preset anti-shake object.
[0064] In some examples, the Extensible Markup Language layout file is a file used to define the interface structure and component properties in the UI framework of an Android application. It is used to describe the layout of UI elements such as buttons (Button), text boxes (TextView), and list items (RecyclerViewItem) and their interactive behaviors. The first click attribute refers to the identifier related to the click event declared in the Extensible Markup Language layout file, which can be used to mark the click behavior of the method for judgment in anti-shake processing; for example, the click method name can be obtained through the android:onClick attribute, and the custom unique identifier can be obtained through the android:tag attribute. If android:onClick="handleClick" is written in the Extensible Markup Language layout file, the handleClick method is the first click attribute; if android:tag="submit_action" is written in the Extensible Markup Language layout file, "submit_action" is the first click attribute and can be used for comparison and judgment. The second click attribute refers to the click identifier parsed from the click event when the target method is called, which is used to match with the first click attribute to determine whether it belongs to the anti-shake object; for example, the tag value of the current button can be obtained through the View.getTag() method, and the name of the currently triggered click method can be parsed through the reflection mechanism; the second click attribute is compared with the first click attribute. If the two are the same, it is considered that the target method belongs to the preset anti-shake object and anti-shake judgment is required.
[0065] By implementing the above embodiment, the click events in the extensible markup language layout file are automatically parsed, which can ensure that the click events declared in the layout can also enjoy anti-shake protection, thereby improving the compatibility of the method.
[0066] Furthermore, as an implementation of the aforementioned method embodiment, the present application also provides a click anti-shake device for implementing the aforementioned method embodiment. This device embodiment corresponds to the aforementioned method embodiment. For ease of reading, this click anti-shake device embodiment will no longer describe the details of the aforementioned method embodiment one by one, but it should be clear that the device in the embodiment of the present application can implement all the contents of the aforementioned method embodiment. Figure 2As shown, the click anti-shake device 20 includes: a method detection unit 201, a parameter acquisition unit 202 and a method execution unit 203, wherein the method detection unit 201 is used to detect the target method through the aspect class annotation of the aspect-oriented programming framework when the target method is called, and determine whether the target method is a preset anti-shake object; the parameter acquisition unit 202 is used to obtain target anti-shake parameters when the target method is a preset anti-shake object; the method execution unit 203 is used to determine whether to execute the target method according to the target anti-shake parameters.
[0067] In some embodiments, the preset anti-shake objects include a first anti-shake object and a second anti-shake object; the method detection unit 201 is also used to detect the target method through the aspect class annotation of the aspect-oriented programming framework; when it is detected that the target method is set with a custom anti-shake annotation, the target method is judged to be the first anti-shake object; when it is detected that the target method is not set with a custom anti-shake annotation, and the target method is the selection method of the tab layout or the click method of the click listener, the target method is judged to be the second anti-shake object.
[0068] In some embodiments, the parameter acquisition unit 202 is further used to obtain target anti-shake parameters by parsing a preset method interception class when the target method is a first anti-shake object; and to obtain target anti-shake parameters by parsing a preset annotation interception class when the target method is a second anti-shake object.
[0069] In some embodiments, the target anti-shake parameters include an anti-shake time threshold and an affinity value; the method execution unit 203 is further configured to determine whether to execute the target method according to the anti-shake time threshold and the affinity value.
[0070] In some embodiments, the target anti-shake parameter further includes an anti-shake enabled Boolean value; the method execution unit 203 is further configured to determine whether to execute the target method according to the anti-shake time threshold and the affinity value when the anti-shake enabled Boolean value is true.
[0071] In some embodiments, the target anti-shake parameter also includes an anti-shake rule Boolean value; the method execution unit 203 is also used to determine whether to execute the target method according to the pre-anti-shake rule based on the anti-shake time threshold and affinity value when the anti-shake enable Boolean value is true and the anti-shake rule Boolean value is true; when the anti-shake enable Boolean value is true and the anti-shake rule Boolean value is false, determine whether to execute the target method according to the post-anti-shake rule based on the anti-shake time threshold and affinity value.
[0072] In some embodiments, the method detection unit 201 is also used to parse the first click attribute declared in the extensible markup language layout file when the target method is called; when the second click attribute of the target method is the same as the first click attribute, determine that the target method is a preset anti-shake object.
[0073] The present application also provides a computer-readable storage medium, which stores computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will be caused to execute any step of the click anti-shake method provided in the present application.
[0074] In some embodiments, the computer-readable storage medium may be a random access memory (RAM), a read-only memory (ROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); or it may be various devices including one or any combination of the above memories.
[0075] In some embodiments, computer-executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0076] In some embodiments, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinating files (for example, files storing one or more modules, subroutines, or code portions).
[0077] In some embodiments, computer-executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed across multiple sites and interconnected by a communication network.
[0078] like Figure 3 As shown, the present application also provides an electronic device 30, including a memory 310, a processor 320 and a computer program 311 stored in the memory 310 and executable on the processor. When the processor 320 executes the computer program 311, any step of the above-mentioned click anti-shake method is implemented.
[0079] The present application also provides a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer program or computer-executable instructions from the computer-readable storage medium and executes the computer program or computer-executable instructions, causing the electronic device to perform any step of the click stabilization method described above.
[0080] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A click stabilization method, characterized in that: include: When a target method is called, the target method is detected through the aspect class annotation of the aspect-oriented programming framework to determine whether the target method is a preset anti-shake object; When the target method is the preset anti-shake object, obtaining target anti-shake parameters; Determine whether to execute the target method according to the target anti-shake parameter.
2. The click stabilization method according to claim 1, wherein: The preset anti-shake object includes a first anti-shake object and a second anti-shake object; The detecting the target method by using the aspect class annotation of the aspect-oriented programming framework to determine whether the target method is a preset anti-shake object includes: Detecting the target method through the aspect class annotation of the aspect-oriented programming framework; When it is detected that the target method is set with a custom anti-shake annotation, determining that the target method is the first anti-shake object; When it is detected that the target method is not set with the anti-shake custom annotation and the target method is the selection method of the tab layout or the click method of the click listener, it is determined that the target method is the second anti-shake object.
3. The click anti-shake method according to claim 2, wherein: When the target method is the preset anti-shake object, obtaining target anti-shake parameters includes: When the target method is the first anti-shake object, obtaining the target anti-shake parameter by parsing a preset method interception class; When the target method is the second anti-shake object, the target anti-shake parameter is obtained by parsing a preset annotation interception class.
4. The click stabilization method according to claim 1, wherein: The target anti-shake parameters include an anti-shake time threshold and an affinity value; The determining, based on the target anti-shake parameter, whether to execute the target method includes: Whether to execute the target method is determined according to the anti-shake time threshold and the affinity value.
5. The click anti-shake method according to claim 4, characterized in that: The target anti-shake parameter also includes an anti-shake enabling Boolean value; The determining, based on the anti-shake time threshold and the affinity value, whether to execute the target method includes: When the anti-shake enabling Boolean value is true, whether to execute the target method is determined according to the anti-shake time threshold and the affinity value.
6. The click anti-shake method according to claim 5, characterized in that: The target anti-shake parameter also includes an anti-shake rule Boolean value; When the anti-shake enabling Boolean value is true, determining whether to execute the target method according to the anti-shake time threshold and the affinity value includes: When the anti-shake enable Boolean value is true and the anti-shake rule Boolean value is true, determining whether to execute the target method according to the pre-anti-shake rule based on the anti-shake time threshold and the affinity value; When the anti-shake enable Boolean value is true and the anti-shake rule Boolean value is false, whether to execute the target method is determined according to the post-anti-shake rule based on the anti-shake time threshold and the affinity value.
7. The click stabilization method according to any one of claims 1 to 6, characterized in that: The click anti-shake method further includes: When the target method is called, parsing the first click attribute declared in the extensible markup language layout file; When the second click attribute of the target method is the same as the first click attribute, the target method is determined to be the preset anti-shake object.
8. A click anti-shake device, characterized in that: include: A method detection unit is used to detect the target method through the aspect class annotation of the aspect-oriented programming framework when the target method is called, and determine whether the target method is a preset anti-shake object; a parameter acquisition unit, configured to acquire target anti-shake parameters when the target method is the preset anti-shake object; A method execution unit is used to determine whether to execute the target method according to the target anti-shake parameter.
9. An electronic device comprising: A memory and a processor, wherein the processor is configured to implement the steps of the click anti-shake method according to any one of claims 1 to 7 when executing a computer program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the click anti-shake method according to any one of claims 1 to 7 are implemented.