Page data display method and device based on MVP architecture, and computer device

CN115993964BActive Publication Date: 2026-10-27SHENZHEN YISHIHUOLALA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310171845.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-20
Publication Date
2026-10-27
Estimated Expiration
2043-02-20

AI Technical Summary

Technical Problem

[0002]MVP架构是Model-View-Presenter构架的简称,即模型层-视图层-表现层的缩写,通常情况下,采用MVP架构的软件在展示页面数据时,业务逻辑设置为需要在页面的视图层初始化完成后,才能通过表现层获取页面的页面数据,导致在切换页面时,页面数据展示的速度不够快,降低了软件的使用体验

Benefits of technology

[0003]为解决上述背景技术中的至少一个技术问题,本申请实施方式提供了一种基于MVP架构的页面数据展示方法、基于MVP架构的页面数据展示装置、计算机设备及计算机可读存储介质。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115993964B_ABST
    Figure CN115993964B_ABST
Patent Text Reader

Abstract

The application discloses a page data display method based on an MVP architecture. The page data display method comprises the following steps: starting a second page from a first page in a cross process; and initializing a view layer; simultaneously with the first step, a second step of acquiring a presentation layer implementation object of the second page; the presentation layer implementation object acquiring page data required by the second page to be displayed from a model layer; and a third step of calling the page data from the presentation layer for display in the view layer. The application further discloses a page data display device based on the MVP architecture, a computer device and a computer readable storage medium. When the second page is started from the first page in the cross process and the view layer is initialized, the presentation layer implementation object of the second page also acquires the page data required by the second page to be displayed from the model layer, so that the page data is acquired through scheduling after the initialization of the view layer is completed, and the time required for displaying the page data is saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software architecture technology, and in particular to a page data display method based on MVP architecture, a page data display device based on MVP architecture, a computer device, and a computer-readable storage medium. Background Technology

[0002] MVP architecture is short for Model-View-Presenter architecture, which stands for Model Layer-View Layer-Presentation Layer. Typically, software using the MVP architecture requires the business logic to be set so that the page data can only be obtained through the presentation layer after the page's view layer has been initialized. This results in slow page data display when switching pages, reducing the user experience. Summary of the Invention

[0003] To address at least one of the technical problems mentioned above, embodiments of this application provide a page data display method based on MVP architecture, a page data display device based on MVP architecture, a computer device, and a computer-readable storage medium.

[0004] The page data display method based on the MVP architecture implemented in this application is as follows: The first step is to launch the second page across processes from the first page and initialize the view layer. The second step, implemented concurrently with the first step, involves: obtaining the presentation layer implementation object of the second page; and the presentation layer implementation object obtaining the page data to be displayed on the second page from the model layer; and The third step: Retrieve the page data from the presentation layer for display in the view layer.

[0005] In some implementations, launching a second page across processes from a first page includes: Invoke startActivity from the first page to communicate with AMS; and Launch the second page via AMS.

[0006] In some implementations, calling the page data from the presentation layer for display in the view layer includes: Execute the onCreate method of the second page, and bind the presentation layer implementation object of the second page; and The page data obtained by the presentation layer implementation object is called back to the view layer for display.

[0007] In some implementations, the page data display method further includes: Fourth step: The presentation layer obtains the page data to be displayed for all pages that can be directly launched across processes from the second page; Step 5: Launch the third page across processes from the second page based on user input; and initialize the view layer; and Step 6: Retrieve the page data bound to the third page from the presentation layer for display in the view layer.

[0008] The page data display device based on the MVP architecture in this application includes: The first module is used to implement the first step: launching the second page across processes from the first page; and initializing the view layer; The second module is used to perform the second step simultaneously with the first step implemented by the first module: obtaining the presentation layer implementation object of the second page; and the presentation layer implementation object obtaining the page data to be displayed by the second page from the model layer; and The third module is used to implement the third step: calling the page data from the presentation layer for display in the view layer.

[0009] In some implementations, the first module, when performing the first step, is further configured to: Invoke startActivity from the first page to communicate with AMS; and Launch the second page via AMS.

[0010] In some embodiments, the third module, when implementing the third step, is further configured to: Execute the onCreate method of the second page, and bind the presentation layer implementation object of the second page; and The page data obtained by the presentation layer implementation object is called back to the view layer for display.

[0011] In some embodiments, the page data display device further includes: The fourth module is used to implement the fourth step: the presentation layer obtains the page data to be displayed for all pages that can be directly launched across processes from the second page; Fifth step: Used to implement the fifth step: launching the third page across processes from the second page based on user input; and initializing the view layer; and Step 6: To implement Step 6: Retrieve the page data bound to the third page from the presentation layer for display in the view layer.

[0012] The computer device according to embodiments of this application includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, and the one or more computer programs are configured to execute the page data display method based on the MVP architecture according to any embodiment of this application.

[0013] The non-volatile computer-readable storage medium of this application stores a computer program that, when executed by one or more processors, causes the processors to perform the page data display method based on the MVP architecture described in any embodiment of this application.

[0014] In the page data display method, page data display device, computer device, and computer-readable storage medium based on the MVP architecture of this application, when the second page is launched across processes from the first page and the view layer is initialized, the presentation layer implementation object of the second page also obtains the page data to be displayed by the second page from the model layer. It is not necessary to wait for the view layer to be initialized before scheduling to obtain the page data, which saves the time required to display the page data of the second page and improves the user experience of the software.

[0015] Additional aspects and advantages of the embodiments of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description

[0016] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, wherein: Figure 1 This is a flowchart illustrating the page data display method based on the MVP architecture according to the first embodiment of this application. Figure 2 This is a flowchart illustrating the page data display method based on the MVP architecture according to the second embodiment of this application. Figure 3 This is a flowchart illustrating the page data display method based on the MVP architecture according to the third embodiment of this application. Figure 4 This is a flowchart illustrating the page data display method based on the MVP architecture according to the fourth embodiment of this application. Figure 5 This is a schematic diagram of the modules of the page data display device based on the MVP architecture according to the fifth embodiment of this application; Figure 6 This is a schematic diagram of the modules of the page data display device based on the MVP architecture according to the sixth embodiment of this application; Figure 7 This is a schematic diagram illustrating communication between a computer-readable storage medium and a processor in certain embodiments of this application; Figure 8 This is a schematic diagram of a computer device according to certain embodiments of this application. Detailed Implementation

[0017] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of this application, and should not be construed as limiting the embodiments of this application.

[0018] MVP architecture is short for Model-View-Presenter architecture. The Model layer represents the business logic and entity model, providing data to the Presentation layer. The View layer is the page that the user sees and interacts with. It displays relevant data to the user and accepts user input, but it doesn't perform any actual business logic processing. The main application logic is implemented within the Presentation layer, which completely separates the data layer from the View layer. All interactions occur within the View layer, while specific business logic is handled by the View layer's interface implementation classes.

[0019] The following section will introduce a page data display method based on the MVP architecture. Of course, the page data display method can also be used on other software architectures, and there are no restrictions here.

[0020] Please see Figure 1 , Figure 1 This is a flowchart illustrating the page data display method based on the MVP architecture according to the first embodiment of this application. In some embodiments, the page data display method based on the MVP architecture includes a first step 01, a second step 02, and a third step 03.

[0021] The first step 01 includes step 011: launching the second page across processes from the first page; and step 012: initializing the view layer. The second step 02 includes step 021: obtaining the presentation layer implementation object of the second page; and step 022: the presentation layer implementation object obtaining the page data to be displayed on the second page from the model layer. The third step 03 includes calling the page data from the presentation layer for display in the view layer.

[0022] In the page data display method based on the MVP architecture, when the second page is launched across processes from the first page and the view layer is initialized, the presentation layer implementation object of the second page also obtains the page data that the second page needs to display from the model layer. It does not need to wait for the view layer to be initialized before scheduling to obtain the page data, which saves the time required to display the page data of the second page and improves the user experience of the software.

[0023] Specifically, in traditional business logic, when the target page is launched, the original page uses cross-process scheduling to eventually open the target page. After the target page is launched, the view layer calls the presentation layer, which in turn calls the model layer to retrieve data and then sends a callback to the view layer to display the target page's display data. In this traditional business logic, the retrieval of the target page's display data requires waiting for the target page to initialize before it can begin. However, the retrieval of the target page's display data does not actually depend on the target page's initialization. Therefore, the traditional business logic leads to a problem of excessively long display time for page data. In the page data display method of this application, the initialization of the view layer and the retrieval of page data are performed simultaneously. This saves the time of one cross-process communication scheduling when displaying page data on the second page, which is generally between 200ms and 500ms.

[0024] The first page and the second page can be two user pages of the application. Users can switch from the first page to the second page. After the user performs the set operation on the first page, they will need to jump to the second page and display the page data of the second page.

[0025] In step 01, the second page is launched across processes from the first page. The first page can send instructions to the system, and the system will then launch the second page and initialize the view layer in preparation for displaying the page data of the second page.

[0026] Step 02 is performed concurrently with Step 01, meaning that Step 02 and Step 01 begin simultaneously. In Step 02, the presentation layer implementation object of the second page is obtained; that is, the implementation object in the presentation layer used to process the business logic of the second page is obtained, so that page data for the second page can be received from this implementation object later. Additionally, the presentation layer implementation object obtains the page data to be displayed on the second page from the model layer; this action can be performed in parallel with Step 01, saving overall processing time.

