Disclosure of Invention
The invention aims to provide a display method and a display device for page state switching, so as to improve the problems.
A first embodiment of the present invention provides a display method for switching page states, including:
setting a view group which comprises a plurality of corresponding sub-views for displaying a plurality of customized different page states, wherein each sub-view is provided with a response processing function for a click event;
setting a unique ID for a content display area of a current page and transmitting the ID to the view group;
the view group obtains a parent layout and a parent layout object of a content display area of a current page through the ID, and is used for controlling the hiding and the displaying of display content in the content display area of the current page, and the view group adds itself to the obtained parent layout through the ID to become a child view of the view group, and is used for displaying one of a plurality of child views contained in the view group according to requirements;
and responding to user operation, and displaying one of a plurality of corresponding sub-views which are contained in the view group and display different page states according to the processing result.
Wherein the plurality of different page states include, but are not limited to: the data loading state is a data loading in-process state, a data loading completion state, a data loading failure state, a data loading completion but empty content state and a network abnormal state.
Wherein the response processing function of the child view to the click event comprises: and processing the click event by self or throwing the click event to a calling party for processing.
And hiding the display content in the content display area of the current page before displaying one of a plurality of corresponding sub-views which are contained in the view group and display different page states according to the processing result.
A second embodiment of the present invention provides a display device for switching a page status, including:
the view group setting unit is used for setting a view group, and comprises a plurality of corresponding sub-views for displaying a plurality of self-defined different page states, and each sub-view is provided with a response processing function to a click event;
the ID setting and sending unit of the content display area of the page is used for setting a unique ID for the content display area of the current page and transmitting the ID to the view group;
an obtaining and adding unit, configured to enable the view group to obtain, through the ID, a parent layout of a content display area of a current page and the parent layout object for controlling hiding and displaying of display content in the content display area of the current page, and enable the view group to add itself to the obtained parent layout through the ID into a child view thereof for displaying one of a plurality of child views included in the view group as required;
and the page state display unit is used for responding to user operation and displaying one of a plurality of corresponding sub-views which are contained in the view group and display different page states according to the processing result.
Wherein the plurality of different page states include, but are not limited to: the data loading state is a data loading in-process state, a data loading completion state, a data loading failure state, a data loading completion but empty content state and a network abnormal state.
Wherein the response processing function of the child view to the click event comprises: and processing the click event by self or throwing the click event to a calling party for processing.
The page state display unit is further configured to hide display content in a content display area of the current page before displaying one of a plurality of corresponding sub-views, included in the view group, that display different page states according to a processing result.
A third embodiment of the invention provides a storage device having stored therein a plurality of instructions adapted to be loaded by a processor and to perform the method according to the first embodiment or a combination thereof.
According to the display method and the device for switching the page states, the idea of separating the user interface layer of the page state from the original page layer is adopted, namely, different page states are displayed by setting a view group comprising a plurality of corresponding sub-views for displaying the customized different page states, so that the technical effect of rapidly switching the different page states in a non-invasive mode is realized, various operations such as repeatedly searching views for displaying different state contents, switching among different views and the like are effectively improved, and the operating efficiency of program codes is greatly improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention and the accompanying drawings, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart of a display method for page status switching according to a first embodiment of the present invention. As shown in fig. 1, the display method for switching page states of the present invention includes:
s1: and setting a view group which comprises a plurality of sub-views for displaying a plurality of customized different page states, wherein each sub-view is provided with a response processing function for a click event.
A group of views (ViewGroup) may be arranged using known techniques to include a corresponding plurality of sub-views for displaying a customized plurality of different page states, each sub-view being provided with a response handling function to a click event.
Generally, the content displayed on the page is realized by obtaining data on the server side through network request. The page display may have a number of different states for various reasons. The various page states described herein include, but are not limited to: a data loading in-process state, a data loading completion state, a data loading failure state, a data loading completion but empty content state, a network exception state and the like. These page display states are all states that are common to users in everyday use. For example, when a user logs in a certain APP to open a page after accessing a network, data content (e.g., information, pictures, etc.) displayed on the page needs to be downloaded from a server and loaded for display, and if data reading is slow due to slow network speed, a state of page display "data loading" is easily generated; if the network connection is unstable, the state of 'data loading failure' displayed on a page is easy to appear; a state in which the page display "data loading is completed" but the content of the page display is empty may also occur; of course, if the client leaves the network for various reasons during the network request, the page will also show a status of "network exception".
When a data loading failure state, a data loading completion but empty content state, a network abnormal state, and the like occur, a user often performs a click operation to obtain a desired result, for example, when a data loading failure occurs or a data loading completion but empty content state occurs, the user clicks a "reload" button to reload data; when a network anomaly occurs, the user clicks the "set network" button to view and set the network. Therefore, various sub-views included in the set view group need to be provided with a response processing function to a click event.
The response processing function of the child view to the click event comprises the following steps: and processing the click event by self or throwing the click event to a calling party for processing. The specific implementation method can include setting onClick () for each sub-view needing to display the state, so that the click event can be processed by self. Of course, onClick () or view. setonclicktListener may also be set at the caller to implement the click event that occurs to a child view by the caller process. As described above, when the page shows a state in which the data loading fails or the data loading is completed but the content is empty, the page at this time also provides a function of whether to reload the data. When the user clicks the button "yes" or the button "reload" or the like, the reload operation is executed, but the processing of the click event of the user can be processed by the sub-view displaying the current page state, or the sub-view provides an interface to the caller to be processed by the caller. The child views displaying different page states all have different click event response mechanisms, and when the child views are processed by a calling party, specific execution contents after the click events occur are determined by the calling party.
Various custom processing operations for the click event, such as reloading processing operation, network setting processing operation, etc., are not the key points of the present invention, and are not described herein in any greater detail.
S2: a unique ID is set for the content display area of the current page and passed to the view group.
In page development, a developer typically sets a unique ID for the content display area of the current page. This ID is also the ID of the root view of the content display of the current page, on the program code design. However, in order to achieve the object of the present invention, the ID needs to be passed to the view group (ViewGroup) set in step S1.
The content display area of the current page herein refers to an area where various information that the user wishes to view is displayed in the page displayed on the screen, and the content displayed in the display area can scroll to display more information content by a slide operation. Fig. 3 is a schematic screenshot of a content display area of a page according to the present invention, and the area indicated by an arrow shown in fig. 3 is the content display area of the current page, which is very easy for those skilled in the art to understand.
S3: the view group obtains a parent layout and a parent layout object of a content display area of a current page through the ID, and is used for controlling the hiding and the displaying of display content in the content display area of the current page, and the view group adds itself to the obtained parent layout through the ID to become a child view of the view group, and is used for displaying one of a plurality of child views contained in the view group according to requirements.
When the view group has the ID, the parent layout (parentView) of the content display area of the current page can be obtained by, for example, a contentview. In addition, after the view group has the ID, the view group can add itself to the parent layout (parentView) of the content display area of the current page by a parentView.
In short, this step S3 is performed, and the view group has the ability to control the hiding and displaying of the displayed content in the content display area of the current page, as well as the ability to display the various page states it contains.
S4: and responding to user operation, and displaying one of a plurality of corresponding sub-views which are contained in the view group and display different page states according to the processing result.
The user operation is, for example, logging in a page of an APP of a certain type, opening or switching to a desired page, refreshing a current page, or the like. Responding to user operation and carrying out corresponding processing, and displaying one of a plurality of corresponding sub-views which are contained in the view group and display different page states according to a processing result, for example, displaying the sub-view which is contained in the view group and is used for displaying the page state of which data loading is completed when the processing result is that data loading is completed and content can be displayed; when the processing result is that the data loading fails, displaying a sub-view which is contained in the view group and used for displaying the page state of the data loading failure; and when the processing result is that the data loading is completed and the content is empty, displaying a sub-view and the like contained in the view group and used for displaying the page state that the data loading is completed and the content is empty.
Since the set view group includes a plurality of sub-views corresponding to a plurality of different customized page states, that is, a plurality of different page states, when step S4 is executed, different page states can be displayed according to a processing result after a user operation is responded, so that switching display of different page states can be quickly realized.
In a preferred embodiment, the display content in the content display area of the current page is hidden before displaying one of the corresponding multiple sub-views, which are included in the view group and display different page states, according to the processing result. Therefore, the conflict caused by the simultaneous display of the contents of different pages can be avoided.
According to the display method for switching the page states, the idea of separating the user interface layer of the page states from the original page layer is adopted, namely, different page states are displayed by setting a view group comprising a plurality of corresponding sub-views for displaying the customized different page states, so that the technical effect of rapidly switching the different page states in a non-invasive mode is realized, the non-invasive mode is that original logic or files are not changed, various operations such as repeatedly searching views for displaying different state contents, switching among different views and the like are effectively improved, and the operating efficiency of program codes is greatly improved.
Fig. 2 is a schematic block diagram of a display device for page state switching according to a second embodiment of the present invention. As shown in fig. 2, the display device for page state switching of the present invention includes:
the view group setting unit is used for setting a view group, and comprises a plurality of corresponding sub-views for displaying a plurality of self-defined different page states, and each sub-view is provided with a response processing function to a click event;
the ID setting and sending unit of the content display area of the page is used for setting a unique ID for the content display area of the current page and transmitting the ID to the view group;
an obtaining and adding unit, configured to enable the view group to obtain, through the ID, a parent layout of a content display area of a current page and the parent layout object for controlling hiding and displaying of display content in the content display area of the current page, and enable the view group to add itself to the obtained parent layout through the ID into a child view thereof for displaying one of a plurality of child views included in the view group as required;
and the page state display unit is used for responding to user operation and displaying one of a plurality of corresponding sub-views which are contained in the view group and display different page states according to the processing result.
Wherein the plurality of different page states include, but are not limited to: the data loading state is a data loading in-process state, a data loading completion state, a data loading failure state, a data loading completion but empty content state and a network abnormal state.
Wherein the response processing function of the child view to the click event comprises: and processing the click event by self or throwing the click event to a calling party for processing.
The page state display unit is further configured to hide display content in a content display area of the current page before displaying one of a plurality of corresponding sub-views, included in the view group, that display different page states according to a processing result.
It is clear to those skilled in the art that for the convenience and brevity of description, the specific operation of the apparatus described above may refer to the corresponding process in the foregoing method embodiment, the example illustrated in the foregoing method embodiment and the related description, which are also applicable to explain the operation of the apparatus, and will not be repeated here.
According to the display device for switching the page states, the idea of separating the user interface layer of the page states from the original page layer is adopted, namely, different page states are displayed by setting a view group comprising a plurality of corresponding sub-views for displaying the customized different page states, so that the technical effect of rapidly switching the different page states in a non-invasive mode is realized, the non-invasive mode is that original logic or files are not changed, various operations such as repeatedly searching views for displaying different state contents, switching among different views and the like are effectively improved, and the operating efficiency of program codes is greatly improved.
The embodiment of the present invention further provides a computer program product of a display method for page state switching, which includes a computer readable storage medium storing a program code, where instructions included in the program code may be used to execute the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, and is not described herein again.
To this end, the invention also provides a storage device having stored therein a plurality of instructions adapted to be loaded by a processor and to carry out the method according to the first embodiment or the method according to the first embodiment in combination with the preferred embodiment.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a smart tablet, a smart phone, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.