Method, system and equipment for generating error view of application program and medium
By encapsulating configuration parameters for enumerated error types in an empty state view class, the generation of views for different error types can be handled uniformly, solving the problems of low development efficiency and high cost in existing technologies, and achieving code simplification and improved maintainability.
Patent Information
- Application Number
- CN202510781888.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-10-24
AI Technical Summary
The development efficiency and cost of generating application error views in the existing technology are low, mainly because layout resources and logic code need to be written separately for each error type.
By creating an enumeration class to define error types, encapsulating configuration parameters in an empty state view class, calling the binding function to determine the error type, and loading the corresponding configuration parameters to generate the view based on the type, a unified handling of multiple error types is achieved.
It simplifies code logic, improves code reusability and maintainability, reduces development costs, and improves development efficiency.
Smart Images

Figure CN120832133A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer software, and in particular to a method, system, device and medium for generating error views of an application. BACKGROUND
[0002] There are two typical implementation methods for the current mobile terminal development Empty State processing scheme. One is to use a unified layout file (such as a common template containing icons, titles, descriptions and operation buttons), and to dynamically control the visibility of each element (such as displaying / hiding icons or buttons) through code. The other is to write a layout file (XML) for each empty state (such as "no data", "no network" and "loading failure") separately, and to load the corresponding layout according to the state in the code.
[0003] Both of these two schemes need to write layout resources and logic code for each error type separately, which leads to a sharp increase in code volume, low development efficiency and high cost. SUMMARY
[0004] The embodiments of the present application provide a method, device and medium for generating error views of an application, to solve the problem of low development efficiency and high cost in the prior art.
[0005] The present application discloses a method for generating error views of an application, the application is installed in an electronic device, the electronic device is communicatively connected with a network-attached storage device, and the network-attached storage device is accessed through the application, and the method comprises the following steps:
[0006] An enumeration class is created, the enumeration class includes a plurality of enumeration values, and the enumeration error type corresponding to each enumeration value is defined;
[0007] An empty state view class is defined, and the configuration parameters of the enumeration error type are encapsulated in the empty state view class;
[0008] An execution binding function is called to receive an error parameter, and it is judged whether there is an enumeration value consistent with the error parameter;
[0009] If yes, it is determined that the current error type corresponding to the error parameter belongs to the enumeration error type, the configuration parameters corresponding to the current error type are loaded from the empty state view class according to the current error type, and the root layout of the empty state view is obtained;
[0010] The empty state view is generated based on the root layout of the empty state view, and is added to the interface to display to the user.
[0011] Optionally, the step of determining that the current error type corresponding to the error parameter belongs to the enumeration error type comprises:
[0012] corresponding to the current error type is determined as the current error type;
[0013] The step of loading the corresponding configuration parameter from the empty state view class according to the current error type comprises:
[0014] An empty view variable is created, the empty view variable is filled by using the empty state view class corresponding to the current error type, and the root layout of the empty state view is obtained.
[0015] Optionally, the step of defining the binding function comprises:
[0016] A callback function is added in the binding function, and a parameter of the callback function has a default value of an empty function.
[0017] Optionally, the step of encapsulating the configuration parameter of at least one of the enumeration error types in the empty state view class comprises:
[0018] A layout file is instantiated into a binding class object by an inflation method in the empty state view class, and the configuration parameter is included in the layout file.
[0019] The properties of the empty state view of the enumeration error type are set according to the configuration parameter by using an application function, a root view object of the empty state view is obtained, and the root view object is assigned to the empty view variable.
[0020] Optionally, after the step of judging whether there is an enumeration value consistent with the error parameter, the step comprises:
[0021] If not, the current error type is determined as a custom type.
[0022] A custom layout method is called, and a custom layout parameter is received by the custom layout method.
[0023] A custom layout instance is created, the properties of the empty state view of the current error type are set according to the custom layout parameter, and the root layout of the empty state view is obtained.
[0024] Optionally, the step of creating the custom layout instance comprises:
[0025] A view object of a created view is obtained by a getting method of a view conversion class, the view object is not directly added to a parent view, and the custom layout instance of the view object is returned.
[0026] Optionally, the step of judging whether there is an enumeration value consistent with the error parameter comprises:
[0027] create a resource pool, the resource pool includes standard icons and default icons, the standard icons are for the enumerated error types;
[0028] if the current error type belongs to the enumerated error types, a standard icon matching the current error type is selected from the standard icons for display;
[0029] if the current error type does not belong to the enumerated error types, the default icon is used for display.
[0030] Optionally, before the step of generating the empty state view based on the empty state view root layout, the method further comprises:
[0031] adding a unified burying point entry to ensure that the burying point logic is triggered every time the control is clicked.
[0032] The application further discloses an electronic device, including a memory and a processor, the memory stores a computer program, the computer program is executed by the processor, so that the processor executes the steps of the method.
[0033] The application further discloses a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to make the processor execute the steps of the method.
[0034] The application further discloses a system for generating an error view of an application, including a network attached storage device and the electronic device as described in 9, and the electronic device is installed with an application capable of executing the steps of the method.
[0035] Compared with the prior art, the method for generating an error view of an application provided by the application has the beneficial effects that: the configuration parameters of the enumerated error types are encapsulated in the empty state view class in advance, the error parameters are obtained by calling the execution binding function, it is judged whether the current error type is the enumerated error type based on the error parameters, if yes, the corresponding configuration parameters can be loaded from the empty state view class, so that the corresponding empty state view is generated, the mapping relationship between the error types and the configuration parameters is established, different empty state views are loaded according to different error types, the unified processing of the multiple error types is realized in the empty state view class, the code logic is simplified, the repeated code writing is avoided, the code reusability and maintainability are improved, the development cost is effectively reduced, and the development efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0036] The scheme of the application will be further described in detail below with reference to the drawings and embodiments, and the drawings show:
[0037] Figure 1is a flowchart of an embodiment of the method for generating an error view of an application provided by the present application.
[0038] Figure 2 is a schematic diagram of an application scenario of the method for generating an error view of an application provided by the present application.
[0039] Figure 3 is a code diagram of an embodiment of the method for creating an enumeration class provided by the present application.
[0040] Figure 4 is a code diagram of an embodiment of the method for calling an execution binding function provided by the present application.
[0041] Figure 5 is a code diagram of the NO_PHOTO_RESULT branch provided by the present application.
[0042] Figure 6 is a flowchart of another embodiment of the method for generating an error view of an application provided by the present application.
[0043] Figure 7 is a code diagram of an embodiment of the method for calling a custom layout method provided by the present application.
[0044] Figure 8 is a schematic diagram of the internal structure of an electronic device in an embodiment provided by the present application. DETAILED DESCRIPTION
[0045] It should be noted that the embodiments and features in the embodiments in the present application can be combined with each other without conflict. The preferred embodiments of the present application will be described in detail with reference to the accompanying drawings.
[0046] Please refer to Figure 1 , Figure 1 is a flowchart of an embodiment of the method for generating an error view of an application provided by the present application. Figure 2 is a schematic diagram of an application scenario of the method for generating an error view of an application provided by the present application. An electronic device 10 establishes a communication connection with a network attached storage device 20. The electronic device 10 has an application installed therein, and accesses the network attached storage device 20 through the application.
[0047] The method for generating an error view of an application provided by the present application includes the following steps.
[0048] S101: Create an enumeration class, the enumeration class includes a plurality of enumeration values, and define an enumeration error type corresponding to each enumeration value.
[0049] In a specific implementation scenario, an enumeration class is created, which can define different error types. Through the enumeration class, all possible error types can be clearly listed, such as network errors, data loading errors, empty data, etc. Each enumeration value represents a specific error type, which can ensure the uniformity and consistency of error types, avoid different error type expressions in the code, and improve the readability and maintainability of the code. Please refer to Figure 3 , Figure 3 is a code schematic diagram of an embodiment of creating an enumeration class provided by the present application.
[0050] S102: Define an empty state view class, which encapsulates configuration parameters of enumeration error types.
[0051] In a specific implementation scenario, the configuration of the empty state view is concentrated in one place, which is easy to maintain and modify. Therefore, the empty state view class EmptyLayoutBinding is defined, which can store the configuration parameters required by various enumeration error types of the empty state view in the instance of EmptyLayoutBinding, and then configure and display the corresponding empty state view according to these parameters when displaying the empty state view.
[0052] Specifically, the EmptyLayoutBinding class is a template class for binding the empty state view, which is used to store the configuration parameters of the empty state view. Various properties required by the empty view are defined in the EmptyLayoutBinding class, such as title: the title of the empty state view, message: the message content of the empty state view, iconResId: the icon resource ID of the empty state view, actionText: the text content of the operation button on the empty state view, and actionClickListener: the click event listener of the operation button on the empty state view.
[0053] S103: Call the execution binding function to receive the error parameter, and judge whether there is an enumeration value consistent with the error parameter. If yes, execute step S104.
[0054] In a specific implementation scenario, the execution binding function bindError is called to receive the error parameter, and the error parameter is compared with the enumeration values in the enumeration class to determine whether there is an enumeration value consistent with the error parameter. If yes, the enumeration error type corresponding to the consistent enumeration value can be used as the current error type, and if not, the current error type is defined as a custom type.
[0055] Specifically, the parameters received by the bindError function include: context: Context, a context object for accessing application resources and global information, errorType: Int, an integer value representing the error type, parent: ViewGroup?, an optional parameter representing the parent container to which the created view is added, and callBack: () -> Unit, a callback function that is called when certain operations need to be performed.
[0056] Referring to Figure 4 , Figure 4 is a code diagram of an embodiment of a call execution binding function provided by the present application. In Figure 4 the code shown, according to the error parameter errorType value passed in, the current error type is obtained, and the corresponding processing logic is selected.
[0057] In Figure 4 the code shown, a callBack: () -> Unit parameter is added to the bindError function, and a default value of an empty function is provided for the callBack parameter to ensure that no error occurs even if no callback function is passed in. When processing a specific error type, the passed-in callback function can be called by setting the click event of the button, realizing the separation of the button click event and the business logic.
[0058] S104: Determine whether the current error type corresponding to the error parameter belongs to the enumerated error type, load the corresponding configuration parameters from the empty state view class according to the current error type, and obtain the root layout of the empty state view.
[0059] In a specific implementation scenario, the enumerated error type is combined with a view binding template in advance, and the view binding template defines configuration parameters such as empty state view and data binding mode. If there is an enumerated value that matches or is the same as the error parameter, it can be determined that the current error type belongs to the enumerated error type, such as no data, no network connection, no search result, etc., and the corresponding configuration parameters are used to obtain the root layout of the empty state view.
[0060] Referring to Figure 4 , Figure 4 is a code diagram of an embodiment of a call execution binding function provided by the present application. In Figure 4 the code shown, according to the errorType (error parameter) value passed in, it is determined whether the error parameter has a corresponding enumerated value, and if so, the enumerated error type corresponding to the enumerated value is taken as the current error type, and the processing logic corresponding to the current error type is executed. For example Figure 4 the error type in is ERROR_NO_FILE.
[0061] InFigure 4 The mapping between error types and configuration parameters is established in the shown code through when (errorType) to load different empty state views according to different error types. If there are a large number of different enumerated error types to handle (such as 50+), corresponding branches can be added in the when expression to handle each enumerated error type. In each branch, different view elements, text content, icons, and other configuration parameters can be set to display different empty state views according to specific circumstances, and unified handling of multiple error types can be achieved, improving code maintainability and flexibility.
[0062] For example, when (errorType) can handle two enumerated error types, ERROR_NO_FILE and ERROR_NETWORK_ISSUE, according to different errorType values, and set the corresponding empty state view content. If it is an unknown error type (for example, a custom error type), a default unknown empty state view will be displayed. In each error type handling branch, the title, message, icon, and other content can be set according to specific circumstances. By handling multiple error types with a unified function, the need to repeatedly write similar code can be avoided. This can improve code reusability and reduce redundant code. A unified error handling approach can ensure consistent user experience throughout the application. Regardless of the error type, users will see a unified style of empty state views.
[0063] In a specific implementation scenario, corresponding configuration parameters are loaded from the empty state view class. These configuration parameters may include layout resource IDs, text information, icons, and other information. The layout resource is obtained through the loaded configuration parameters, and the loaded configuration parameters are used to obtain the layout resource according to the layout resource ID and other information. The empty state view will have a root layout, which can be obtained by calling the corresponding method, such as emptyLayoutBinding.root. This root layout can be used for subsequent layout operations, display control, and other operations.
[0064] For example, Figure 4As shown in , when errorType is ERROR_NO_FILE, an empty view variable emptyView is created. The empty state view class EmptyLayoutBinding is used to fill this empty view. An empty state view layout file is instantiated through EmptyLayoutBinding.inflate(LayoutInflater.from(context)). Then, the properties of the empty state view are set through the apply function apply. For example, the title is set to invisible, the message text is set to "This is empty", the message text font is set to bold, the message text color is set to black (using com.ugreen.modulesbase.common.R.color.black85 reference), and the icon resource is set to R.mipmap.app_no_file_placeholder. Finally, the root view object is obtained through .root and assigned to the empty view variable emptyView. In this way, the empty view variable emptyView contains the root view object of the generated empty state view, which can be used in subsequent code for further operations or display.
[0065] Specifically, the inflate method in the EmptyLayoutBinding class instantiates an empty state view's layout file, generating a corresponding, operational binding class object, EmptyLayoutBinding. This allows for convenient configuration and manipulation of view elements in the layout file within code. The layout file defines the configuration parameters for the empty state view's layout structure, including the layout and style of elements such as the title, message text, and icon. The apply method is used to set a series of properties on the instantiated EmptyLayoutBinding object.
[0066] The root view object of the empty state view is retrieved through .root and assigned to the empty view variable emptyView. This variable now contains the root view object of the generated empty state view, which can be used in subsequent code for further operations or display. This method allows you to dynamically generate different styles of empty state views based on different error types, improving code reusability and flexibility.
[0067] Please refer to Figure 5 , Figure 5 It is a code schematic diagram of the NO_PHOTO_RESULT branch provided by the present invention. Figure 5The code handles the error type NO_PHOTO_RESULT in this branch. Inside this branch, the content and style of the NO_PHOTO_RESULT empty state view are set. An empty state view is instantiated from the layout file through the inflate method of the EmptyLayoutBinding class and added to the specified parent layout (parent parameter).
[0068] A series of property settings are performed on the instantiated EmptyLayoutBinding object using the apply function. The title text of the empty state view is set to "Empty gallery", and the message text of the empty state view is set to an empty string, i.e. no specific message content. The message text view is set to invisible, i.e. no message content is displayed in this case. The icon resource of the empty state view is set to app_no_content_placeholder, i.e. an icon indicating no content is displayed. According to the value of isShowButton, it is determined whether the confirmation button is visible. If isShowButton is true, the confirmation button is visible, otherwise it is not visible. The text content of the confirmation button is set to "Upload photo".
[0069] confirm.setOnClickListener{callBack()} sets the click event listener for the confirmation button. When the user clicks the confirmation button, the callBack() function is executed, i.e. the passed-in callback function is executed. Finally,.root gets the root view of EmptyLayoutBinding, i.e. the root view of the entire empty state view, and assigns it to the emptyView variable.
[0070] In combination Figure 4 Figure 5 As can be seen, the code uses the EmptyLayoutBinding class to uniformly manage the layout and element configuration parameters of the empty state view, so as to centrally manage the configuration parameters. According to the errorType obtained, the configuration parameters of the empty state view are loaded through the EmptyLayoutBinding.inflate method, and the title, message, icon, etc. are set according to the configuration parameters. In this way, different types of empty state views can be managed through a unified template, which is convenient for maintenance and modification. Through the unified template EmptyLayoutBinding, the configuration parameters originally scattered in multiple layout files can be centrally managed in one place, improving the maintainability and flexibility of the code.
[0071] In addition, in the present application, the content of the title, message, icon, etc. is dynamically set according to different error types to adapt to different empty state requirements. Through the parameterized configuration mode, the function can dynamically display different empty state contents according to the configuration parameters passed in, such as whether to display the button or not. All empty states share the same XML template (EmptyLayoutBinding), so that only one layout file needs to be modified when the UI is revised.
[0072] In the present embodiment, through the apply function, multiple properties can be set in a code block one by one without having to repeatedly reference the object. The object itself is returned in each configuration method so that other configuration methods can be called in succession to achieve the effect of chain configuration. This chain configuration mode allows multiple properties to be configured in a certain order when setting the error type, improving the readability and maintainability of the code.
[0073] Through standardized parameters, commonly used configuration parameters can be unified, such as icon configuration, title configuration, button visibility, etc. In the code shown in Figure 4 and Figure 5 , standardized parameters such as icon.setImageResource(), title.text = context.getString(), confirm.isVisible = isShowButton are used to quickly and consistently configure the corresponding properties. The use of such standardized parameters allows new error types to be added by simply providing the corresponding parameter values without having to repeatedly write configuration logic, thereby saving a lot of development time.
[0074] Through the combination of chain configuration mode and standardized parameters, developers only need to provide specific information of the new error type, such as icon, title, button visibility, etc., to quickly configure the new error type view. The modification scope is limited to the current interface because the configuration is only done inside the bindError method and does not affect other parts of the code.
[0075] S105: Generate an empty state view based on the root layout of the empty state view and add it to the interface to display to the user.
[0076] In a specific implementation scenario, the empty state root layout (the topmost view of the entire empty state view) is obtained, an empty state view is generated based on the empty state view root layout, and the empty state view is added to the interface for display to the user. Executing the code returnemptyLayoutBinding.root and using emptyLayoutBinding.root as the function's return value returns the entire empty state root layout. The generated empty state view is then obtained and added to the interface for display to the user where the function is called.
[0077] In other implementation scenarios, add the following code:
[0078] / / Standardized callback processing (including anti-shake) confirm.setOnClickListener{callBack() / / Unified tracking entry / / ClickThrottle anti-shake logic can be inserted here}
[0079] / / Special interaction processing (INDEX_ERROR branch) message.clickThrottle{callBack()}
[0080] In standardized callback processing, debounce logic can be easily inserted to ensure that the callback function is executed only once during the button click process. This helps avoid repeated operations caused by users frequently clicking buttons. For special interaction processing, such as in the INDEX_ERROR branch, through specific interaction methods (such as message.clickThrottle{callBack()}), different interaction logic can be implemented for specific error types without affecting the handling of other error types.
[0081] Passing a callback function as a parameter to the bindError function implements standardized callback handling. This means all error types share the same callback function, uniformly handling button click events. This unified callback function allows for operations such as tracking statistics and logging, ensuring that these operations are executed for button click events of all error types.
[0082] Because all error types share the same callback function, adding or modifying tracking points requires only modification within this unified callback function, eliminating the need to rewrite the same code for each error type. This design greatly simplifies code maintenance, reduces duplication, and makes modification and expansion easier and more efficient.
[0083] It can be known from the above description that the application encapsulates the configuration parameters of the enumeration error type in the empty state view class in advance, calls the execution binding function to obtain error parameters, obtains the current error type based on the error parameters, and if the current error type belongs to the enumeration error type, the corresponding configuration parameters can be loaded from the empty state view class, so that the corresponding empty state view is generated, the mapping relationship between the error type and the configuration parameters is established, different empty state views are loaded according to different error types, the unified processing of multiple error types is realized in the empty state view class, the code logic is simplified, repeated code writing is avoided, the code reusability and maintainability are improved, the development cost is effectively reduced, and the development efficiency is improved.
[0084] Please refer to Figure 6 , Figure 6 is a flowchart of another embodiment of the method for generating an error view of an application program provided by the application. The method for generating an error view of an application program provided by the application comprises the following steps:
[0085] S201: An enumeration class is created, the enumeration class comprises a plurality of enumeration values, and the enumeration error type corresponding to each enumeration value is defined.
[0086] S202: An empty state view class is defined, and the configuration parameters of the enumeration error type are encapsulated in the empty state view class.
[0087] S203: An execution binding function is called to receive error parameters, and it is judged whether there is an enumeration value consistent with the error parameters. If not, step S204 is executed.
[0088] In a specific implementation scenario, steps S201-S204 are basically the same as steps S101-S104 in the embodiment of the method for generating an error view of an application program provided by the application, and will not be repeated here.
[0089] S204: It is determined that the current error type is a custom type, and a custom layout method is called to receive custom layout parameters through the custom layout method.
[0090] In a specific implementation scenario, it is determined that the current error type does not belong to the enumeration error type, and is a custom type. A custom layout method is called to receive custom layout parameters through the custom layout method. Please refer to Figure 7 , Figure 7 is a code schematic diagram of one embodiment of the custom layout method provided by the application. In Figure 7In the custom layout method bindErrorCustom function, multiple custom layout parameters are accepted, including context (context), parent (parent view), iconResId (icon resource ID), showTitle (whether to display the title), titleStr (title content), showMessage (whether to display the message), messageStr (message content), showButton (whether to display the button), buttonStr (button text), and callBack (callback function).
[0091] S205: Create a custom layout instance, set the empty state view attributes of the current error type according to the custom layout parameters, and obtain the empty state view root layout.
[0092] In a specific implementation scenario, a custom layout instance is created, the empty state view attributes of the current error type are set according to the custom layout parameters, and the empty state view root layout is obtained.
[0093] like Figure 7 As shown in the example, create a custom layout instance named emptyView of the EmptyLayoutBinding class and use the inflate method in the EmptyLayoutBinding class to instantiate the layout file of the empty view into a view object named emptyView. Specifically, use the from method of the view conversion class LayoutInflater to obtain a view object LayoutInflater used to create a blank view from the layout file. Instead of adding the view object directly to the parent view, an instance of the view object is returned. This allows for further configuration and manipulation of the view object in subsequent code. The LayoutInflater class can convert XML layout files into corresponding view objects.
[0094] Set the properties of the empty state view according to the configuration parameters. If showTitle is true, set the title text to titleStr and make the title visible; otherwise, make the title invisible. If showMessage is true, set the message text to messageStr and make the message visible; otherwise, make the message invisible. Set the icon resource to iconResId. Determine the button visibility based on the value of showButton and set the button text to buttonStr. Set a click event listener for the confirmation button and call the callBack function when the button is clicked.
[0095] Finally, return the root layout emptyView.root of the constructed empty state view.
[0096] The empty state view is dynamically constructed according to the incoming custom configuration parameters, and flexible customization of the empty state view is achieved. The user can set whether to display the title, message, button, and configure the specific content and behavior of them according to the needs, so as to realize the empty state view of different styles and functions. Such design helps to reduce repeated code and improve the maintainability and flexibility of the code.
[0097] S206: Generate the empty state view based on the empty state view root layout, and add it to the interface to display to the user.
[0098] In a specific implementation scenario, step S206 is basically the same as step S105 in an embodiment of the method for generating an error view of an application provided by the present application, and will not be described here.
[0099] For reference Figure 4 and Figure 7 It can be known that in the embodiment, the resource pool R.mipmap.app is created, and the standard icons correspond to the enumerated error types; if the current error type belongs to the enumerated error type, the icon that matches the current error type is selected from the standard icons for display, which can make the icon resources have a higher reuse rate. Reusing resources as much as possible can reduce the loading of repeated resources, thereby reducing the size of the application. If the current error type does not belong to the enumerated error type, a default icon is used for display. Through the intelligent reuse strategy, similar icon resources can be avoided from being repeatedly included in the APK, thereby reducing the size of the APK. In this case, selecting different icon resources according to the error type can reduce the APK size by about 300KB, improve the download speed of the application, and improve the user experience.
[0100] As can be known from the above description, in the embodiment, multiple customizable configuration parameters are provided, and the caller can flexibly configure the display mode of the empty state view according to the needs, so that the function is more universal and applicable. According to the value of the configuration parameter, the properties of each component in the empty state view are dynamically controlled, and the flexibility and customizability of the empty state view are improved.
[0101] Figure 8 An internal structure schematic diagram of an electronic device in an embodiment is shown. The electronic device can be a terminal or a server. As Figure 8As shown, the electronic device includes a processor, a memory and a network interface connected through a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the electronic device stores an operating system, and can also store a computer program which, when executed by the processor, can enable the processor to implement the method for generating an error view of an application program. The internal memory can also store a computer program which, when executed by the processor, can enable the processor to execute the method for generating an error view of an application program. Those skilled in the art can understand that Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0102] In one embodiment, an electronic device is provided, including a memory and a processor, the memory storing a computer program which, when executed by the processor, enables the processor to perform the steps as described above.
[0103] In one embodiment, a computer readable storage medium is provided, storing a computer program which, when executed by a processor, enables the processor to perform the steps as described above.
[0104] The present application also provides a system for generating an error view of an application program. The system for processing application program versions includes the electronic device described above and a network-attached storage device, and the electronic device is installed with an application program capable of executing the steps of the method described above.
[0105] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing relevant hardware. The program can be stored in a non-volatile computer readable storage medium, and when the program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0106] The technical features of the above embodiments can be combined in any way. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present disclosure.
[0107] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present application, but not limit it. Those skilled in the art can modify the technical solutions described in the above embodiments, or make equivalent replacement for part of the technical features; all these modifications and replacements shall fall into the protection scope of the appended claims of the present application.
Claims
1. A method for generating an error view for an application, wherein the application is installed in an electronic device, the electronic device is communicatively connected to a network attached storage device, and the network attached storage device is accessed by the application, characterized in that: The method for generating an error view of an application comprises: creating an enumeration class comprising a plurality of enumeration values, each enumeration value corresponding to an enumeration error type; defining an empty state view class, wherein configuration parameters of the enumeration error type are encapsulated in the empty state view class; calling an execution binding function to receive an error parameter, and determining whether there is an enumeration value consistent with the error parameter; if yes, determining that a current error type corresponding to the error parameter belongs to the enumeration error type, loading corresponding configuration parameters from the empty state view class according to the current error type, and obtaining an empty state view root layout; generating an empty state view based on the empty state view root layout, and adding the empty state view to an interface to display to a user.
2. The method of generating an error view for an application of claim 1, wherein, The step of determining that the current error type corresponding to the error parameter belongs to the enumeration error type comprises: taking the enumeration error type corresponding to the enumeration value as the current error type. The step of loading corresponding configuration parameters from the empty state view class according to the current error type comprises: creating an empty view variable, filling the empty view variable using the empty state view class corresponding to the current error type, and obtaining the empty state view root layout.
3. The method of generating an error view for an application of claim 2, wherein, The step of defining a binding function comprises: adding a callback function to the binding function, and setting a default value of a parameter of the callback function as an empty function.
4. The method of generating an error view for an application of claim 1, wherein, The step of encapsulating at least one configuration parameter of the enumeration error type in the empty state view class comprises: instantiating a layout file as a binding class object through an inflation method in the empty state view class, the layout file comprising the configuration parameter; setting properties of an empty state view of the enumeration error type according to the configuration parameter using an application function, obtaining a root view object of the empty state view, and assigning the root view object to the empty view variable.
5. The method for generating an error view of an application according to claim 1, wherein: After the step of determining whether there is an enumeration value consistent with the error parameter, the method further comprises: if no, determining that the current error type is a custom type; calling a custom layout method, and receiving a custom layout parameter through the custom layout method; creating a custom layout instance, setting properties of an empty state view of the current error type according to the custom layout parameter, and obtaining the empty state view root layout.
6. The method of generating an error view for an application of claim 5, wherein, The step of creating a custom layout instance comprises: obtaining a view object of a created view through an obtaining method of a view conversion class, and not directly adding the view object to a parent view, and returning the custom layout instance of the view object.
7. The method of generating an error view for an application of claim 5, wherein, The step of determining whether there is an enumeration value consistent with the error parameter comprises: creating a resource pool, the resource pool comprising standard icons and default icons, the standard icons being for the enumeration error type; if the current error type belongs to the enumeration error type, selecting a standard icon matching the current error type for display from the standard icons; if the current error type does not belong to the enumeration error type, using the default icon for display.
8. The method of generating an error view for an application of claim 1, wherein, Before the step of generating an empty state view based on the empty state view root layout, the method further comprises: Add a unified entry for the tracking, and make sure the control triggers the tracking logic every time it is clicked.
9. An electronic device, comprising: A memory storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the method of any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that, A computer program stored on a computer readable medium, which, when executed by a processor, causes the processor to perform the steps of the method of any one of claims 1 to 8.
11. A system for generating an error view of an application, the system comprising: A network attached storage device and the electronic device of claim 9, the electronic device having installed an application program capable of performing the steps of the method of any one of claims 1 to 8.