[0027] After steps 01 and 02 are completed, step 03 is implemented. In step 03, page data is retrieved from the presentation layer for display in the view layer, allowing the user to see a second page displaying the page data.

[0028] Please see Figure 2 , Figure 2This is a flowchart illustrating the page data display method based on the MVP architecture according to the second embodiment of this application. In some embodiments, step 011: launching the second page across processes from the first page includes the following steps: 0111: Invoke startActivity from the first page to communicate with AMS; and 0112: Launch the second page via AMS.

[0029] AMS stands for ActivityManagerService, a crucial service in Android that manages the four main components of Android and coordinates the processes of various applications. The first page calls the startActivity command to communicate with AMS, transmitting the user's request to launch the second page. AMS then launches the second page, thus providing unified management of the launch processes of each page of the application.

[0030] Please see Figure 3 , Figure 3 This is a flowchart illustrating the page data display method based on the MVP architecture according to the third embodiment of this application. In some embodiments, step 03: calling page data from the presentation layer for display in the view layer includes the following steps: 031: Execute the onCreate method of the second page, binding the presentation layer implementation object of the second page; and 032: Callback to the presentation layer implements the retrieved page data to the view layer for display.

[0031] Specifically, after the second page is started by AMS, the onCreate method of the second page can be executed to bind the presentation layer implementation object of the second page, so as to ensure that the page data finally called back is the page data that needs to be displayed. After the presentation layer implementation object obtains the page data from the model layer, the page data is called back to be displayed in the view layer.

[0032] Please see Figure 4 , Figure 4 This is a flowchart illustrating the page data display method based on the MVP architecture according to the fourth embodiment of this application. In some embodiments, the page data display method further includes the following steps: Step 4: The presentation layer obtains the data of all pages to be displayed from the second page that can be launched directly across processes; Step 5: Launch the third page across processes from the second page based on user input; and initialize the view layer; and Step 6: Retrieve the page data bound to the third page from the presentation layer for display in the view layer.

[0033] Specifically, in step 4, the presentation layer obtains the page data to be displayed for all pages that can be directly launched across processes from the second page. Here, all pages that can be directly launched across processes from the second page refer to all pages that the user can directly navigate to from the second page. The presentation layer obtains the page data to be displayed for these pages before the user makes any input.

[0034] In step 5, the third page is launched across processes from the second page based on user input, and the view layer is initialized. When the user performs an input operation based on the data displayed on the second page, the third page is launched across processes based on the user input. It can be understood that at this time, the page data of the third page has been obtained by the presentation layer.

[0035] In step 6, the page data bound to the third page is retrieved from the presentation layer for display in the view layer. As mentioned above, the page data for the third page has already been obtained by the presentation layer; it is only necessary to retrieve the page data for the third page after user input and use it for display. By implementing steps 4, 5, and 6, the page data to be displayed on the next page can be obtained in advance. Therefore, when switching pages, there is no need to wait for the time to retrieve page data from the model layer, saving the time required for page data display.

[0036] Please see Figure 5 , Figure 5 This is a schematic diagram of the modules of a page data display device 10 based on an MVP architecture according to a fifth embodiment of this application. In some embodiments, the page data display device 10 includes a first module 11, a second module 12, and a third module 13. The first module 11 can be used to implement the first step 01, that is, the first module 11 can be used to launch a second page across processes from a first page; and initialize the view layer. The second module 12 can be used to implement the second step 02 while the first module 11 is implementing the first step 01, that is, the second module 12 can be used to obtain the presentation layer implementation object of the second page; and the presentation layer implementation object obtains the page data to be displayed by the second page from the model layer. The third module 13 can be used to implement the third step 03, that is, the third module 13 can be used to call page data from the presentation layer for display in the view layer.

[0037] Please continue reading. Figure 5 In some implementations, the first module 11 can be used to implement steps 0111 and 0112, that is, the first module 11 can be used to call startActivity from the first page to communicate with AMS; and to launch the second page through AMS.

[0038] Please continue reading. Figure 5In some implementations, the third module 13 can be used to implement steps 031 and 032, that is, the third module 13 can be used to execute the onCreate method of the second page, bind the presentation layer implementation object of the second page; and call back the page data obtained by the presentation layer implementation object to the view layer for display.

