Method and device for determining that component enters and exits from stack, electronic equipment and storage medium

By judging the properties of the Fragment, only performing stack or stack operation when it is not released or stacked is not released, the problem of repeated loading of Fragment in the Android system is solved, and the memory management and responsiveness of electronic devices is improved.

CN119201322APending Publication Date: 2024-12-27GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411360831.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-27
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In Android system development, the difficulty in judging the entry and exit of Fragment leads to the possibility of duplicate loading problems, affecting the memory usage and responsiveness of electronic devices.

Method used

By obtaining the properties of the current component and target component, we can determine whether the Fragment is in and out of the stack, and only perform stack or stack operations without stacking or not, avoid repeated loading, reduce memory usage and improve responsiveness.

Benefits of technology

It realizes accurate and efficient identification of Fragment, avoids duplicate loading, reduces unexpected situations during component switching, and improves user experience and device responsiveness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201322A_ABST
    Figure CN119201322A_ABST
Patent Text Reader

Abstract

The invention provides a method and device for determining that a component enters and exits a stack, electronic equipment and a storage medium, the method is applied to the technical field of computers, and the method comprises the steps that in response to a component switching operation on a display interface, component attributes of a current component displayed on the display interface and component attributes of a target component are obtained; according to the component attribute of the current component and the component attribute of the target component, whether the initial component goes out of a stack or whether the target component goes into the stack is judged; and under the condition that the initial component is not out of the stack, executing a stack-out operation on the initial component and displaying the target component on the display interface, or under the condition that the target component is not in the stack, executing a stack-in operation on the target component and displaying the target component on the display interface. According to the method, the out-of-stack operation or the in-stack operation can be executed on the Fragment only when the Fragment is not out of the stack or not in the stack, so that the problem that the Fragment repeatedly enters and exits the stack is avoided, the memory occupation of the electronic equipment is reduced, and the responsiveness of the electronic equipment can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a method, device, electronic device and storage medium for determining whether a component enters or exits a stack in the field of computer technology. Background Art

[0002] Currently, in the development process of Android system, all user interfaces (UI) are managed by Activity. However, since Activity manages a complete page, it is difficult to dynamically add or remove part of the UI, resulting in poor flexibility of Activity in managing UI.

[0003] Based on this problem, Fragment was introduced in the development of the Android system. Fragment allows developers to split complex UI into smaller and more independent modules, which can be dynamically added, removed or replaced, making UI switching more flexible.

[0004] When using the above Fragment, it is impossible to determine whether the current Fragment has entered or exited the stack, which may cause the problem of repeated loading of the Fragment. Summary of the invention

[0005] The present application provides a method, device, electronic device and storage medium for determining whether a component enters or exits a stack. The method can determine whether a fragment enters or exits a stack when switching fragments. Only when the fragment is not popped out of the stack or not pushed into the stack, a pop operation or a push operation is performed on the fragment, thereby avoiding the problem of repeated entry and exit of the fragment, reducing the memory usage of the electronic device, and effectively improving the responsiveness of the electronic device.

[0006] In a first aspect, a method for determining whether a component is put into or taken out of a stack is provided, the method comprising: in response to a component switching operation on a display interface, obtaining component properties of a current component displayed on the display interface, and component properties of a target component corresponding to the component switching operation, the current component being the target component or the initial component before switching, and the component properties being used to represent the identification, type, and storage location of the component; judging whether the initial component is popped out of the stack or whether the target component is pushed into the stack based on the component properties of the current component and the component properties of the target component; if the initial component is not popped out of the stack, performing a pop operation on the initial component and displaying the target component on the display interface, or, if the target component is not pushed into the stack, performing a push operation on the target component and displaying the target component on the display interface.

[0007] In the above technical scheme, in the process of user switching components, the embodiment of the present application proposes a method for determining whether a component enters and exits the stack. When the electronic device receives a component switching operation, the component attributes of the current component displayed on the display interface and the component attributes of the target component indicated by the component switching operation can be obtained. The electronic device determines whether the initial component is out of the stack or whether the target component is stacked according to the component attributes of the current component and the component attributes of the target component. In this application, since the component attributes of each component are unique. Therefore, according to the component attributes of the current component and the component attributes of the target component, it is possible to accurately determine whether the current component is specifically the initial component or the target component, so as to determine whether the initial component is out of the stack or whether the target component is stacked, thereby realizing accurate and efficient identification of the component entry and exit. When the initial component is not out of the stack or the target component is not stacked, the electronic device displays the target component, which can avoid repeated loading of the target component, reduce the space occupied by the component, reduce the probability of occurrence of unexpected conditions during the component switching process, and increase the responsiveness of the electronic device. In addition, based on the above method, even if the user performs the component switching operation for multiple times in a row during the component switching process, the target component will not be loaded all the time, which improves the user experience.

[0008] In combination with the first aspect, in some possible implementations, before determining whether the initial component is popped or the target component is pushed into the stack based on the component properties of the current component and the component properties of the target component, the method also includes: determining a type of the component switching operation, the type of the component switching operation being used to represent a component switching mode corresponding to the component switching operation; and determining whether the initial component is popped or the target component is pushed into the stack based on the component properties of the current component and the component properties of the target component, including: when the type of the component switching operation is a forward type, determining whether the target component is pushed into the stack based on the component properties of the current component and the component properties of the target component; or, when the type of the component switching operation is a backward type, determining whether the initial component is popped or the stack based on the component properties of the current component and the component properties of the target component.

[0009] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the component attributes include a component class name and a component tag, and the determination of whether the target component is pushed into the stack based on the component attributes of the current component and the component attributes of the target component includes: determining whether the current component is the target component based on the component tag of the current component and the component class name of the target component; if the current component is the target component, determining that the target component has been pushed into the stack; if the current component is not the target component, determining that the target component has not been pushed into the stack.

[0010] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the component attributes include a component class name and a component tag, and the determination of whether the initial component is popped is made based on the component attributes of the current component and the component attributes of the target component, including: determining whether the current component is the target component based on the component tag of the current component and the component class name of the target component; if the current component is the target component, determining that the initial component has been popped; if the current component is not the target component, determining that the initial component has not been popped.

[0011] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the determining whether the current component is the target component based on the component tag of the current component and the component class name of the target component includes: determining whether the component tag of the current component and the component class name of the target component are the same; when the component tag of the current component and the component class name of the target component are the same, determining that the current component is the target component; when the component tag of the current component and the component class name of the target component are different, determining that the current component is not the target component.

[0012] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, when the initial component has not been popped out of the stack, a pop operation is performed on the initial component and the target component is displayed on the display interface, or, when the target component has not been pushed into the stack, a push operation is performed on the target component and the target component is displayed on the display interface, including: when the initial component has not been popped out of the stack, the component transaction record of the initial component is removed from the back stack, and the view state of the target component is configured to be displayed so that the display interface displays the target component; when the target component has not been pushed into the stack, a component transaction record of the target component is generated according to the component switching operation; the component transaction record of the target component is added to the back stack, and the view state of the target component is configured to be displayed so that the display interface displays the target component.

[0013] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the component attributes include a component class name and a component tag, and before the component attributes of the current component displayed on the display interface and the component attributes of the target component corresponding to the component switching operation are obtained in response to a component switching operation on the display interface, the method also includes: for any preset component among multiple preset components, configuring the component tag of the preset component to the component class name of the preset component; and, in response to the component switching operation on the display interface, obtaining the component attributes of the current component displayed on the display interface, including: in response to the component switching operation, obtaining the navigation destination of the current component; obtaining the component attributes of the current component according to the navigation destination of the current component; obtaining the navigation destination of the target component; and obtaining the component attributes of the target component according to the navigation destination of the target component.

[0014] In the above technical solution, before determining whether a component enters or exits the stack, the component tag of each component is pre-configured as the component class name in this application, that is, the component tag and component class name of each component are the same. The above process provides a basis for subsequent judgment of whether a component enters or exits the stack. Unlike the component class name, since the component tag does not need to be hard-coded and has flexible configuration, configuring the component tag will not affect the operation of the code. When judging whether the current component is the target component based on the component tag of the current component and the component class name of the target component, since the component attributes of each component are unique, that is, the component tag and component class name of each component are also unique. Therefore, it is provided to compare the component tag of the current component with the component class name of the target component, so that it can quickly determine whether the component enters or exits the stack without affecting the operation of the application.

[0015] In a second aspect, a device for determining whether a component enters or exits a stack is provided, the device comprising: an attribute acquisition module, for acquiring, in response to a component switching operation on a display interface, component attributes of a current component displayed on the display interface, and component attributes of a target component corresponding to the component switching operation, the current component being the target component or the initial component before switching, the component attributes being used to indicate the component's identification, type, and storage location; an in-and-out stack judgment module, for judging whether the initial component is to be popped out of the stack or whether the target component is to be pushed into the stack based on the component attributes of the current component and the component attributes of the target component; a component display module, for performing a pop operation on the initial component and displaying the target component on the display interface if the initial component has not been popped out of the stack, or performing a push operation on the target component and displaying the target component on the display interface if the target component has not been pushed into the stack.

[0016] In combination with the second aspect, in some possible implementations, before judging whether the initial component is popped out of the stack or whether the target component is pushed into the stack based on the component attributes of the current component and the component attributes of the target component, the device also includes: an operation type determination module, used to determine the type of the component switching operation, the type of the component switching operation is used to indicate the component switching mode corresponding to the component switching operation; and the stack entry and exit judgment module is specifically used to: when the type of the component switching operation is a forward type, judge whether the target component is pushed into the stack based on the component attributes of the current component and the component attributes of the target component; or, when the type of the component switching operation is a backward type, judge whether the initial component is popped out of the stack based on the component attributes of the current component and the component attributes of the target component.

[0017] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the component attributes include a component class name and a component tag, and the stack entry and exit judgment module is also used to: determine whether the current component is the target component based on the component tag of the current component and the component class name of the target component; if the current component is the target component, determine that the target component has been pushed into the stack; if the current component is not the target component, determine that the target component has not been pushed into the stack.

[0018] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the component attributes include a component class name and a component tag, and the stack entry and exit judgment module is also used to: determine whether the current component is the target component based on the component tag of the current component and the component class name of the target component; if the current component is the target component, determine that the initial component has been popped out of the stack; if the current component is not the target component, determine that the initial component has not been popped out of the stack.

[0019] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the stack entry and exit judgment module is also used to: determine whether the component label of the current component and the component class name of the target component are the same; when the component label of the current component and the component class name of the target component are the same, determine that the current component is the target component; when the component label of the current component and the component class name of the target component are different, determine that the current component is not the target component.

[0020] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the component display module is specifically used to: when the initial component has not been popped out of the stack, remove the component transaction record of the initial component from the back stack, and configure the view state of the target component to display so that the display interface displays the target component; when the target component has not been pushed into the stack, generate a component transaction record of the target component according to the component switching operation; add the component transaction record of the target component to the back stack, and configure the view state of the target component to display so that the display interface displays the target component.

[0021] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the component attributes include a component class name and a component tag. Before the component attributes of the current component displayed on the display interface and the component attributes of the target component corresponding to the component switching operation are obtained in response to a component switching operation on the display interface, the device also includes: a configuration module for configuring the component tag of any preset component among multiple preset components to the component class name of the preset component; and the attribute acquisition module is specifically used to: in response to the component switching operation, obtain the navigation destination of the current component; obtain the component attributes of the current component according to the navigation destination of the current component; obtain the navigation destination of the target component; and obtain the component attributes of the target component according to the navigation destination of the target component.

[0022] In a third aspect, an electronic device is provided, comprising a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the electronic device executes the method in the first aspect or any possible implementation of the first aspect.

[0023] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.

[0024] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a schematic diagram of a component switching scenario provided by an embodiment of the present application;

[0026] Figure 2is a schematic flow chart of a method for determining whether a component enters or exits a stack provided by an embodiment of the present application;

[0027] Figure 3 is a schematic flow chart of another method for determining whether a component enters or exits a stack provided by an embodiment of the present application;

[0028] Figure 4 It is a structural schematic diagram of a device for determining whether a component enters or exits a stack provided by an embodiment of the present application;

[0029] Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0031] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.

[0032] Before introducing the method of the embodiment of the present application, the professional terms that may be involved in the embodiment of the present application are first explained.

[0033] Activity: In the Android system, Activity is one of the basic components of an application. It represents a screen for interaction with the user. An Activity usually represents a separate screen, including various UI elements, allowing users to perform specific tasks or view specific information. The main functions of Activity include providing UI, life cycle management, and communicating with other Activities.

[0034] Fragment: A reusable component in the Android system that represents a part of the user interface. Fragments are usually used to build complex user interfaces. The relationship between Fragments and Activities is that Activities are containers for Fragments, an Activity can contain one or more Fragments, and one or more Fragments can be embedded in an Activity to build a more dynamic and flexible user interface.

[0035] Navigation: In Android development, Navigation refers to the navigation logic between screens within an application. It involves how to jump from one screen to another. It is used to manage the navigation logic between Fragments and the jump between Fragments.

[0036] Navigation Graph (Nav Graph): An Extensible Markup Language (XML) file, which is the core component of Navigation. It defines the destination and navigation path (Action) of the navigation in the application. Each destination usually corresponds to a Fragment or an Activity, and the navigation path defines how to navigate from one destination to another. The Navigation Graph file contains two parts: NavDestination and action.

[0037] Navigation Destination (Nav Destination): An interface in Navigation that represents a location that can be navigated to. Nav Graph contains multiple Nav Destinations. Specifically, Nav Graph defines the path from one Nav Destination to another.

[0038] Generally, a Nav Destination corresponds to a Fragment, and the Nav Destination contains some key information of the corresponding Fragment, such as the identity document (ID), name, label, and layout file path (tools:layout).

[0039] Action: describes the path from one Nav Destination to another Nav Destination. Each Action corresponds to a unique ID.

[0040] Back Stack: used to manage the navigation history between Fragments. The main function of the back stack is to save the user's navigation history and ensure that the user can undo the most recent navigation operation by pressing the back button.

[0041] Specifically, in Navigation, Nav Controller is responsible for managing the back stack. The back stack is characterized by Last In First Out (LIFO), which means that the last data item pushed into the stack is taken out first.

[0042] Push (also called "push"): refers to adding a fragment to the back stack. When the user navigates from one fragment to another, the current fragment is automatically added to the back stack, which means that if the user then presses the back key, the current display interface can return to the previous fragment.

[0043] Pop: refers to removing a fragment from the back stack. When the user presses the back key, the current fragment will be removed from the back stack and restored to the previous fragment.

[0044] Full path: refers to the complete path from the root directory to a specific file or directory, including all intermediate directories and the final target file or directory name. In the embodiment of the present application, the full path of a Fragment specifically refers to the full class name of the Fragment, which refers to the Java or Kotlin name that defines the Fragment, that is, the Name of the Fragment in the above NavDestination.

[0045] The application scenarios of the embodiments of the present application are introduced below.

[0046] Figure 1 It is a schematic diagram of a component switching scenario provided in an embodiment of the present application.

[0047] For example, Figure 1 As shown in (a), the display area of ​​the current electronic device displays a display interface 1, that is, an Activity. The current display interface 1 includes three fragments, namely, operation controls corresponding to each of Fragment A, Fragment B and Fragment C.

[0048] When the user selects the operation control corresponding to "Fragment A" through a selection operation, the electronic device can display the content corresponding to Fragment A in the display area in response to the operation.

[0049] like Figure 1 As shown in (b), when the user needs to view the content of other Fragments, the user can also select the operation control corresponding to Fragment B. In response to the operation, the electronic device can display the content of Fragment B in the display interface 1.

[0050] In the above process of switching from Fragment A to Fragment B, the electronic device will perform a stacking operation on Fragment B based on the user's click operation. That is, Fragment B that needs to be displayed in display interface 1 will be automatically added to the back stack, making Fragment B the last fragment added in the back stack, so that the content of Fragment B is displayed on display interface 1.

[0051] Correspondingly, when the user needs to view the content of Fragment A, the user can control the electronic device to return from Fragment B to Fragment A through the "return" control (not shown in the figure) in the display interface 1. In this process, the electronic device performs a pop operation on Fragment B, and the original Fragment B will be successfully removed from the back stack, making Fragment A the last Fragment pushed into the back stack, so that the display interface 1 can display Fragment A.

[0052] In one possible implementation, when the user needs to view the content of Fragment B, he or she may click the control corresponding to "Fragment B" multiple times. In this case, when the electronic device switches from Fragment A to Fragment B, the electronic device may perform multiple stacking operations on Fragment B. Repeated stacking not only increases the memory space occupied by the electronic device, but may also cause the electronic device to freeze or become unresponsive, reducing the user experience.

[0053] Based on the above problems, an embodiment of the present application proposes a method for determining whether a component enters or exits a stack. The method can determine whether a fragment enters or exits a stack when switching fragments. Only when the fragment is not popped out of the stack or not pushed into the stack, a pop operation or a push operation is performed on the fragment, thereby avoiding the problem of repeated entry and exit of the fragment and reducing the memory usage of the electronic device.

