CN107391119B - Method and device for realizing horizontal and vertical screens - Google Patents

Method and device for realizing horizontal and vertical screens Download PDF

Info

Publication number
CN107391119B
CN107391119B CN201710524367.7A CN201710524367A CN107391119B CN 107391119 B CN107391119 B CN 107391119B CN 201710524367 A CN201710524367 A CN 201710524367A CN 107391119 B CN107391119 B CN 107391119B
Authority
CN
China
Prior art keywords
class
screen
service logic
horizontal
logic class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710524367.7A
Other languages
Chinese (zh)
Other versions
CN107391119A (en
Inventor
张磊
陈少杰
张文明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201710524367.7A priority Critical patent/CN107391119B/en
Publication of CN107391119A publication Critical patent/CN107391119A/en
Application granted granted Critical
Publication of CN107391119B publication Critical patent/CN107391119B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method and a device for realizing a horizontal screen and a vertical screen, wherein the method comprises the following steps: s1, defining abstract functions corresponding to different business logics between a horizontal screen and a vertical screen and concrete functions corresponding to the same business logics in a first business logic class; s2, defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, wherein the second service logic class and the third service logic class inherit the first service logic class; s3, duplicating the abstract function in the first service logic class in the second service logic class and the third service logic class. According to the invention, by defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen in an abstract class and delaying the abstract functions into a subclass for instantiation, sharing of the same business logics of the horizontal screen and the vertical screen is realized on one hand; on the other hand, the service logic of the horizontal and vertical screens is decoupled, and the maintainability and the expansibility of the program are improved.

Description

Method and device for realizing horizontal and vertical screens
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for realizing a horizontal screen and a vertical screen.
Background
During the development of live software there is typically a gift module through which a user can gift a favorite anchor. Generally, the player has two layout situations, one is horizontal screen playing, and the other is vertical screen playing. When the player is playing in a landscape mode, the whole player occupies the whole width of the screen, and when the player is playing in a portrait mode, the player interface only occupies the position of the upper half part of the screen. Due to the fact that the states of the horizontal and vertical screens are different, the presentation modes of the gift interfaces in the horizontal and vertical screens are different.
In the current development mode, logic judgment is carried out in a gift panel, and if the current screen state is judged to be a transverse screen state, the gift panel in the transverse screen state is displayed; and if the current screen state is judged to be the vertical screen state, displaying the gift panel in the vertical screen state. Due to the fact that a plurality of different business logics exist in the horizontal and vertical screen states, all related business logics in the horizontal and vertical screen states are mixed and masoned in the gift panel. As business functions continue to increase, the logic within the gift panels becomes increasingly difficult to maintain, and even a small change can introduce a wide variety of errors.
Therefore, in the prior art, business logics in a horizontal screen and a vertical screen are coupled together, errors are easy to occur during change, and the maintainability of a program is poor.
Disclosure of Invention
In order to overcome the problem that the service logics in the horizontal and vertical screen states are coupled together to cause difficulty in maintaining programs or at least partially solve the problem, the invention provides a method and a device for realizing the horizontal and vertical screens.
According to a first aspect of the present invention, a method for implementing a horizontal screen and a vertical screen is provided, which includes:
s1, defining a first business logic class of the abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics, and realizing the same business logics between the horizontal screen and the vertical screen through the concrete functions;
s2, defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, wherein the second service logic class and the third service logic class inherit the first service logic class;
and S3, duplicating the abstract function in the first service logic class in the second service logic class and the third service logic class, realizing the service logic of the horizontal screen through the abstract function in the second service logic class, and realizing the service logic of the vertical screen through the abstract function in the third service logic class.
Specifically, the step S1 specifically includes:
and defining a specific function corresponding to page initialization logic in the first service logic class, and realizing page initialization of a horizontal screen and a vertical screen through the specific function corresponding to the page initialization logic.
Specifically, the step S1 specifically includes:
s11, defining abstract functions corresponding to layout file loading logics in the first business logic class;
s12, defining abstract functions corresponding to the button display logics in the first business logic class;
correspondingly, the step S3 specifically includes:
copying abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class, and realizing layout file loading and button display in the horizontal screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class;
and duplicating the layout file loading logic and the abstract function corresponding to the button display logic in the third service logic class, and realizing layout file loading and button display in a vertical screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the third service logic class.
Specifically, the step S11 and the step S12 further include:
and defining specific functions corresponding to network communication and data analysis in the first service logic class, and realizing the network communication and the data analysis through the specific functions corresponding to the network communication and the data analysis.
Specifically, the step of implementing network communication and data analysis through the specific function corresponding to the network communication and data analysis specifically includes:
sending an HTTP network request to a server according to the network request address;
receiving JSON data of the character string type returned by the server;
and analyzing the JSON data into a corresponding object of a javaBean type.
Specifically, the step of analyzing the JSON data into corresponding javaBean objects specifically includes:
converting the JSON data into a JSONObject object by calling a constructor of the JSONObject class;
and converting the JSONObject object into a javaBean object by calling a method in the JSONObject object.
Specifically, the loading of the layout files in the corresponding horizontal screen and the vertical screen by loading the corresponding abstract functions through the layout files in the second service logic class and the third service logic class includes:
returning the layout file number of the horizontal screen through an abstract function corresponding to the layout file loading logic in the second business logic class;
returning the layout file number of the vertical screen through an abstract function corresponding to the layout file loading logic in the third business logic class;
and loading the layout file of the transverse screen according to the layout file number of the transverse screen, and loading the layout file of the vertical screen according to the layout file number of the vertical screen.
According to a second aspect of the present invention, there is provided a device for implementing horizontal and vertical screens, comprising:
the first definition unit is used for defining a first business logic class of an abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between a horizontal screen and a vertical screen and concrete functions corresponding to the same business logics, and realizing corresponding business logics through the concrete functions;
the second definition unit is used for defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, and the second service logic class and the third service logic class inherit the first service logic class;
and the implementation unit is used for duplicating the abstract function in the first business logic class in the second business logic class and the third business logic class, implementing the business logic of the horizontal screen through the abstract function in the second business logic class, and implementing the business logic of the vertical screen through the abstract function in the third business logic class.
According to a third aspect of the present invention, there is provided a landscape screen implementation apparatus, including:
at least one processor, at least one memory, and a bus; wherein the content of the first and second substances,
the processor and the memory complete mutual communication through the bus;
the memory stores program instructions executable by the processor, which when called by the processor are capable of performing the method as previously described.
According to a fourth aspect of the invention, there is provided a non-transitory computer readable storage medium storing a computer program of the method as described above.
The invention provides a method and a device for realizing horizontal and vertical screens, wherein the method defines abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics in abstract classes, and delays the abstract functions to subclasses corresponding to the business logics of the horizontal screen and the vertical screen for instantiation operation, so that sharing of the same business logics of the horizontal screen and the vertical screen is realized on one hand; on the other hand, the service logic of the horizontal and vertical screens is decoupled, and the maintainability and the expansibility of the program are improved.
Drawings
Fig. 1 is a schematic overall flow chart of a horizontal and vertical screen implementation method provided by an embodiment of the invention;
fig. 2 is a schematic flow chart of a horizontal and vertical screen implementation method according to another embodiment of the present invention;
FIG. 3 is a schematic diagram of an overall structure of a horizontal and vertical screen implementation apparatus provided in an embodiment of the present invention;
fig. 4 is a schematic view of an overall structure of a horizontal and vertical screen implementation device provided by an embodiment of the present invention.
Detailed Description
The following detailed description of embodiments of the present invention is provided in connection with the accompanying drawings and examples. The following examples are intended to illustrate the invention but are not intended to limit the scope of the invention.
Fig. 1 is a schematic overall flow chart of a horizontal and vertical screen implementation method provided in an embodiment of the present invention. In general, the method comprises: s1, defining a first business logic class of the abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics, and realizing the same business logics between the horizontal screen and the vertical screen through the concrete functions; s2, defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, wherein the second service logic class and the third service logic class inherit the first service logic class; and S3, duplicating the abstract function in the first service logic class in the second service logic class and the third service logic class, realizing the service logic of the horizontal screen through the abstract function in the second service logic class, and realizing the service logic of the vertical screen through the abstract function in the third service logic class.
Specifically, in S1, abstracting and separating the business logic of the horizontal and vertical screens, and finally extracting an independent base class, where the base class is used as the first business logic class. The first business logic class is used for realizing the same business logic between the horizontal screen and the vertical screen, so that the same business logic between the horizontal screen and the vertical screen can be shared. Since the first service logic class needs to be compatible with the service logic of the horizontal screen and the vertical screen, the first service logic class cannot be defined as a concrete implementation class, but is defined as an abstract class. There may be abstract functions and concrete implementation functions in the abstract class. The abstract function needs to be delayed to a subclass for instantiation operation so as to realize corresponding business logic. The specific function directly realizes corresponding business logic without delaying to subclass for instantiation operation. In the first business logic class, abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics are defined. And realizing the same business logic between the horizontal screen and the vertical screen through the specific function in the first business logic class.
In S2, a second service logic class of the horizontal screen and a third service logic class of the vertical screen are defined, and both the second service logic class and the third service logic class inherit the first service logic class. Due to the inheritance relationship between the second service logic class and the third service logic class and the first service logic class, the second service logic class and the third service logic class have all functions in the first service logic class.
In S3, since the abstract function needs to be delayed to a subclass for instantiation to implement the corresponding service logic, the abstract function in the first service logic class is rewritten in the second service logic class and the third service logic class, the service logic of the horizontal screen is implemented by the abstract function in the second service logic class, and the service logic of the vertical screen is implemented by the abstract function in the third service logic class.
In the embodiment, by defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics in an abstract class and delaying the abstract functions to subclasses corresponding to the business logics of the horizontal screen and the vertical screen for instantiation, sharing of the same business logics of the horizontal screen and the vertical screen is realized on one hand; on the other hand, the service logic of the horizontal and vertical screens is decoupled, and the maintainability and the expansibility of the program are improved.
On the basis of the foregoing embodiment, step S1 in this embodiment specifically includes: and defining a specific function corresponding to page initialization logic in the first service logic class, and realizing page initialization of a horizontal screen and a vertical screen through the specific function corresponding to the page initialization logic.
Specifically, both the horizontal screen page and the vertical screen page need to be page initialized, and the page initialization mainly applies for public resources so as to facilitate later use of the public resources. Since the page initialization is the same business logic between the horizontal screen and the vertical screen, a specific function class corresponding to the page initialization logic is defined in the first business logic class to implement the page initialization, for example, a public void init () function is defined to implement the page initialization.
On the basis of any one of the above embodiments, fig. 2 is a flowchart of a horizontal and vertical screen implementation method provided by the embodiment of the present invention, and as shown in fig. 2, the step S1 specifically includes: s11, defining abstract functions corresponding to layout file loading logics in the first business logic class; s12, defining abstract functions corresponding to the button display logics in the first business logic class; correspondingly, the step S3 specifically includes: copying abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class, and realizing layout file loading and button display in the horizontal screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class; and duplicating the layout file loading logic and the abstract function corresponding to the button display logic in the third service logic class, and realizing layout file loading and button display in a vertical screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the third service logic class.
Specifically, in S11, since the landscape and portrait pages are rendered differently, the page needs to be dynamically loaded. And defining a layout file in the first business logic class to load a corresponding abstract function, such as defining an abstract public int getLayoutId () function. Wherein abstrate indicates that the function is an abstract function, and the abstract function may exist in an abstract class. The abstract function is only declared and is not realized, and the realization needs to be delayed to be realized by subclasses, so that the separation of layout file loading logics of a horizontal screen and a vertical screen is realized. In S12, since the width of the screen is different between the landscape screen and the portrait screen, the display form of the partial button is different between the landscape screen and the portrait screen. In order to solve the problem that the button displays different logics under the conditions of horizontal and vertical screens, abstract functions corresponding to the button display logics, such as abstrat void showButtons (), are defined. And the abstract function corresponding to the button display logic is used for displaying the button information. Because the function corresponding to the button display logic is an abstract function, the concrete business implementation of the function is delayed to be realized by subclasses, and therefore the separation of the button display logic of the horizontal screen and the vertical screen is realized.
And duplicating abstract functions corresponding to the layout file loading logic and the button display logic, such as a getLayoutId function and showButtons, in a second service logic class of the horizontal screen, and realizing the layout file loading and the button display in the horizontal screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the second service logic class. And only processing the display logic of the buttons of the horizontal screen in the showButtons function in the second service logic class of the horizontal screen, and displaying the buttons in the horizontal screen state. And duplicating the layout file loading logic and the abstract function corresponding to the button display logic in the third service logic class, such as a getLayoutId function and showButtons, and realizing layout file loading and button display in a vertical screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the third service logic class. And only processing the display logic of the buttons of the vertical screen in the showButtons function in the third service logic class of the vertical screen, and displaying the buttons in the vertical screen state. The present embodiments are not limited to function names of specific implementations.
In the embodiment, by defining the abstract functions corresponding to the layout file loading logic and the button display logic in the abstract class, duplicating the abstract functions in the service logic classes of the horizontal screen and the vertical screen, and instantiating the duplicated abstract functions, the layout file loading and the button display in the horizontal screen and the vertical screen are respectively realized, so that the service logic of the horizontal screen and the vertical screen is decoupled, and the maintainability and the expansibility of a program are improved.
On the basis of any of the above embodiments, the present embodiment further includes, between the step S11 and the step S12: and defining specific functions corresponding to network communication and data analysis logics in the first service logic class, and realizing network communication and data analysis through the specific functions corresponding to the network communication and data analysis logics.
Specifically, since the network requests sent by the landscape and portrait pages are one request, and the data returned by analyzing the network requests is the same data, there is no difference, the function corresponding to the network communication and data analysis logic is defined as a specific function, such as public void getNetData (String url), where url is the network request address. And acquiring corresponding data according to the network request address. And realizing network communication and data analysis through specific functions corresponding to the network communication and data analysis logics. The present embodiments are not limited to function names of specific implementations.
On the basis of any of the above embodiments, in this embodiment, the step specific packet for implementing network communication and data analysis is implemented by using the specific function corresponding to the network communication and data analysis logic
Comprises the following steps: sending an HTTP network request to a server according to the network request address; receiving JSON data of the character string type returned by the server; and analyzing the JSON data into a corresponding object of a javaBean type.
Specifically, a standard HTTP network request is sent according to the delivered network request address. After the HTTP network request is successful, the server returns a String of String type JSON data. And acquiring information required to be displayed on the horizontal and vertical screens through a standard HTTP request. And after receiving the JSON data sent by the server, analyzing the standard JSON data, and analyzing the data in the standard JSON format into corresponding javaBean objects.
On the basis of any one of the above embodiments, the step of parsing the JSON data into corresponding javaBean objects in this embodiment specifically includes: converting the JSON data into a JSONObject object by calling a constructor of the JSONObject class; and converting the JSONObject object into a javaBean object by calling a method in the JSONObject object.
Specifically, the JSON data of String type is converted into JSONObject type object jobby calling the constructor of the JSONObject class. And converting the jobobject into a javaBean object by calling a parse method in the jobobject, thereby completing the type conversion of JSON data.
On the basis of any of the foregoing embodiments, in this embodiment, implementing the loading of the layout files in the corresponding horizontal screen and the vertical screen by using the abstract functions corresponding to the layout file loading logics in the second service logic class and the third service logic class includes: returning the layout file number of the horizontal screen through an abstract function corresponding to the layout file loading logic in the second business logic class;
returning the layout file number of the vertical screen through an abstract function corresponding to the layout file loading logic in the third business logic class;
and loading the layout file of the transverse screen according to the layout file number of the transverse screen, and loading the layout file of the vertical screen according to the layout file number of the vertical screen.
Specifically, the R.id.Hxxxx method provided by the system is called to obtain the layout file numbers of the horizontal screen and the vertical screen, and the obtained layout file numbers of the horizontal screen and the vertical screen are returned. And calling a findViewById function according to the layout file numbers of the horizontal screen and the vertical screen to dynamically load the corresponding horizontal screen layout file and the vertical screen layout file. The present embodiments are not limited to function names of specific implementations.
In another embodiment of the present invention, a horizontal and vertical screen implementation apparatus is provided, and fig. 3 is a block diagram of a horizontal and vertical screen implementation apparatus provided in an embodiment of the present invention, where the apparatus includes a first defining unit 1, a second defining unit 2, and an implementation unit 3, where:
the first definition unit 1 is used for defining a first business logic class of an abstract type for business logic of a horizontal screen and a vertical screen; in the first business logic class, defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics, and realizing the same business logics between the horizontal screen and the vertical screen through the concrete functions; the second defining unit 2 is configured to define a second service logic class of the horizontal screen and a third service logic class of the vertical screen, where the second service logic class and the third service logic class inherit the first service logic class; the implementation unit 3 is configured to duplicate the abstract function in the first service logic class in the second service logic class and the third service logic class, implement the service logic of the horizontal screen through the abstract function in the second service logic class, and implement the service logic of the vertical screen through the abstract function in the third service logic class.
Specifically, the business logic of the horizontal and vertical screens is abstracted and separated, and finally, the business logic is extracted to form an independent base class, and the base class is used as a first business logic class. The first business logic class is used for realizing the same business logic between the horizontal screen and the vertical screen, so that the same business logic between the horizontal screen and the vertical screen can be shared. Since the first service logic class needs to be compatible with the service logic of the horizontal screen and the vertical screen, the first service logic class cannot be defined as a concrete implementation class, but is defined as an abstract class. There may be abstract functions and concrete implementation functions in the abstract class. The abstract function needs to be delayed to a subclass for instantiation operation so as to realize corresponding business logic. The specific function directly realizes corresponding business logic without delaying to subclass for instantiation operation. In the first service logic class, the first defining unit 1 defines abstract functions corresponding to different service logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same service logics. And realizing the same business logic between the horizontal screen and the vertical screen through the specific function in the first business logic class.
The second definition unit 2 defines a second service logic class of the horizontal screen and a third service logic class of the vertical screen, and both the second service logic class and the third service logic class inherit the first service logic class. Due to the inheritance relationship between the second service logic class and the third service logic class and the first service logic class, the second service logic class and the third service logic class have all functions in the first service logic class.
Since the abstract function needs to be delayed to a subclass for instantiation operation so as to implement the corresponding service logic, the implementation unit 3 overwrites the abstract function in the first service logic class in the second service logic class and the third service logic class, implements the service logic of the horizontal screen through the abstract function in the second service logic class, and implements the service logic of the vertical screen through the abstract function in the third service logic class.
In the embodiment, by defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics in an abstract class and delaying the abstract functions to subclasses corresponding to the business logics of the horizontal screen and the vertical screen for instantiation, sharing of the same business logics of the horizontal screen and the vertical screen is realized on one hand; on the other hand, the service logic of the horizontal and vertical screens is decoupled, and the maintainability and the expansibility of the program are improved.
On the basis of the foregoing embodiments, in this embodiment, the first defining unit is specifically configured to:
and defining a specific function corresponding to page initialization logic in the first service logic class, and realizing page initialization of a horizontal screen and a vertical screen through the specific function corresponding to the page initialization logic.
On the basis of the above embodiments, in this embodiment, the first defining unit includes:
a first loading unit, configured to define, in the first service logic class, an abstract function corresponding to a layout file loading logic;
the second loading unit is used for defining an abstract function corresponding to the button display logic in the first business logic class;
correspondingly, the implementation unit is specifically configured to:
copying abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class, and realizing layout file loading and button display in the horizontal screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class;
and duplicating the layout file loading logic and the abstract function corresponding to the button display logic in the third service logic class, and realizing layout file loading and button display in a vertical screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the third service logic class.
On the basis of the foregoing embodiments, in this embodiment, the first defining unit further includes:
and the communication unit is used for defining a specific function corresponding to network communication and data analysis in the first service logic class and realizing the network communication and the data analysis through the specific function corresponding to the network communication and the data analysis.
On the basis of the foregoing embodiment, the communication unit in this embodiment is specifically configured to:
the sending unit is used for sending an HTTP network request to the server according to the network request address;
the interpretation unit is used for receiving JSON data of the character string type returned by the server;
and the analysis unit is used for analyzing the JSON data into a corresponding object of the javaBean type.
On the basis of the foregoing embodiment, in this embodiment, the parsing unit is specifically configured to:
converting the JSON data into a JSONObject object by calling a constructor of the JSONObject class;
and converting the JSONObject object into a javaBean object by calling a method in the JSONObject object.
On the basis of the foregoing embodiment, the implementation unit in this embodiment is specifically configured to:
returning the layout file number of the horizontal screen through an abstract function corresponding to the layout file loading logic in the second business logic class;
returning the layout file number of the vertical screen through an abstract function corresponding to the layout file loading logic in the third business logic class;
and loading the layout file of the transverse screen according to the layout file number of the transverse screen, and loading the layout file of the vertical screen according to the layout file number of the vertical screen.
The present embodiment provides a horizontal and vertical screen implementation device, and fig. 4 is a schematic diagram of an overall structure of the horizontal and vertical screen implementation device provided in the embodiment of the present invention, where the device includes: at least one processor 41, at least one memory 42, and a bus 43; wherein the content of the first and second substances,
the processor 41 and the memory 42 complete mutual communication through the bus 43;
the memory 42 stores program instructions executable by the processor 41, and the processor calls the program instructions to execute the methods provided by the method embodiments, for example, the method includes: s1, defining a first business logic class of the abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics, and realizing the same business logics between the horizontal screen and the vertical screen through the concrete functions; s2, defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, wherein the second service logic class and the third service logic class inherit the first service logic class; and S3, duplicating the abstract function in the first service logic class in the second service logic class and the third service logic class, realizing the service logic of the horizontal screen through the abstract function in the second service logic class, and realizing the service logic of the vertical screen through the abstract function in the third service logic class.
The present embodiments provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the methods provided by the above method embodiments, for example, including: s1, defining a first business logic class of the abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics, and realizing the same business logics between the horizontal screen and the vertical screen through the concrete functions; s2, defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, wherein the second service logic class and the third service logic class inherit the first service logic class; and S3, duplicating the abstract function in the first service logic class in the second service logic class and the third service logic class, realizing the service logic of the horizontal screen through the abstract function in the second service logic class, and realizing the service logic of the vertical screen through the abstract function in the third service logic class.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, the method of the present application is only a preferred embodiment and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for realizing horizontal and vertical screens is characterized by comprising the following steps:
s1, defining a first business logic class of the abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between the horizontal screen and the vertical screen and concrete functions corresponding to the same business logics, and realizing the same business logics between the horizontal screen and the vertical screen through the concrete functions;
s2, defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, wherein the second service logic class and the third service logic class inherit the first service logic class;
and S3, duplicating the abstract function in the first service logic class in the second service logic class and the third service logic class, realizing the service logic of the horizontal screen through the abstract function in the second service logic class, and realizing the service logic of the vertical screen through the abstract function in the third service logic class.
2. The method for implementing horizontal and vertical screens according to claim 1, wherein the step S1 specifically includes:
and defining a specific function corresponding to page initialization logic in the first service logic class, and realizing page initialization of a horizontal screen and a vertical screen through the specific function corresponding to the page initialization logic.
3. The method for implementing horizontal and vertical screens according to claim 1, wherein the step S1 specifically includes:
s11, defining abstract functions corresponding to layout file loading logics in the first business logic class;
s12, defining abstract functions corresponding to the button display logics in the first business logic class;
correspondingly, the step S3 specifically includes:
copying abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class, and realizing layout file loading and button display in the horizontal screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the second business logic class;
and duplicating the layout file loading logic and the abstract function corresponding to the button display logic in the third service logic class, and realizing layout file loading and button display in a vertical screen through the abstract functions corresponding to the layout file loading logic and the button display logic in the third service logic class.
4. The method for implementing horizontal and vertical screens according to claim 3, further comprising between the step S11 and the step S12:
and defining specific functions corresponding to network communication and data analysis in the first service logic class, and realizing the network communication and the data analysis through the specific functions corresponding to the network communication and the data analysis.
5. The method for implementing horizontal and vertical screens according to claim 4, wherein the step of implementing network communication and data analysis through the specific function corresponding to the network communication and data analysis specifically comprises:
sending an HTTP network request to a server according to the network request address;
receiving JSON data of the character string type returned by the server;
and analyzing the JSON data into a corresponding object of a javaBean type.
6. The method for realizing horizontal and vertical screens according to claim 5, wherein the step of analyzing the JSON data into corresponding javaBean objects specifically comprises the following steps:
converting the JSON data into a JSONObject object by calling a constructor of the JSONObject class;
and converting the JSONObject object into a javaBean object by calling a method in the JSONObject object.
7. The method for implementing horizontal and vertical screens according to claim 3, wherein loading corresponding abstract functions through the layout files in the second business logic class and the third business logic class to implement loading of the layout files in the corresponding horizontal and vertical screens comprises:
returning the layout file number of the horizontal screen through an abstract function corresponding to the layout file loading logic in the second business logic class;
returning the layout file number of the vertical screen through an abstract function corresponding to the layout file loading logic in the third business logic class;
and loading the layout file of the transverse screen according to the layout file number of the transverse screen, and loading the layout file of the vertical screen according to the layout file number of the vertical screen.
8. The utility model provides a violently erect screen realize device which characterized in that includes:
the first definition unit is used for defining a first business logic class of an abstract type for the business logic of the horizontal and vertical screens; in the first business logic class, defining abstract functions corresponding to different business logics between a horizontal screen and a vertical screen and concrete functions corresponding to the same business logics, and realizing corresponding business logics through the concrete functions;
the second definition unit is used for defining a second service logic class of the horizontal screen and a third service logic class of the vertical screen, and the second service logic class and the third service logic class inherit the first service logic class;
and the implementation unit is used for duplicating the abstract function in the first business logic class in the second business logic class and the third business logic class, implementing the business logic of the horizontal screen through the abstract function in the second business logic class, and implementing the business logic of the vertical screen through the abstract function in the third business logic class.
9. The utility model provides a violently erect screen and realize equipment which characterized in that includes:
at least one processor, at least one memory, and a bus; wherein the content of the first and second substances,
the processor and the memory complete mutual communication through the bus;
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions executable by a processor to implement the method of any one of claims 1 to 7.
CN201710524367.7A 2017-06-30 2017-06-30 Method and device for realizing horizontal and vertical screens Active CN107391119B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710524367.7A CN107391119B (en) 2017-06-30 2017-06-30 Method and device for realizing horizontal and vertical screens

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710524367.7A CN107391119B (en) 2017-06-30 2017-06-30 Method and device for realizing horizontal and vertical screens

Publications (2)

Publication Number Publication Date
CN107391119A CN107391119A (en) 2017-11-24
CN107391119B true CN107391119B (en) 2020-05-12

Family

ID=60334814

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710524367.7A Active CN107391119B (en) 2017-06-30 2017-06-30 Method and device for realizing horizontal and vertical screens

Country Status (1)

Country Link
CN (1) CN107391119B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189498B (en) * 2018-08-07 2021-09-07 武汉斗鱼网络科技有限公司 Android horizontal and vertical screen data synchronization method and device, terminal and readable medium
CN109144750B (en) * 2018-08-21 2021-06-15 武汉斗鱼网络科技有限公司 Message processing method and device, electronic equipment and storage medium
CN109101311B (en) * 2018-08-24 2021-07-23 武汉斗鱼网络科技有限公司 Display view compatibility method and electronic equipment
CN109298853A (en) * 2018-09-10 2019-02-01 武汉斗鱼网络科技有限公司 A kind of message treatment method, device, electronic equipment and storage medium
CN114764484A (en) * 2021-01-13 2022-07-19 武汉斗鱼网络科技有限公司 Lazy loading implementation method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8924845B2 (en) * 2008-02-20 2014-12-30 Lsi Corporation Web application code decoupling and user interaction performance
CN102902805B (en) * 2012-10-15 2017-06-27 东软集团股份有限公司 A kind of page access method and apparatus
US10031586B2 (en) * 2013-06-12 2018-07-24 Amazon Technologies, Inc. Motion-based gestures for a computing device
CN104216715B (en) * 2014-09-02 2017-12-08 深圳市前海圆舟网络科技股份有限公司 A kind of Web App Development Frameworks and method

Also Published As

Publication number Publication date
CN107391119A (en) 2017-11-24

Similar Documents

Publication Publication Date Title
CN107391119B (en) Method and device for realizing horizontal and vertical screens
US9071625B2 (en) Cross-environment event notification
US10127524B2 (en) Shared collaboration canvas
US20160070541A1 (en) Conversion of business suite solutions
US20130066947A1 (en) System and Method for Managing Applications for Multiple Computing Endpoints and Multiple Endpoint Types
US20140082511A1 (en) Method and system for emulating desktop software applications in a mobile communication network
KR102159416B1 (en) Systems and methods for building and using hybrid mobile applications
US20090199213A1 (en) Automatic Connections Between Application Components
CN104995601B (en) It is switched to the machine Web page application program and is switched away from from the machine Web page application program
JP2013546043A (en) Instant remote rendering
CN110019464B (en) Page processing method and device
US20150074634A1 (en) Business suite framework for developing software applications
CN112363794A (en) Rendering method of front-end list type component and electronic equipment
US20170201551A1 (en) Collaborative Platform for Communication, Application Development and Use
US9361710B2 (en) Defining a midlet region space
US20160359654A1 (en) Mobile client application for managing user interface components
CN110673827B (en) Resource calling method and device based on android system and electronic equipment
CN113761871A (en) Rich text rendering method and device, electronic equipment and storage medium
CN107133046B (en) Page construction method and device and electronic terminal
CN106383705B (en) Method and device for setting mouse display state in application thin client
US20180130240A1 (en) Displaying visualization images on portable electronic device
CN112100187A (en) Student learning data storage method and device based on VueJS
CN112783960A (en) Data processing system and method, electronic device, computer-readable storage medium
CN114185845A (en) File management method and device, computer equipment and storage medium
Canfora et al. Toward seamless migration of Java AWT-based applications to personal wireless devices

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant