[ invention ]
In view of the above, the embodiments of the present invention provide an interface display method, apparatus, terminal device, and storage medium, so as to solve the problem of slow interface display speed.
In one aspect, an embodiment of the present invention provides an interface display method, where the method is applied to a terminal device, and the terminal device installs an application program, and the method includes:
when an application program runs, generating a data loading task of a target application interface;
executing the data loading task to obtain loading data;
receiving an interface display instruction;
and responding to the interface display instruction, and displaying the target application interface through the loading data when the data loading task is completed.
Optionally, the application program runs a first application interface including the application program starting or displaying the application program.
Optionally, the generating the data loading task of the target application interface further includes: generating a task identifier, wherein the task identifier is used for identifying the data loading task;
before the target application interface is displayed through the loading data, the method further comprises the following steps:
monitoring whether a data loading task corresponding to the task identifier is completed or not through the task identifier;
if the data loading task is completed, executing the step of displaying the target application interface through the loading data;
and if the data loading task is not completed, executing the step of monitoring whether the data loading task is completed or not through the task identification.
Optionally, the executing the data loading task to obtain loading data includes:
and executing the data loading task through the set thread pool to acquire loading data.
Optionally, the acquiring the loading data includes:
reading data from a local database, retrieving data from a server, or retrieving loading data from a local disk file.
Optionally, the terminal device installs a data preloading framework;
the generating the data loading task of the target application interface comprises the following steps:
and generating a data preloading task through the invoked data preloading framework.
Optionally, the terminal device installs a data preloading framework;
the monitoring whether the data loading task is completed comprises the following steps:
invoking the data preloading framework by the application program to inject a listener;
and monitoring whether the data loading task corresponding to the task identifier is completed or not through the monitor.
On the other hand, the embodiment of the invention provides an interface display device, which is applied to terminal equipment, and the terminal equipment installs an application program; the device comprises:
the generating module is used for generating a data loading task of the target application interface when the application program runs;
the execution module is used for executing the data loading task to acquire loading data;
the receiving module is used for receiving the interface display instruction;
and the display module is used for responding to the interface display instruction, and displaying the target application interface through the loading data when the data loading task is completed.
On the other hand, the embodiment of the invention provides a storage medium, which comprises a stored program, wherein the device where the storage medium is located is controlled to execute the interface display method when the program runs.
In another aspect, an embodiment of the present invention provides a terminal device, including a memory and a processor, where the memory is configured to store information including program instructions, and the processor is configured to control execution of the program instructions, where the program instructions, when loaded and executed by the processor, implement steps of the interface presentation method described above.
According to the technical scheme provided by the embodiment of the invention, when the application program runs, the data loading task of the target application interface is generated and executed to acquire the loading data, and the target application interface is displayed by loading the data in response to the received interface display instruction.
[ detailed description ] of the invention
For a better understanding of the technical solutions of the present specification, embodiments of the present specification are described in detail below with reference to the accompanying drawings.
It should be understood that the described embodiments are only some, but not all, of the embodiments of the present description. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present disclosure.
The terminology used in the embodiments of the description presented herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description presented herein. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one way of describing an association of associated objects, meaning that there may be three relationships, e.g., a and/or b, which may represent: the first and second cases exist separately, and the first and second cases exist separately. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
Fig. 1 is a flowchart of an interface display method provided in an embodiment of the present invention, where the method is applied to a terminal device, and the terminal device installs an application program, as shown in fig. 1, and the method includes:
and 102, when the application program runs, the terminal equipment generates a data loading task of the target application interface.
In the embodiment of the invention, the terminal equipment comprises, but is not limited to, a mobile phone, a tablet personal computer, a personal computer (personal computer, PC), a wearable device or a car machine and the like.
In the embodiment of the invention, the application program running can comprise the application program starting or displaying the first application interface of the application program. The terminal equipment can generate a data loading task in the running process of the application program so as to execute the data loading task, and the data loading task is used for preloading the data of the target application interface. That is, the data loading task is used to begin preloading data of the target application interface prior to presentation of the target application interface. The terminal device may generate a data loading task when the application is started, or generate a data loading task when the first application interface is exposed.
The terminal device installs a data preloading framework, and the data loading task of the terminal device for generating the target application interface specifically may include: and the terminal equipment generates a data preloading task through the invoked data preloading framework.
The terminal equipment generates a data loading task of the target application interface and also generates a task Identification (ID) which is used for identifying the data loading task. For example, the task identity may be a value of the int type. The number of target application interfaces may be one or more, each target application interface may correspond to one data loading task, and the task identifier corresponding to each data loading task is unique.
Fig. 2 is a flowchart of another interface display method provided in an embodiment of the present invention, where, as shown in fig. 2, a terminal device installs a data preloading frame and an application program, the application program accesses the data preloading frame, and the application program can perform data preloading through the data preloading frame anywhere. Specifically, the Application program may call an interface of the data preloading framework at an entry, such as an onCreate function of an Application program (Application), to perform data preloading to generate a data loading task, and the Application program may call an interface of the data preloading framework anywhere in the first Application interface to perform data preloading to generate a data loading task, which may be selected by an Application developer. The terminal device invokes the data preloading framework through the application to generate a data loading task and a task identifier, wherein the task identifier generated by the data preloading framework can be a numerical value of the type int, and then the data preloading framework returns the task identifier to the application program. For example, when the terminal device displays the first application interface, the data of the target application interface needs to be loaded, and the application program can call the data preloading framework when the entry function "onCreate ()" created by the first application interface or clicking a certain button, so as to generate a data loading task and a task identifier of the target application interface, and the data preloading framework can return the task identifier to the application program.
Step 104, the terminal device executes a data loading task to acquire loading data.
The method specifically comprises the following steps: and the terminal equipment executes a data loading task through the set thread pool to acquire loading data, wherein a user can create the thread pool or the thread pool adopts a default thread pool. In order to fully utilize the multi-core processing capability, the data loading tasks are executed in parallel through a thread pool in the data preloading framework, so that the CPU resource preemption of the main thread is reduced, and an application clamping or application program non-response dialog box (Application Not Response, ANR) is not added. The data loading task is generally a time-consuming task, such as querying data from a database, acquiring data from a cloud server, wherein the time-consuming task is few hundred milliseconds, more than a few seconds, if the task is executed in a main thread, the performance of an application program is seriously affected, the task is blocked when the task is light, and the ANR is caused when the task is heavy. It can be seen that the longer the data loading time is, the greater the specific gravity of the time taken to jump from the first application interface to the target application interface. The data preloading framework is used for not occupying the resources of a central processing unit (Central Processing Unit, CPU) with the main thread, fully utilizing the multi-core processing capability of the CPU, adopting the thread pool class provided by Android to create a thread pool, and carrying out parallel processing on tasks, thereby improving the data acquisition efficiency when executing the data loading tasks, and further reducing the time consumption of data loading. As shown in fig. 2, the terminal device executes a data loading task by using a set thread pool through a data preloading framework to acquire loading data, so that the multi-thread acquisition of the loading data is realized. According to the embodiment of the invention, the thread pool is adopted to execute the data loading task, so that the program parallelism capability is improved, the program execution efficiency is improved, and the program running is smoother.
The obtaining, by the terminal device, the loading data may include: the terminal device reads data from a local database, acquires data from a server or acquires loading data from a local disk file, wherein the local disk file can comprise a vehicle-mounted disk file.
And 106, receiving an interface display instruction by the terminal equipment.
If the user wants to view the target application interface, an interface display instruction is input on the terminal device, for example, a first application interface of the terminal device, and the user clicks a button of the target application interface in the first application interface to input the interface display instruction to the terminal device. As shown in fig. 2, the interface presentation instruction is configured to cause the application program to jump from the first application interface to the target application interface, and when the application program jumps from the first application interface to the target application interface, the task identifier is further transferred to the target application interface.
And step 108, the terminal equipment responds to the interface display instruction, and displays the target application interface by loading the data when the data loading task is completed.
Fig. 3 is a flowchart of a task for monitoring data loading, where, as shown in fig. 3, before the target application interface is displayed by loading data, the method further includes:
step 202, the terminal equipment monitors whether a data loading task corresponding to a task identifier is completed or not through the task identifier, if yes, the step 204 is executed; if not, step 202 is performed.
In the embodiment of the present invention, after receiving the interface display instruction, the terminal device may execute step 202 in response to the interface display instruction. If the terminal equipment monitors that the data loading task corresponding to the task identifier is completed, the terminal equipment indicates that the terminal equipment can display the target application interface, and then step 204 is executed; if the terminal device monitors that the data loading task corresponding to the task identifier is completed, it indicates that the terminal device cannot temporarily display the target application interface, and continues to execute step 202 to wait for the completion of the data loading task in step 104, that is, wait for the completion of the acquisition of the loading data.
In this step, the terminal device monitoring whether the data loading task is completed may specifically include: the terminal equipment calls the data preloading framework through the application program to inject the data preloading framework into the monitor, and monitors whether the data loading task corresponding to the task identifier is completed or not through the monitor.
As shown in fig. 2, if the data loading task is not completed, the data preloading framework is executing the data loading task to obtain loading data of the target application Interface, and when the terminal device receives an Interface display instruction input by a User to jump from the first application Interface to the target application Interface, the target application Interface performs User Interface (UI) initialization to initialize Interface elements; the application program calls the data loading frame to inject the monitor, in particular, the application program calls the data loading frame to inject the monitor for monitoring the task identifier; monitoring a data loading task corresponding to the task identifier through a monitor of the data loading frame, if the acquisition of the loading data is not completed, continuing monitoring until the acquisition of the loading data is completed, and distributing the loading data to the monitor corresponding to the task identifier; the data loading frame returns the loading data to the application program through a callback interface of the monitor; the application program displays the target application interface according to the loading data, and specifically, the application program renders the loading data to the target application interface to display the target application interface, so that the target application interface is completely displayed in front of a user.
In this case, the total time consumption of interface presentation=interface initialization time+data loading time+data presentation time, for example, the interface initialization time is 200ms, and the total time consumption is 600ms when the data loading time is 200ms and the data presentation time is 200ms respectively. The data loading time is the remaining time for completing the data loading task, namely: the remaining time to load the data is obtained. Compared with 1000ms of total time consumption of interface display in the related art, the scheme of the embodiment of the invention greatly reduces the data loading time due to the data preloading, thereby reducing the total time consumption of interface display.
Step 204, the terminal device executes the target application interface displayed by the loaded data in step 108.
As shown in fig. 2, when the terminal device receives an interface presentation instruction input by a user to jump from the first application interface to the target application interface, the data loading task is completed, and the target application interface performs UI initialization to initialize interface elements; the application program calls the data loading frame to inject the monitor, in particular, the application program calls the data loading frame to inject the monitor for monitoring the task identifier; monitoring a data loading task corresponding to the task identifier through a monitor of the data loading frame, and then monitoring that the loading data acquisition is completed and distributing the loading data to the monitor corresponding to the task identifier; the data loading frame returns the loading data to the application program through a callback interface of the monitor; the application program displays the target application interface according to the loading data, and specifically, the application program renders the loading data to the target application interface to display the target application interface, so that the target application interface is completely displayed in front of a user.
In this case, total time spent for interface presentation=interface initialization time+data presentation time, for example, when the interface is initialized to 200ms and the data presentation time is 200ms, the total time spent is 400ms. Compared with 1000ms of total time consumption of interface display in the related art, the scheme of the embodiment of the invention completely omits data loading time due to data preloading, thereby greatly reducing the total time consumption of interface display.
According to the technical scheme of the interface display method, when an application program runs, a data loading task of a target application interface is generated and executed to acquire loading data, and when the data loading task is completed, the target application interface is displayed through the loading data in response to a received interface display instruction.
In the technical scheme of the interface display method provided by the embodiment of the invention, the time for loading the data is advanced, and the total time consumption is reduced or equal to the sum of the interface initialization time and the data display time through the data preloading. In general, the residence time of the user on the first application interface only exceeds a few seconds, after the completion of obtaining the loading data, the user clicks the button to jump from the first application interface to the target application interface, and the loading data needed by the target application interface is loaded and completed at a proper time in the display process of the first application interface, so that the display speed of the interface is improved.
In the embodiment of the invention, the data is preloaded through the thread pool of the data preloading frame, and after the application program is accessed into the data preloading frame, the data loading time is reduced and omitted when the application program is switched from the first application interface to the target application interface, so that the interface display speed is improved, the satisfaction degree of a user in using the vehicle-mounted application program is improved, the brand acceptance degree of the vehicle is indirectly improved, and the method plays a positive role in selling the vehicle. The embodiment of the invention adopts the scheme of data preloading, reduces the time waiting for a user to operate the vehicle-mounted application program, improves the satisfaction degree of the user, and indirectly improves the acceptance degree of the automobile brands.
The embodiment of the invention provides an interface display device which is applied to terminal equipment, and the terminal equipment installs an application program. Fig. 4 is a schematic structural diagram of an interface display device according to an embodiment of the present invention, as shown in fig. 4, where the device includes: a generation module 11, an execution module 12, a receiving module 13 and a presentation module 14.
The generating module 11 is used for generating a data loading task of the target application interface when the application program runs; the execution module 12 is configured to execute the data loading task to obtain loading data; the receiving module 13 is used for receiving an interface display instruction; the presentation module 14 is configured to present the target application interface via the loading data when the data loading task is completed in response to the interface presentation instruction.
In the embodiment of the invention, the device further comprises: and an operation module 15. The running module 15 is used for starting the application program; alternatively, the display module 14 is configured to display a first application interface of the application program.
In the embodiment of the invention, the device further comprises: a monitoring module 16. The generating module 11 is further configured to generate a task identifier at the same time of generating a data loading task of the target application interface, where the task identifier is used to identify the data loading task; the monitoring module 16 is configured to monitor, according to the task identifier, whether a data loading task corresponding to the task identifier is completed, and if the data loading task is completed, trigger the display module 14 to execute the step of displaying the target application interface according to the loading data; and if the data loading task is not completed, executing the step of monitoring whether the data loading task is completed or not through the task identification.
In the embodiment of the present invention, the execution module 12 is specifically configured to execute the data loading task through the set thread pool, so as to obtain loading data.
In the embodiment of the present invention, the execution module 12 is specifically configured to read data from a local database, acquire data from a server, or acquire loading data from a local disk file.
In the embodiment of the present invention, the terminal device installs a data preloading frame, and the generating module 11 is specifically configured to generate a data preloading task through the invoked data preloading frame.
In the embodiment of the present invention, the terminal device installs a data preloading framework, and the monitoring module 16 is specifically configured to invoke the data preloading framework through the application program to inject into the monitor; and monitoring whether the data loading task corresponding to the task identifier is completed or not through the monitor.
According to the technical scheme of the interface display device, when an application program runs, a data loading task of a target application interface is generated and executed to acquire loading data, and when the data loading task is completed, the target application interface is displayed through the loading data in response to a received interface display instruction.
The embodiment of the invention provides a storage medium, which comprises a stored program, wherein the program is used for controlling equipment where the storage medium is located to execute the steps of the embodiment of the interface display method, and the specific description can be seen from the embodiment of the interface display method.
The embodiment of the invention provides a terminal device, which comprises a memory and a processor, wherein the memory is used for storing information comprising program instructions, the processor is used for controlling the execution of the program instructions, and the program instructions are loaded and executed by the processor to realize the steps of the embodiment of the interface display method.
Fig. 5 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 5, the terminal device 20 of this embodiment includes: the processor 21, the memory 22, and the computer program 23 stored in the memory 22 and capable of running on the processor 21, where the computer program 23 is executed by the processor 21 to implement the interface presentation method in the embodiment, and is not repeated here. Alternatively, the computer program, when executed by the processor 21, implements the functions of the embodiments applied to each model/unit in the interface display device, and in order to avoid repetition, it is not described in detail herein.
Terminal device 20 includes, but is not limited to, a processor 21, a memory 22. It will be appreciated by those skilled in the art that fig. 5 is merely an example of terminal device 20 and is not intended to limit terminal device 20, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., a terminal device may also include an input-output device, a network access device, a bus, etc.
The processor 21 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 22 may be an internal storage unit of the terminal device 20, such as a hard disk or a memory of the terminal device 20. The memory 22 may also be an external storage device of the terminal device 20, such as a plug-in hard disk provided on the terminal device 20, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like. Further, the memory 22 may also include both an internal storage unit and an external storage device of the terminal device 20. The memory 22 is used for storing computer programs and other programs and data required by the terminal device. The memory 22 may also be used to temporarily store data that has been output or is to be output.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the several embodiments provided in the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a Processor (Processor) to perform part of the steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather to enable any modification, equivalent replacement, improvement or the like to be made within the spirit and principles of the invention.