[0054] Figure 2 1 is a schematic flow chart of a method for determining whether a component enters or exits a stack provided in an embodiment of the present application. It should be understood that the method can be applied to any electronic device.

[0055] For example, Figure 2 As shown, the method 200 includes:

[0056] 201. In response to a component switching operation on a display interface, component properties of a current component displayed on the display interface and component properties of a target component corresponding to the component switching operation are obtained. The current component is a target component or an initial component before switching. The component properties are used to represent the component's identification, type, and storage location.

[0057] The above-mentioned component refers to Fragment, and the component switching operation refers to the switching operation between Fragments.

[0058] Generally, electronic devices are installed with applications with different functions. For any of these applications, users can configure in the display area to make the electronic device display any application interface of the application, which can be regarded as an Activity. Among them, the Activity may contain one or more Fragments. Users can select different Fragments by clicking, so that the electronic device can display the content of different Fragments accordingly.

[0059] For example, suppose that a shopping application is installed in an electronic device. When a user opens the shopping application, the electronic device displays a shopping page. The shopping page includes two fragments: a product list fragment and a product detail fragment. Assume that the default displayed fragment on the shopping page is the product list fragment.

[0060] When the user clicks on a product in the product list fragment, the electronic device switches the currently displayed fragment from the Product List Fragment to the Product Detail Fragment, that is, adds the Product Detail Fragment to the back stack and displays the details of the currently selected product.

[0061] On the contrary, after adding the Product Detail Fragment to the back stack, if the user clicks the back control, the electronic device switches the currently displayed fragment from the Product Detail Fragment to the Product List Fragment, that is, removes the Product Detail Fragment from the back stack, so that the Product List Fragment is redisplayed.

[0062] Thus, through the above-mentioned component switching operation, the electronic device can display the contents of different components on the current display interface.

[0063] Optionally, component switching operations can be divided into forward type and backward type according to their types, and the above two operations correspond to the push and pop processes of components respectively. Specifically, when the type of component switching operation is forward type, it means that the user moves forward from one component to a new component, corresponding to the push process of the new component; when the type of component switching operation is backward type, it means that the current component rolls back to the previous component, corresponding to the pop process of the current component.

[0064] For example, in the embodiment of the present application, for the type of component switching operation, the corresponding methods in the Navigation framework are different. The method corresponding to the forward type is the navigate() method of the Nav Controller. The method corresponding to the backward type is the popBackStack() or navigateUp() method of the Nav Controller.

[0065] Therefore, after receiving a component switching operation, the electronic device can determine the type of the current component switching operation by acquiring relevant information of the NavController.

[0066] It should be understood that in the embodiment of the present application, the Fragment before switching is recorded as the "initial component"; and the Fragment after switching is recorded as the "target component".

[0067] The following briefly introduces the component switching process according to the different types of component switching operations.

[0068] In the first case, if the type of the component switching operation is a forward type, assuming that the initial component is Fragment A and the target component is Fragment B. After receiving the component switching operation, the electronic device can add Fragment B to the back stack and display the corresponding content of Fragment B on the display interface. In this process, the component switching operation is used to enable the electronic device to perform a push operation on the target component Fragment B (target component).

[0069] In the second case, when Fragment B has been pushed into the stack, if the type of the component switching operation is a back type, the initial component is Fragment B and the target component is Fragment A. Then, after the electronic device receives the component switching operation, Fragment B can be removed from the back stack so that the display interface displays the content of Fragment A. In this process, the component switching operation is used to cause the electronic device to perform a pop operation on the initial component Fragment B (initial component).

[0070] Regardless of the above component popping or pushing, in the embodiment of the present application, in order to avoid repeated popping or pushing operations on the same component, each time the electronic device needs to push or pop the component, it can be determined whether the current component has been popped or pushed.

[0071] Combined with the above, it can be known that each Fragment corresponds to a unique Nav Destination. The Nav Destination contains the Fragment's ID, Name (i.e. class name), Label and tools:layout. When determining whether a component has been popped or stacked, the embodiment of the present application can be implemented based on the above key information in the navigation destination corresponding to each Fragment.

[0072] The above component properties refer to the Nav Destination of the Fragment.

[0073] Optional, component attributes specifically refer to the Fragment's Label and name.

[0074] Specifically, when using Nav Destination to determine whether a component is popped or pushed into the stack, it can be implemented based on the Label of each Fragment. The reason is: if you use Name or ID to find Fragment, you need to hardcode this information in the code. If the Name or ID changes, the technician needs to update all the places involving this information in all the codes, which is prone to errors and has a large workload. However, since Label can be freely configured, it will not affect the operation of the code layer and can reduce potential errors caused by changes.

[0075] When using Lable to determine whether a component is pushed into or out of the stack, you can first configure the Lable of each Fragment.

[0076] In a possible implementation, in response to a component switching operation on the display interface, before obtaining component properties of a current component displayed on the display interface and component properties of a target component corresponding to the component switching operation, the method further includes:

[0077] For any preset component among the multiple preset components, the component tag of the preset component is configured to be the component class name of the preset component.

[0078] For each Fragment, the technician can configure the Label of each Fragment as the full path of the Fragment, that is, the class name. Since the full class name of each Fragment is unique, when judging whether a component is pushed into or out of the stack, it is only necessary to compare whether the Label of the component displayed in the current display interface is consistent with the class name of the target component, and then it can be determined whether the component displayed in the current display interface and the target component are the same component, so as to determine whether the component is successfully pushed into or out of the stack.

[0079] For example, for a Fragment, the corresponding Nav Destination has the following specific form:

[0080] <fragment

[0081] android:id="@+id / fragmentA"

[0082] android:name="com.xxxxxxx.app.FragmentA"