[0039] Please see Figure 6 , Figure 6 This is a schematic diagram of the modules of the page data display device 10 based on the MVP architecture according to the sixth embodiment of this application. In some embodiments, the page data display device 10 further includes a fourth module 14, a fifth module 15, and a sixth module 16. The fourth module 14 can be used to implement the fourth step 04, that is, the fourth module 14 can be used to obtain the page data to be displayed from all pages that can be directly launched across processes from the second page in the presentation layer. The fifth module 15 can be used to implement the fifth step 05, that is, the fifth module 15 can be used to launch the third page across processes from the second page based on user input; and to initialize the view layer. The sixth module 16 can be used to implement the sixth step 06, that is, the sixth module 16 can be used to call the page data bound to the third page from the page data to be displayed in the presentation layer for display in the view layer.

[0040] It should be noted that the implementation details and effects achieved by the page data display device 10 when implementing the page data display method of any embodiment of this application can be referred to the above description of the page data display method, and will not be repeated here.

[0041] In addition, please see Figure 7 This application provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the page data display method described in any of the above embodiments. The computer-readable storage medium includes, but is not limited to, any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic cards, or optical cards. In other words, the storage device includes any medium that stores or transmits information in a readable form by a device (e.g., a computer, a mobile phone), and can be a read-only memory, a disk, or an optical disk, etc.

[0042] The content of the method embodiments in this application is applicable to the storage medium embodiments. The specific functions implemented by the storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above methods. For details, please refer to the description in the method embodiments, which will not be repeated here.

[0043] In addition, please see Figure 8 This application also provides a computer device, which may be a server, a personal computer, or a network device. The computer device includes one or more processors, a memory, and one or more computer programs. The one or more computer programs are stored in the memory and configured to be executed by the one or more processors. The one or more computer programs are configured to perform the page data display method described in any of the above embodiments.

[0044] In the description of this specification, the terms "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with the described embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0045] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.

[0046] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.

Claims

1. A page data display method based on MVP architecture, characterized in that, The page data display method includes: First step: Launch the second page across processes from the first page; and initialize the view layer at the same time as launching the second page; The second step: While initializing the view layer, obtain the presentation layer implementation object of the second page; and the presentation layer implementation object obtains the page data to be displayed by the second page from the model layer; and Third step: Retrieve the page data from the presentation layer for displaying the page data in the view layer; The method of launching a second page across processes from a first page includes: Invoke startActivity from the first page to communicate with AMS; and Launch the second page via AMS; The step of retrieving page data from the presentation layer for display in the view layer includes: Execute the onCreate method of the second page, and bind the presentation layer implementation object of the second page; and The page data obtained by the presentation layer implementation object is called back to the view layer for display.

2. The page data display method based on MVP architecture according to claim 1, characterized in that, The page data display method also includes: Fourth step: The presentation layer obtains the page data to be displayed for all pages that can be directly launched across processes from the second page; Step 5: Launch the third page across processes from the second page based on user input; and initialize the view layer; and Step 6: Retrieve the page data bound to the third page from the presentation layer for display in the view layer.

3. A page data display device based on MVP architecture, characterized in that, The page data display device includes: The first module is used to implement the first step: launching the second page across processes from the first page; and initializing the view layer at the same time as launching the second page; The second module is used to obtain the presentation layer implementation object of the second page while initializing the view layer; and the presentation layer implementation object obtains the page data to be displayed by the second page from the model layer; and The third module is used to implement the third step: calling the page data from the presentation layer for displaying the page data in the view layer; When implementing the first step, the first module is further configured to: Invoke startActivity from the first page to communicate with AMS; and Launch the second page via AMS; When implementing the third step, the third module is also used for: Execute the onCreate method of the second page, and bind the presentation layer implementation object of the second page; and The page data obtained by the presentation layer implementation object is called back to the view layer for display.

4. The page data display device based on MVP architecture according to claim 3, characterized in that, The page data display device also includes: The fourth module is used to implement the fourth step: the presentation layer obtains the page data to be displayed for all pages that can be directly launched across processes from the second page; Module 5: Used to implement step 5: launching the third page across processes from the second page based on user input; and initializing the view layer; and The sixth module is used to implement the sixth step: calling the page data bound to the third page from the presentation layer for display in the view layer.

5. A computer device, characterized in that, include: One or more processors; Memory; and One or more computer programs, wherein the one or more computer programs are stored in the memory and configured to be executed by the one or more processors, the one or more computer programs being configured to: perform the page data display method based on the MVP architecture as described in claim 1 or 2.

6. A non-volatile computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by one or more processors, the processors perform the page data display method based on the MVP architecture as described in claim 1 or 2.

Citation Information

Patent Citations

  • Front-end routing method and apparatus based on asynchronous loading pages

    CN109508436A

  • Page display method and device, computer equipment and medium

    CN114139081A