[0083] android:label="com.xxxxxxx.app.FragmentA"

[0084] tools:layout="@layout / fragment_a">

[0085] As shown in the example, in the embodiment of the present application, the technician can configure the naem and label of any Fragment to be the same.

[0086] In the above technical solution, before determining whether a component enters or exits the stack, the component tag of each component is pre-configured as the component class name in this application, that is, the component tag and component class name of each component are the same. The above process provides a basis for subsequent judgment of whether a component enters or exits the stack. Unlike the component class name, since the component tag does not need to be hard-coded and has flexible configuration, configuring the component tag will not affect the operation of the code. When judging whether the current component is the target component based on the component tag of the current component and the component class name of the target component, since the component attributes of each component are unique, that is, the component tag and component class name of each component are also unique. Therefore, it is provided to compare the component tag of the current component with the component class name of the target component, so that it can quickly determine whether the component enters or exits the stack without affecting the operation of the application.

[0087] After the Fragment's Lable configuration is completed, the electronic device can obtain the component properties of the current component displayed on the display interface and the component properties of the target component after detecting the component switching operation to determine whether the current component is the target component to be displayed.

[0088] In a possible implementation, in response to a component switching operation on a display interface, obtaining component properties of a current component displayed on the display interface and component properties of a target component corresponding to the component switching operation includes:

[0089] In response to a component switching operation, obtaining a navigation destination of the current component;

[0090] Get the component properties of the current component according to the navigation destination of the current component;

[0091] Get the navigation destination of the target component;

[0092] Gets the component properties of the target component according to the navigation destination of the target component.

[0093] Optionally, the component switching operation may be performed once or multiple times. The embodiment of the present application does not limit the number of times a user performs the component switching operation.

[0094] Among them, the component attribute of the current component specifically refers to the component label of the current component, that is, label; the component attribute of the target component specifically refers to the component class name of the target component, that is, name.

[0095] Based on the difference in the number of executions of the above component switching operation, the above current component may be the initial component or the target component. If the current component is the initial component, it means that the target component has not been added to the back stack or the initial component has not been removed from the back stack, and the target component has not been displayed on the interface; on the contrary, if the current component is the target component, it means that the target component has been added to the back stack or the initial component has been removed from the back stack, and the target component has been displayed on the interface.

[0096] Exemplarily, if the type of component switching operation is a forward type, take the initial component as Fragment A and the target component as Fragment B. When the electronic device detects the component switching operation, assuming that the user has only clicked once, the electronic device can perform a stacking operation on Fragment B in response to the operation and display Fragment B on the display interface. If the user clicks multiple times in succession, when Fragment B has been displayed on the display interface for the first time, each subsequent click operation is actually equivalent to the electronic device continuously switching from Fragment B to Fragment B. Therefore, in the non-first click process, the display interface always displays Fragment B, that is, the current component and the target component are always Fragment B. Therefore, in this case, based on the uniqueness of the Fragment's Nav Destination, the component label of the current component and the component class name of the target component obtained are the same, indicating that Fragment B has been pushed into the stack.

[0097] Therefore, based on the component attributes of the current component and the component attributes of the target component, the electronic device can determine whether the component is popped or pushed into the stack.

[0098] Exemplarily, for the component properties of the current component, when the electronic device detects a component switching operation by the user, the NavDestination of the current Fragment can be obtained through the Nav Controller.

[0099] The specific code examples are as follows:

[0100] Get the navigation destination of the current component: NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host_fragment); NavDestination currentDestination = navController.getCurrentDestination();

[0101] The component attribute of the current component is specifically the component label, so the electronic device can obtain the label of the current component based on the NavDestination of the current component. The specific code example is as follows:

[0102] String currentComponentLabel=currentDestination.getLabel();

[0103] For example, the component properties of the target component can be obtained through the Action of the target component. The specific code example is as follows:

[0104] Assuming that the Action ID corresponding to the target component is R.id.action_fragmentA_to_fragmentB, the process of obtaining the component properties of the target component can be expressed as: NavDestination targetDestination = navController.getGraph().getDestination(R.id.fragmentB);

[0105] After obtaining the NavDestination of the target component, the electronic device can obtain the component class name of the target component from it. The specific code example is as follows:

[0106] String targetComponentClassName=targetDestination.getClassName();

[0107] Thus, through the above process, the electronic device can obtain the component attributes of the current component and the component attributes of the target component, specifically, the component label of the current component and the component type of the target component.

[0108] 202 , judging whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component.

[0109] After obtaining the component attributes of the current component and the component attributes of the target component in step 201, the type of component switching operation determines whether the electronic device performs a push operation or a pop operation on the component. Therefore, before determining whether the component is pushed or popped, the electronic device can first determine whether the current display process corresponds to the push or pop operation of the component according to the component switching operation, and determine the specific component corresponding to the push or pop operation.

[0110] In a possible implementation, before determining whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component, the method further includes:

[0111] Determine the type of the component switching operation, where the type of the component switching operation is used to indicate the component switching mode corresponding to the component switching operation;

[0112] And, judging whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component, including:

[0113] When the type of the component switching operation is the forward type, judging whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component; or,

[0114] When the type of the component switching operation is the back type, it is determined whether the initial component is popped out of the stack according to the component attributes of the current component and the component attributes of the target component.

[0115] As can be seen from the above, the types of component switching operations include forward type and backward type. The specific acquisition method is introduced in the above process and will not be repeated here.

[0116] When the type of component switching operation is a forward type, it corresponds to the stacking process of the target component. Therefore, the electronic device can determine whether the target component is stacked according to the component attributes of the current component and the component attributes of the target component; on the contrary, when the type of component switching operation is a backward type, it corresponds to the stacking process of the initial component. Therefore, the electronic device can determine whether the initial component is stacked according to the component attributes of the current component and the component attributes of the target component.

[0117] The process of determining whether the target component is pushed into the stack is as follows.

[0118] In a possible implementation, judging whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component includes:

[0119] Determine whether the current component is the target component according to the component tag of the current component and the component class name of the target component;

[0120] When the current component is the target component, it is determined that the target component has been pushed into the stack;

[0121] When the current component is not the target component, it is determined that the target component is not stacked.

[0122] It should be understood that based on the uniqueness of the class name of each Fragment, the embodiment of the present application pre-configures the component tag of each Fragment to be the same as the class name. Therefore, after obtaining the component tag of the current component and the component class name of the target component, the electronic device can determine whether the component tag and the component class name are the same, so as to determine whether the current component and the target component are the same component.

[0123] In a possible implementation, determining whether the current component is the target component according to the component tag of the current component and the component class name of the target component includes:

[0124] Determine whether the component tag of the current component and the component class name of the target component are the same;

[0125] When the component label of the current component is the same as the component class name of the target component, the current component is determined to be the target component;

[0126] When the component tag of the current component and the component class name of the target component are different, it is determined that the current component is not the target component.

[0127] Specifically, when determining whether the component tag of the current component and the component class name of the target component are the same, the String.equals() method is used to implement it.

[0128] The specific comparison code examples are as follows:

[0129] {if(currentComponentLabel!=null&&targetComponentClassName!=null&¤tComponentLabel.equals(targetComponentClassName));

[0130] returu true;

[0131] else,

[0132] return false};

[0133] When the electronic device determines that the component label of the current component is the same as the component class name of the target component, it means that the current component is the target component, indicating that the target component has been stacked; on the contrary, when the electronic device determines that the component label of the current component is different from the component class name of the target component, it means that the current component is not the target component, the current component is the initial component, indicating that the target component has not yet been stacked.

[0134] Correspondingly, the process of determining whether the initial component is popped is as follows.

[0135] In a possible implementation, judging whether the initial component is to be popped out of the stack according to the component attributes of the current component and the component attributes of the target component includes:

[0136] Determine whether the current component is the target component according to the component tag of the current component and the component class name of the target component;

[0137] When the current component is the target component, determining that the initial component has been popped out of the stack;

[0138] When the current component is not the target component, it is determined that the initial component is not popped out of the stack.

[0139] Similarly, when judging whether the initial component is popped out of the stack, the same method is used to determine whether the component tag of the current component is the same as the component class name of the target component.

[0140] When the electronic device determines that the component label of the current component is the same as the component class name of the target component, it means that the current component is the target component, indicating that the initial component has been popped out of the stack; on the contrary, when the electronic device determines that the component label of the current component is different from the component class name of the target component, it means that the current component is not the target component, the current component is the initial component, indicating that the initial component has not yet been popped out of the stack.

[0141] Thus, through the above method, when the electronic device needs to switch the displayed component, it can determine whether the target component is stacked or whether the initial component is popped according to the type of component switching operation.

[0142] 203 , when the initial component has not been popped out of the stack, perform a pop operation on the initial component and display the target component on the display interface, or, when the target component has not been pushed into the stack, perform a push operation on the target component and display the target component on the display interface.

[0143] In one case, when the electronic device determines that the initial component has not been popped out of the stack or the target component has not been pushed into the stack, the electronic device can perform a pop operation on the initial component to make the display device display the target component. Alternatively, the electronic device performs a push operation on the target component to make the display interface display the target component.

[0144] In a possible implementation, when the initial component is not popped out of the stack, performing a pop operation on the initial component and displaying the target component on the display interface, or, when the target component is not pushed into the stack, performing a push operation on the target component and displaying the target component on the display interface, includes:

[0145] If the initial component is not popped out of the stack, the component transaction record of the initial component is removed from the back stack, and the view state of the target component is configured to be displayed, so that the display interface displays the target component;

[0146] When the target component is not pushed into the stack, a component transaction record of the target component is generated according to the component switching operation; the component transaction record of the target component is added to the back stack, and the view state of the target component is configured to display so that the display interface displays the target component.

[0147] Specifically, the back stack mainly stores the transaction record of each component, which refers to the state information of each navigation destination saved in the back stack. The transaction record of each component is automatically generated when the user performs navigation operations. When the user uses the Nav Controller to navigate or operate, the electronic device will automatically record the component transactions during the navigation process into the back stack.

[0148] For example, when a user navigates to a new destination using the Nav Controller.navigate() method, the system creates a new transaction record and adds it to the back stack. Conversely, when the user presses the back button or calls the Nav Controller.popBackStack() method, the current destination is removed from the back stack and restored to the destination corresponding to the previous transaction record.

[0149] When the target component is not pushed into the stack, the electronic device can create a new transaction record, namely, the component transaction record of the target component, according to the component switching operation (ie, the NavController.navigate() method), and add it to the back stack, and configure the view state of the component to be displayed (or visible) so that the view of the target component is displayed in the display interface.

[0150] When the initial component is not popped out of the stack, the electronic device can call the Nav Controller.getCurrentBackStackEntry() method to obtain the component transaction record of the current initial component and remove the component transaction record. From then on, the component transaction record of the target component becomes the last component transaction record in the back stack. At the same time, since the view state of the target component may be configured to be replaced or hidden during the initial component display process, when the previous target component needs to be redisplayed, the electronic device can also configure the view state of the target component to be displayed (or visible) so that the view of the target component is displayed in the display interface.

[0151] In another scenario, when the electronic device determines that the initial component has been popped out of the stack, or the target component has been pushed into the stack, the push operation is no longer performed on the target component, or the pop operation is performed on the initial component.

[0152] Thus, the present application proposes a method for determining whether a component is in and out of a stack through the above process, in the process of user switching components, when the electronic device receives a component switching operation, the component attributes of the current component displayed on the display interface and the component attributes of the target component indicated by the component switching operation can be obtained. The electronic device determines whether the initial component is out of the stack or whether the target component is stacked according to the component attributes of the current component and the component attributes of the target component. In the present application, since the component attributes of each component are unique. Therefore, according to the component attributes of the current component and the component attributes of the target component, it is possible to accurately determine whether the current component is specifically the initial component or the target component, so as to determine whether the initial component is out of the stack or whether the target component is stacked, thereby realizing accurate and efficient identification of the component in and out of the stack. When the initial component is not out of the stack or the target component is not stacked, the electronic device displays the target component, which can avoid repeated loading of the target component, reduce the space occupied by the component, reduce the probability of occurrence of unexpected conditions during the component switching process, and increase the responsiveness of the electronic device. In addition, based on the above method, even if the user performs the component switching operation for multiple times in a row during the component switching process, the target component will not be loaded all the time, which improves the user experience.

[0153] In order to facilitate understanding of the process of the embodiment of the present application, Figure 3 The method of the embodiment of the present application is introduced in detail.

[0154] Figure 3 It is a schematic flowchart of another method for determining whether components are stacked or not provided in an embodiment of the present application.

[0155] For example, Figure 3 As shown, the method 300 includes:

[0156] 301. In response to a component switching operation on a display interface, component properties of a current component displayed on the display interface and component properties of a target component corresponding to the component switching operation are obtained. The current component is a target component or an initial component before switching. The component properties are used to represent the identification, type and storage location of the component.

[0157] 302. Determine the type of the component switching operation.

[0158] When the type of the component switching operation is a forward type, steps 303 to 305 are executed.

[0159] When the type of the component switching operation is a back-off type, steps 306 to 308 are executed.

[0160] 303. Determine whether the target component is pushed into the stack (whether the current component is the target component) according to the component attributes of the current component and the component attributes of the target component.

[0161] When the target component is stacked, execute step 304;

[0162] When the target component is not pushed into the stack, step 305 is executed.

[0163] 304: Do not push the target component into the stack.

[0164] 305, perform a push operation on the target component.

[0165] 306 , determining whether the initial component is popped out of the stack (whether the current component is the target component or the initial component) according to the component attributes of the current component and the component attributes of the target component.

[0166] When the initial component is not popped out of the stack, execute step 307;

[0167] When the target component is popped out of the stack, step 308 is executed.

[0168] 307, perform a pop operation on the target component.

[0169] 308, do not perform a pop operation on the target component.

[0170] 301-308 in the above method 300 and 201-203 in the method 200 have the same inventive concept. Please refer to the introduction in the above method 200 for details, which will not be repeated here.

[0171] Figure 4 It is a structural schematic diagram of a device for determining whether components are stacked or not provided in an embodiment of the present application.

[0172] For example, Figure 4 As shown, the device 400 includes:

[0173] The attribute acquisition module 401 is used to respond to the component switching operation on the display interface, and acquire the component attribute of the current component displayed on the display interface, and the component attribute of the target component corresponding to the component switching operation, the current component is the target component or the initial component before switching, and the component attribute is used to indicate the identification, type and storage location of the component;

[0174] The stack entry and exit judgment module 402 is used to judge whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component;

[0175] The component display module 403 is used to perform a pop operation on the initial component and display the target component on the display interface when the initial component has not been popped, or to perform a push operation on the target component and display the target component on the display interface when the target component has not been pushed.

[0176] Optionally, before judging whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component properties of the current component and the component properties of the target component, the device also includes: an operation type determination module, used to determine the type of the component switching operation, the type of the component switching operation is used to indicate the component switching mode corresponding to the component switching operation; and the stack entry and exit judgment module 402 is specifically used to: when the type of the component switching operation is a forward type, judge whether the target component is pushed into the stack according to the component properties of the current component and the component properties of the target component; or, when the type of the component switching operation is a backward type, judge whether the initial component is popped out of the stack according to the component properties of the current component and the component properties of the target component.

[0177] In one possible implementation, the component attributes include a component class name and a component tag, and the stack entry and exit judgment module 402 is also used to: determine whether the current component is the target component based on the component tag of the current component and the component class name of the target component; if the current component is the target component, determine that the target component has been pushed into the stack; if the current component is not the target component, determine that the target component has not been pushed into the stack.

[0178] In one possible implementation, the component attributes include a component class name and a component tag, and the stack entry and exit judgment module 402 is also used to: determine whether the current component is the target component based on the component tag of the current component and the component class name of the target component; if the current component is the target component, determine that the initial component has been popped out of the stack; if the current component is not the target component, determine that the initial component has not been popped out of the stack.

[0179] In one possible implementation, the stack entry and exit judgment module 402 is also used to: determine whether the component label of the current component and the component class name of the target component are the same; if the component label of the current component and the component class name of the target component are the same, determine that the current component is the target component; if the component label of the current component and the component class name of the target component are different, determine that the current component is not the target component.

[0180] In one possible implementation, the component display module 403 is specifically used to: when the initial component has not been popped out of the stack, remove the component transaction record of the initial component from the back stack, and configure the view state of the target component to display so that the display interface displays the target component; when the target component has not been pushed into the stack, generate a component transaction record of the target component according to the component switching operation; add the component transaction record of the target component to the back stack, and configure the view state of the target component to display so that the display interface displays the target component.

[0181] Optionally, the component attributes include a component class name and a component tag. Before the device responds to a component switching operation on the display interface and obtains the component attributes of the current component displayed on the display interface and the component attributes of the target component corresponding to the component switching operation, the device also includes: a configuration module for configuring the component tag of any preset component among multiple preset components to be the component class name of the preset component; and the attribute acquisition module 401 is specifically used to: respond to the component switching operation, obtain the navigation destination of the current component; obtain the component attributes of the current component according to the navigation destination of the current component; obtain the navigation destination of the target component; and obtain the component attributes of the target component according to the navigation destination of the target component.

[0182] Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0183] For example, Figure 5 As shown, the electronic device 500 includes: a memory 501 and a processor 502, wherein the memory 501 stores an executable program code 5011, and the processor 502 is used to call and execute the executable program code 5011 to perform a method for determining whether a component enters or exits a stack.

[0184] In this embodiment, the electronic device can be divided into functional modules according to the above method example. For example, each functional module can be corresponded to, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0185] In the case of dividing each functional module according to each function, the electronic device may include: an attribute acquisition module, an in-and-out stack judgment module, and a component display module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.

[0186] The electronic device provided in this embodiment is used to execute the above method for determining whether a component enters or exits a stack, and thus can achieve the same effect as the above implementation method.

[0187] In the case of an integrated unit, the electronic device may include a processing module and a storage module. The processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device in executing related program codes and data.

[0188] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits shown in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0189] This embodiment also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement a method for determining the entry and exit of components in the above-mentioned embodiment.

[0190] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement a method for determining whether a component enters or exits a stack in the above-mentioned embodiment.

[0191] In addition, the electronic device provided in the embodiments of the present application may specifically be a chip, a component or a module, and the electronic device may include a connected processor and a memory; wherein the memory is used to store instructions, and when the electronic device is running, the processor may call and execute instructions so that the chip executes a method for determining the entry and exit of components in the stack in the above-mentioned embodiments.

[0192] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.

[0193] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0194] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0195] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for determining whether a component enters or leaves a stack, characterized in that: The method comprises: In response to a component switching operation on a display interface, obtaining a component attribute of a current component displayed on the display interface and a component attribute of a target component corresponding to the component switching operation, wherein the current component is the target component or an initial component before switching, and the component attribute is used to indicate an identifier, a type, and a storage location of the component; Determining whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component; When the initial component has not been popped out of the stack, a pop operation is performed on the initial component, and the target component is displayed on the display interface; or, when the target component has not been pushed into the stack, a push operation is performed on the target component and the target component is displayed on the display interface.

2. The method according to claim 1, characterized in that Before determining whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attribute of the current component and the component attribute of the target component, the method further includes: Determine a type of the component switching operation, where the type of the component switching operation is used to indicate a component switching mode corresponding to the component switching operation; And, judging whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attribute of the current component and the component attribute of the target component, comprises: In the case where the type of the component switching operation is a forward type, judging whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component; or In the case that the type of the component switching operation is a backward type, it is determined whether the initial component is popped out according to the component attributes of the current component and the component attributes of the target component.

3. The method according to claim 2, characterized in that The component attributes include a component class name and a component tag, and judging whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component includes: Determining whether the current component is the target component according to the component tag of the current component and the component class name of the target component; In a case where the current component is the target component, determining that the target component has been pushed into the stack; When the current component is not the target component, it is determined that the target component is not pushed into the stack.

4. The method according to claim 2, characterized in that: The component attributes include a component class name and a component tag, and judging whether the initial component is popped out of the stack according to the component attributes of the current component and the component attributes of the target component includes: Determining whether the current component is the target component according to the component tag of the current component and the component class name of the target component; In the case where the current component is the target component, determining that the initial component has been popped out of the stack; When the current component is not the target component, it is determined that the initial component is not popped out of the stack.

5. The method according to claim 3 or 4, characterized in that: The determining, according to the component tag of the current component and the component class name of the target component, whether the current component is the target component comprises: Determine whether the component tag of the current component and the component class name of the target component are the same; In a case where the component label of the current component is the same as the component class name of the target component, determining the current component to be the target component; When the component tag of the current component and the component class name of the target component are different, it is determined that the current component is not the target component.

6. The method according to claim 1, characterized in that The method of performing a pop operation on the initial component and displaying the target component on the display interface when the initial component has not been popped out of the stack, or performing a push operation on the target component and displaying the target component on the display interface when the target component has not been pushed into the stack, includes: In the case that the initial component is not popped out of the stack, the component transaction record of the initial component is removed from the rollback stack, and the view state of the target component is configured to be displayed, so that the display interface displays the target component; When the target component is not pushed into the stack, a component transaction record of the target component is generated according to the component switching operation; the component transaction record of the target component is added to the rollback stack, and the view state of the target component is configured to display so that the display interface displays the target component.

7. The method according to claim 1, characterized in that The component attributes include a component class name and a component tag. Before the component attributes of the current component displayed on the display interface and the component attributes of the target component corresponding to the component switching operation are acquired in response to the component switching operation on the display interface, the method further includes: For any preset component among the plurality of preset components, configuring the component tag of the preset component to be the component class name of the preset component; And, in response to the component switching operation on the display interface, obtaining the component properties of the current component displayed on the display interface includes: In response to the component switching operation, obtaining a navigation destination of the current component; According to the navigation destination of the current component, obtaining the component property of the current component; Obtaining the navigation destination of the target component; According to the navigation destination of the target component, a component property of the target component is obtained.

8. A device for determining the entry and exit of components, characterized in that: The device comprises: an attribute acquisition module, for, in response to a component switching operation on a display interface, acquiring a component attribute of a current component displayed on the display interface and a component attribute of a target component corresponding to the component switching operation, wherein the current component is the target component or an initial component before switching, and the component attribute is used to indicate an identifier, type and storage location of the component; A stack entry and exit judgment module, used to judge whether the initial component is popped out of the stack or whether the target component is pushed into the stack according to the component attributes of the current component and the component attributes of the target component; A component display module is used to perform a pop operation on the initial component and display the target component on the display interface when the initial component has not been popped, or to perform a push operation on the target component and display the target component on the display interface when the target component has not been pushed.

9. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.