WO2019041709A1 - Android系统中横竖屏业务逻辑共享的方法及装置 - Google Patents

Android系统中横竖屏业务逻辑共享的方法及装置 Download PDF

Info

Publication number
WO2019041709A1
WO2019041709A1 PCT/CN2017/120194 CN2017120194W WO2019041709A1 WO 2019041709 A1 WO2019041709 A1 WO 2019041709A1 CN 2017120194 W CN2017120194 W CN 2017120194W WO 2019041709 A1 WO2019041709 A1 WO 2019041709A1
Authority
WO
WIPO (PCT)
Prior art keywords
event
function
horizontal
business logic
class
Prior art date
Application number
PCT/CN2017/120194
Other languages
English (en)
French (fr)
Inventor
张磊
张文明
陈少杰
Original Assignee
武汉斗鱼网络科技有限公司
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 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2019041709A1 publication Critical patent/WO2019041709A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • 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
    • 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/445Program loading or initiating
    • 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

Definitions

  • the present invention relates to the field of computer technology, and more particularly to a method and apparatus for sharing horizontal and vertical screen business logic in an Android system.
  • the gift panel is mainly used to carry the gift data.
  • the gift panel is mainly used to carry the gift data.
  • the message processing mechanism inside the gift panel is the same under the business logic of the horizontal and vertical screens. The only difference is that the UI interface of the horizontal screen and the vertical screen is different. of.
  • the traditional scheme uses a horizontal screen set of business logic and a vertical set of business logic when implementing the horizontal and vertical screen business logic.
  • the two sets of business logic are separated and separated.
  • the current implementation method separates the two sets of business logic independently, resulting in the sharing functions being unable to be reused, making the horizontal and vertical screen implementation code redundant.
  • the problem which in turn leads to problems that are difficult to maintain later in the code.
  • the present invention proposes a method and a device for sharing the horizontal and vertical screen business logic in the Android system.
  • a method for sharing horizontal and vertical screen business logic in an Android system including:
  • the event object captured by the Android system callback to the horizontal or vertical event function onTouchEvent is passed to the instantiated object of the business logic class, so that the instantiated object of the business logic class calls the corresponding function function pair.
  • the event object is processed.
  • the step S1 further includes:
  • An event handler function that defines the same parameters as the Android system callback to the horizontal or vertical event function onTouchEvent is defined in the business logic class.
  • the step S3 further includes:
  • the event object captured by the Android system callback to the horizontal or vertical screen event function onTouchEvent is transparently transmitted to the event processing function for processing.
  • the step S3 further includes:
  • the Android system callback is filtered to the event object captured by the horizontal or vertical event function onTouchEvent, and the filtered event object is passed to the event processing function for processing.
  • the step S3 further includes:
  • the event processing function After receiving the event object, the event processing function acquires an event type corresponding to the event object;
  • the instantiated object of the business logic class sends a message updating the UI to the horizontal screen or the vertical screen;
  • the event function is processed by calling a corresponding function function inside the event processing function.
  • the step of filtering the event object captured by the Android system callback to the horizontal or vertical event function onTouchEvent further includes:
  • an apparatus for sharing horizontal and vertical screen business logic in an Android system including:
  • a first defining unit configured to define a business logic class for the same business logic between the horizontal screen and the vertical screen, wherein the business logic class stores a function function corresponding to the same business logic between the horizontal screen and the vertical screen;
  • a second defining unit configured to define a first service class of the horizontal screen and a second service class of the vertical screen according to different business logics between the horizontal screen and the vertical screen, and in the first service class Instantiating the business logic class in a constructor and a constructor of the second business class;
  • a business logic processing unit configured to transfer an event object captured by an Android system callback to an event function onTouchEvent of a horizontal or vertical screen to an instantiated object of the business logic class for invoking an instantiated object of the business logic class
  • the corresponding function function processes the event object.
  • the first defining unit further includes:
  • a sub-unit is defined for defining an event processing function in the business logic class that has the same parameters as the Android system callback to the horizontal or vertical event function onTouchEvent.
  • an apparatus for sharing horizontal and vertical screen business logic in an Android system including a memory, a processor, and a bus, is provided.
  • the processor and the memory complete communication with each other through the bus;
  • the memory stores program instructions executable by the processor, the processor invoking program instructions in the memory to perform the method of any of the preceding.
  • a non-transitory computer readable storage medium storing computer instructions, the computer instructions causing the computer to perform the method of any of the preceding .
  • the method and device for sharing the horizontal and vertical screen business logic in the Android system proposed by the invention realizes the purpose of service sharing by bridging the functions shared by the horizontal and vertical and vertical screen business logics into a customized business logic class, and can effectively share the horizontal and vertical directions.
  • the same business logic in the screen greatly reduces code redundancy, improves development efficiency, and reduces post-code maintenance costs.
  • FIG. 1 is a schematic flowchart of a method for logically sharing a horizontal and vertical screen in an Android system according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of an apparatus for logically sharing a horizontal and vertical screen in an Android system according to another embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an apparatus for logically sharing horizontal and vertical screen services in an Android system according to another embodiment of the present invention.
  • a schematic flowchart of a method for sharing a horizontal and vertical screen service logic in an Android system includes:
  • the event object captured by the Android system callback to the horizontal or vertical event function onTouchEvent is passed to the instantiated object of the business logic class, so that the instantiated object of the business logic class calls the corresponding function function pair.
  • the event object is processed.
  • step S1 by abstracting and separating the business logic of the horizontal and vertical screens, the same business logic between the horizontal screen and the vertical screen is defined as a business logic class for controlling the business logic of the horizontal and vertical screens.
  • ViewHolder as a business logic class, which means that ViewHolder is mainly used to control the business logic of horizontal and vertical screens.
  • the main method of ViewHolder is the implementation of business logic.
  • the same is given by giving gifts as an example.
  • the gifts of the horizontal and vertical screens are the same except for the differences in the UI, such as the price of sending gifts to the server, and the process of returning the remaining gift information of the server to the server is the same.
  • the gift is a business method that is required in both horizontal and vertical screens.
  • step S1 we implement the function function of storing the same business logic between the horizontal screen and the vertical screen into a custom business logic class. Then, to realize the horizontal screen and the vertical screen, it is also required to implement the horizontal screen. Different business logic between vertical screen and vertical screen, the different business logic between horizontal screen and vertical screen refers to those functions related to changing the UI. Therefore, in step S2, the first service class of the horizontal screen and the second service class of the vertical screen are defined according to different business logics between the horizontal screen and the vertical screen. The first business class of the horizontal screen is used to implement the horizontal screen page, and the second business class of the vertical screen is used to implement the vertical screen page.
  • the first service class of the horizontal screen only includes the function function related to the horizontal screen UI implementation
  • the second service class of the vertical screen only includes the function function related to the UI implementation of the vertical screen, and is responsible for the realization of the specific business function.
  • the business function functions are all in the business logic class defined in step S1. Therefore, in step S2, the business logic shared by the horizontal screen and the vertical screen is added to the first service class and vertical of the defined horizontal screen by a method.
  • the horizontal screen page and the vertical screen page correspondingly call the first service class of the horizontal screen and the second business class of the vertical screen when the creation is performed, Instantiating the business logic class in the constructor of the first business class and the constructor of the second business class, ie instantiating the ViewHolder class in the constructor of the horizontal and vertical screens, such that Both the horizontal and vertical screens contain a VIewHolder object, which is the instantiated object corresponding to the business logic class.
  • the business logic of the horizontal and vertical screens is complete.
  • the subsequent business logic can be expanded using ViewHolder as a bridge to bridge the shared business function functions in the horizontal and vertical screen business logic.
  • the above example function sendGift can be used both in landscape and vertical screen.
  • step S1 and step S2 the function function corresponding to the same business logic between the horizontal screen and the vertical screen is stored in the instantiated object of the business logic class ViewHolder, and the business function corresponding to all the trigger events needs to pass the ViewHolder in step S3.
  • the system callback event function onTouchEvent is the system callback to the entry of all trigger events on the page, so the system callback to the horizontal or vertical interface event function onTouchEvent captured event object passed to the ViewHolder instantiation object
  • the business logic of the horizontal and vertical screens can be realized.
  • Step S3 unifies the message events that should have been processed in the horizontal and vertical screens into the ViewHolder for processing.
  • the method for sharing the horizontal and vertical screen business logic in the Android system proposed by the invention bridges the functions shared by the horizontal and vertical and vertical screen business logic into the customized business logic class, realizes the purpose of service sharing, and can effectively share the horizontal and vertical screens.
  • the same business logic greatly reduces code redundancy, improves development efficiency, and reduces post-code maintenance costs.
  • step S1 further includes:
  • An event handler function that defines the same parameters as the Android system callback to the horizontal or vertical event function onTouchEvent is defined in the business logic class.
  • the system receives an event that the user clicks or touches the Android terminal device, the event is encapsulated into an event object, and then the event object is passed to the function function that processes the event by means of a system callback. Since the functions of the same business logic between the horizontal screen and the vertical screen are stored in our custom business logic class ViewHolder, in order to call the corresponding function to handle the user's operation events, the event object needs to be passed to the service first.
  • the logic class ViewHolder in order to implement the transfer, defines an event handler function in the business logic class ViewHolder that exactly matches the parameter of the event function onTouchEvent of the system callback to the horizontal screen or the vertical screen, by which the event processing function can
  • the events captured by the system are passed to the instantiated objects of the defined business logic class for processing, thereby implementing functional business processing of the horizontal and vertical screens.
  • step S3 further includes:
  • the event object captured by the Android system callback to the horizontal or vertical screen event function onTouchEvent is transparently transmitted to the event processing function for processing.
  • transparent transmission means that all event objects captured by the event function onTouchEvent of the system callback to the horizontal or vertical screen interface are delivered to the event processing function for processing, that is, the event object is not filtered, and all triggers are triggered. Events are passed to the event handler of the business logic class for processing.
  • the step S3 further includes:
  • the event processing function After receiving the event object, the event processing function acquires an event type corresponding to the event object;
  • the instantiated object of the business logic class sends a message of updating the UI to the horizontal screen or the vertical screen;
  • the event function is processed by calling a corresponding function function inside the event processing function.
  • real business function processing is implemented in the event handler of the business logic class ViewHolder. Since the business logic class ViewHolder stores the function function corresponding to the same business logic between the horizontal screen and the vertical screen, the event processing function can directly process the event when the non-UI related event needs to be processed, and If you want to deal with events related to UI operations, such as updating the UI, because the UI interface of the horizontal and vertical screens is different, you cannot perform unified processing through ViewHolder. In order to solve this problem, ViewHolder needs to update the UI.
  • the place sends an update UI message Msg, and then after receiving the message in the horizontal or vertical screen interface, the corresponding function function is called to update the UI logic of the horizontal screen or the UI logic of the vertical screen, thus making all the trigger events Both can be assembled into the ViewHolder for processing, and the functional business logic of the subsequent horizontal and vertical screens can also be shared by ViewHolder.
  • the event processing function first acquires the event type corresponding to the event object; then, determines whether the event type is related to the UI operation, and if the event type is related to updating the UI, the business logic class
  • the instantiated object sends a message updating the UI to the horizontal screen or the vertical screen; if the event type is non-UI related, the event function is processed by calling a corresponding function function inside the event processing function.
  • step S3 further includes:
  • the Android system callback is filtered to the event object captured by the horizontal or vertical event function onTouchEvent, and the filtered event object is passed to the event processing function for processing.
  • the event object captured by the event function onTouchEvent of the system callback to the horizontal or vertical screen interface is filtered and then passed, and the filter is placed before the step of the transfer, thereby separating the filtering and event trigger logic.
  • the filtered event object is passed to the event processing function for processing, and the event processing function calls the corresponding function function to process the received event object, that is, the filtered event objects can all be directly processed in the ViewHolder. . This method works well for event objects that are mostly related to the update UI.
  • the step of filtering the event object captured by the system callback to the event function onTouchEvent of the horizontal or vertical screen interface further includes:
  • the event type corresponding to the event object is first acquired, and the filtered non-UI related event object is directly transmitted to the event processing function of the business logic class ViewHolder for processing, and the event related to updating the UI.
  • the object is sent to the horizontal or vertical screen in the form of a message and is not passed to the business logic class ViewHolder.
  • FIG. 2 is a schematic structural diagram of an apparatus for sharing a horizontal and vertical screen service logic in an Android system according to another embodiment of the present invention, including: a first defining unit 21, a second defining unit 22, and a service logic processing unit 23, wherein ,
  • a first defining unit 21 configured to define a business logic class for the same business logic between the horizontal screen and the vertical screen, wherein the business logic class stores a function function corresponding to the same business logic between the horizontal screen and the vertical screen ;
  • a second defining unit 22 configured to define a first service class of the horizontal screen and a second service class of the vertical screen according to different business logics between the horizontal screen and the vertical screen, and in the first service class Instantiating the business logic class in a constructor of the second business class;
  • the business logic processing unit 23 is configured to pass the event object captured by the Android system callback to the event function onTouchEvent of the horizontal or vertical screen interface to the instantiated object of the business logic class for instantiation of the business logic class
  • the object calls the corresponding function to process the event object.
  • the first definition unit 21 defines the same business logic between the horizontal screen and the vertical screen as a business logic class for controlling the business logic of the horizontal and vertical screens by abstracting and separating the business logic of the horizontal and vertical screens.
  • ViewHolder as a business logic class, which means that ViewHolder is mainly used to control the business logic of horizontal and vertical screens.
  • Taking the business logic sharing of the gift panel as an example when we click on the gift panel, we need to display the gift panel. When clicking a gift in the gift panel and clicking the send button, we need to send a gift and notify the server of the message. Whether it is a horizontal or vertical screen gift panel, it includes a gift-giving feature. The gift-giving feature is implemented by ViewHolder.
  • the main method of ViewHolder is the implementation of business logic.
  • the same is given by giving gifts as an example.
  • the gifts of the horizontal and vertical screens are the same except for the differences in the UI, such as the price of sending gifts to the server, and the process of returning the remaining gift information of the server to the server is the same.
  • the gift is a business method that is required in both horizontal and vertical screens.
  • the function function corresponding to the same business logic between the horizontal screen and the vertical screen is stored in the customized business logic class. Therefore, to realize the horizontal screen and the vertical screen, it is also required to realize the horizontal screen and the vertical screen.
  • Different business logic, different business logic between horizontal and vertical screens refers to those functions related to changing the UI. Therefore, the second defining unit 22 defines a first service class of the horizontal screen and a second service class of the vertical screen according to different business logics between the horizontal screen and the vertical screen.
  • the first business class of the horizontal screen is used to implement the horizontal screen page
  • the second business class of the vertical screen is used to implement the vertical screen page.
  • the first service class of the horizontal screen only includes the function function related to the horizontal screen UI implementation
  • the second service class of the vertical screen only includes the function function related to the UI implementation of the vertical screen, and is responsible for the realization of the specific business function.
  • the business function functions are all in the business logic class defined in step S1. Therefore, the second definition unit 22 adds the business logic common to the horizontal screen and the vertical screen to the first service class of the defined horizontal screen by a method.
  • the horizontal screen page and the vertical screen page correspondingly call the first service class of the horizontal screen and the constructor of the second service class of the vertical screen when the screen is created.
  • both the horizontal and vertical screens contain a VIewHolder object, which is the instantiated object corresponding to the business logic class.
  • the business logic of the horizontal and vertical screens is complete.
  • the subsequent business logic can be expanded using ViewHolder as a bridge to bridge the shared business function functions in the horizontal and vertical screen business logic.
  • the above example function sendGift can be used both in landscape and vertical screen.
  • the execution flow of the application is promoted by the trigger of an external event.
  • the life cycle of the entire application is maintained by a series of trigger events.
  • the function functions corresponding to the same business logic between the horizontal screen and the vertical screen are stored in the instantiation object of the business processing class ViewHolder, and the business logic processing unit 23 needs to The business function corresponding to the trigger event is completed by the ViewHolder. Since the event call function onTouchEvent of the system callback is the system callback to the entry of all the trigger events on the page, the system callback is captured by the event function onTouchEvent of the horizontal or vertical screen interface.
  • the event object is passed to the ViewHoder's instantiated object for processing, so that the business logic of the horizontal and vertical screen can be realized. Then, in the instantiated object of the business logic class ViewHolder, the function function corresponding to the same business logic between the horizontal screen and the vertical screen is called, thereby realizing the business function processing of the horizontal and vertical screen.
  • the business logic processing unit 23 unifies the message events that should have been processed in the horizontal and vertical screens into the ViewHolder for processing.
  • the first defining unit further includes:
  • a sub-unit is defined for defining an event processing function in the business logic class that has the same parameters as the Android system callback to the horizontal or vertical event function onTouchEvent.
  • the system receives an event that the user clicks or touches the Android terminal device, the event is encapsulated into an event object, and then the event object is passed to the function function that processes the event by means of a system callback. Since the functions of the same business logic between the horizontal and vertical screens are stored in our custom business logic class ViewHolder, because the corresponding function is called to handle the user's operation events, the event object needs to be passed to the service first.
  • the definition sub-unit defines an event processing function in the business logic class ViewHolder that exactly matches the parameter of the event function onTouchEvent of the system callback to the horizontal screen or the vertical screen, through the event processing function
  • the event captured by the system is passed to the instantiated object of the defined business logic class for processing, thereby realizing the functional business processing of the horizontal screen and the vertical screen.
  • FIG. 3 is a schematic structural diagram of a device for sharing a horizontal and vertical screen service logic in an Android system according to another embodiment of the present invention, including a memory 31, a processor 32, and a bus 33.
  • the processor 32 and the memory 31 complete communication with each other through the bus 33;
  • the memory 31 stores program instructions executable by the processor 32, the processor 32 invoking program instructions in the memory to perform the method of any of the preceding, for example, including: S1, being a landscape screen
  • S1 being a landscape screen
  • the same business logic between the vertical screen and the vertical screen defines a business logic class in which the function function corresponding to the same business logic between the horizontal screen and the vertical screen is stored; S2, according to the horizontal screen and the vertical screen Different business logic, defining a first service class of the horizontal screen and a second service class of the vertical screen, and in the constructor of the first business class and the constructor of the second business class
  • the business logic class is instantiated; S3, the event object captured by the Android system callback to the horizontal or vertical event function onTouchEvent is passed to the instantiated object of the business logic class for the instance of the business logic class
  • the object calls the corresponding function to process the event object.
  • a non-transitory computer readable storage medium storing computer instructions, the computer instructions causing the computer to perform the method of any of the preceding
  • the computer instructions causing the computer to perform the method of any of the preceding
  • the business logic class is instantiated in the constructor of the second business class;
  • S3, the event object captured by the Android system callback to the horizontal or vertical event function onTouchEvent is passed to the instantiated object of the business logic class,
  • the event object is processed by the corresponding function function for the instantiated object of the business logic class.
  • the embodiment discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer
  • the method provided by the foregoing method embodiments can be executed, for example, comprising: S1, defining a business logic class for the same business logic between the horizontal screen and the vertical screen, wherein the business logic class stores between the horizontal screen and the vertical screen a function function corresponding to the same business logic; S2, defining a first service class of the horizontal screen and a second service class of the vertical screen according to different business logics between the horizontal screen and the vertical screen, and in the The constructor of the first business class and the constructor of the second business class instantiate the business logic class; S3, the Android system callback to the event object captured by the horizontal or vertical event function onTouchEvent An instantiated object to the business logic class, for the instantiated object of the business logic class to call a corresponding function function to the event object Line processing.
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
  • the device embodiments of the horizontal and vertical screen service logic sharing in the Android system described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as the unit may be or It may not be a physical unit, that is, it may be located in one place, or it may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without deliberate labor.

Landscapes

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

Abstract

一种Android系统中横竖屏业务逻辑共享的方法及装置,其中,所述方法包括:为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数(S1);根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化(S2);Android系统回调给横竖或竖屏界面的事件函数onTouchEvent传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理(S3)。该方法通过将横竖和竖屏业务逻辑共有的功能桥接到自定义的业务逻辑类中,实现了业务共享的目的,极大的降低代码的冗余,提高开发效率。

Description

Android系统中横竖屏业务逻辑共享的方法及装置
交叉引用
本申请引用于2017年08月31日提交的专利名称为“Android系统中横竖屏业务逻辑共享的方法及装置”的第2017107739291号中国专利申请,其通过引用被全部并入本申请。
技术领域
本发明涉及计算机技术领域,更具体地,涉及Android系统中横竖屏业务逻辑共享的方法及装置。
背景技术
在直播软件Android端app的开发过程中通常会需要实现礼物面板的功能,礼物面板主要用于承载礼物数据。礼物面板的设计过程中有一套横竖屏的业务逻辑,在横竖屏的业务逻辑下礼物面板内部的消息处理机制是相同的,不同之处仅在于横屏和竖屏下UI界面的呈现形式不一样的。
传统的方案在实现横竖屏业务逻辑时采用的是横屏一套业务逻辑,竖屏一套业务逻辑,这两套业务逻辑是独立分开的。但是,由于横屏和竖屏的业务逻辑中有很多类似的共享功能,目前的实现方法将两套业务逻辑独立分开,造成了这些共享功能不能够被复用,使得横竖屏实现代码存在冗余问题,进而导致了代码后期维护较困难的问题。
发明内容
为了克服现有横竖屏业务逻辑独立分开、共享功能没有复用所造成的代码冗余和维护困难的问题,本发明提出Android系统中横竖屏业务逻辑共享的方法及装置。
根据本发明的一个方面,提供Android系统中横竖屏业务逻辑共享 的方法,包括:
S1,为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;
S2,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;
S3,将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
其中,所述步骤S1还包括:
在所述业务逻辑类中定义与Android系统回调给横竖或竖屏的事件函数onTouchEvent的参数相同的事件处理函数。
其中,所述步骤S3进一步包括:
将所述Android系统回调给横屏或竖屏的事件函数onTouchEvent所捕获到的事件对象透传至所述事件处理函数中进行处理。
其中,所述步骤S3进一步包括:
对所述Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象进行筛选,并将筛选后的事件对象传递至所述事件处理函数中进行处理。
其中,所述步骤S3还包括:
所述事件处理函数接收到事件对象后,获取事件对象所对应的事件类型;
若所述事件类型为与更新UI有关,则所述业务逻辑类的实例化对 象向横屏或竖屏发送更新UI的消息;或者,
若所述事件类型为非UI相关,则在所述事件处理函数的内部调用相应的功能函数对所述事件对象进行处理。
其中,对所述Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象进行筛选的步骤进一步包括:
获取Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象所对应的事件类型;
筛选出事件类型为非UI相关的事件对象。
根据本发明的另一个方面,提供Android系统中横竖屏业务逻辑共享的装置,包括:
第一定义单元,用于为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;
第二定义单元,用于根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;
业务逻辑处理单元,用于将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
其中,所述第一定义单元还包括:
定义子单元,用于在所述业务逻辑类中定义与Android系统回调给横竖或竖屏的事件函数onTouchEvent的参数相同的事件处理函数。
根据本发明的另一个方面,提供Android系统中横竖屏业务逻辑共 享的设备,包括存储器、处理器、以及总线,
所述处理器和存储器通过所述总线完成相互间的通信;
所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述存储器中的程序指令,以执行如前任一所述的方法。
根据本发明的又一个方面,提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如前任一所述的方法。
本发明提出的Android系统中横竖屏业务逻辑共享的方法及装置,通过将横竖和竖屏业务逻辑共有的功能桥接到自定义的业务逻辑类中,实现了业务共享的目的,能够有效的共享横竖屏中相同的业务逻辑,极大的降低代码的冗余,提高开发效率,同时降低了后期代码维护成本。
附图说明
图1为本发明一实施例提供的Android系统中横竖屏业务逻辑共享的方法的流程示意图;
图2为本发明另一实施例提供的Android系统中横竖屏业务逻辑共享的装置的结构示意图;
图3为本发明另一实施例提供的Android系统中横竖屏业务逻辑共享的设备的结构示意图。
具体实施方式
下面结合附图和实施例,对本发明的具体实施方式作进一步详细描述。以下实施例用于说明本发明,但不用来限制本发明的范围。
如图1所示,为本发明一实施例提供的Android系统中横竖屏业务逻辑共享的方法的流程示意图,包括:
S1,为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所 述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;
S2,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;
S3,将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
具体地,步骤S1中,通过对横竖屏的业务逻辑进行抽象和分离,将横屏和竖屏之间相同的业务逻辑定义为一个业务逻辑类,用于控制横竖屏的业务逻辑。我们可以将ViewHolder定义为业务逻辑类,也就是说ViewHolder主要用于控制横竖屏的业务逻辑。以礼物面板的业务逻辑共享为例,当我们点击礼物面板的时候我们需要把礼物面板展示出来,点击礼物面板中的一个礼物并点击发送按钮的时候,需要发送礼物并将该消息通知给服务器。不管是横屏还是竖屏的礼物面板,都包含赠送礼物这个功能,赠送礼物这个功能就通过ViewHolder来实现。
通过上面的描述我们可以发现ViewHolder中主要存放的是业务逻辑的实施方法。同样以赠送礼物为例来进行说明,我们在横竖屏的业务逻辑中都包含有赠送礼物这个功能。横竖屏的赠送礼物除了UI上有差异性以外其他功能都是相同的,比如向服务器发送赠送礼物的价格,服务器返回用户剩余礼物信息的解析等过程都是相同的。这样我们就将赠送礼物这个功能编写为函数sendGift,并将该函数sendGift存储在ViewHolder中,这样我们定义的一个ViewHolder就拥有了除UI以外的赠送礼物的所有功能。通过上述举例我们可以看出,赠送礼物是横屏和竖屏中都需要的业务方法,我们将该业务方法独立出来存储到ViewHolder中后续方便横屏和竖屏来进行使用。因此在步骤S1中,将横屏和竖屏之间相同的业务逻辑所对应的功能函数存储至我们所定义 的业务逻辑类中。
在步骤S1中,我们实现了将横屏和竖屏之间相同的业务逻辑所对应的功能函数存储至自定义的业务逻辑类中,那么,要实现横屏和竖屏,还需要实现横屏和竖屏之间不同的业务逻辑,横屏和竖屏之间不同的业务逻辑即是指那些与改变UI有关的功能。因此,我们在步骤S2中,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类。横屏的第一业务类用于实现横屏页面,竖屏的第二业务类用于实现竖屏页面。目前,横屏的第一业务类中仅包含与横屏UI实现相关的功能函数,竖屏的第二业务类中仅包含与竖屏的UI实现相关的功能函数,而负责具体业务功能实现的业务功能函数都在步骤S1中所定义的业务逻辑类中,因此,在步骤S2中通过一种方法将横屏和竖屏共有的业务逻辑添加进所定义的横屏的第一业务类和竖屏的第二业务类中,具体地,横屏页面和竖屏页面在创建的时候会对应地调用所述横屏的第一业务类和所述竖屏的第二业务类的构造函数,在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化,即在横屏和竖屏页面的构造函数中对ViewHolder类进行实例化,这样横屏和竖屏页面中均含有一个VIewHolder对象,即业务逻辑类所对应的实例化对象,横屏和竖屏的业务逻辑就完整了。后续业务逻辑的展开就可以使用ViewHolder来作为一个桥接,来桥接横屏和竖屏业务逻辑中的共享业务功能函数了。例如,上述举例的函数sendGift既可以在横屏中使用也可以在竖屏中进行使用了。
由于Android系统是通过事件来进行触发的,即应用程序的执行流程是通过外部事件的触发来进行推进的。整个应用程序的生命周期由一系列的触发事件来维系。经过步骤S1和步骤S2,将横屏和竖屏之间相同的业务逻辑所对应的功能函数存放在业务逻辑类ViewHolder的实例化对象中,步骤S3需要将所有触发事件所对应的业务功能通过ViewHolder来进行完成,由于系统回调的事件函数onTouchEvent是系 统回调到页面上所有触发事件的入口,因此将系统回调给横竖或竖屏界面的事件函数onTouchEvent所捕获到的事件对象传递到ViewHolder的实例化对象中来进行处理,才能够真正实现横竖屏的业务逻辑。然后,调用ViewHolder中相应的横屏和竖屏之间相同的业务逻辑所对应的功能函数,在ViewHolder中实现横竖屏的业务功能处理。步骤S3将原本应该放在横屏和竖屏页面中各自处理的消息事件统一到ViewHolder中来进行处理。
本发明提出的Android系统中横竖屏业务逻辑共享的方法,通过将横竖和竖屏业务逻辑共有的功能桥接到自定义的业务逻辑类中,实现了业务共享的目的,能够有效的共享横竖屏中相同的业务逻辑,极大的降低代码的冗余,提高开发效率,同时降低了后期代码维护成本。
基于上述实施例,所述步骤S1还包括:
在所述业务逻辑类中定义与Android系统回调给横竖或竖屏的事件函数onTouchEvent的参数相同的事件处理函数。
具体地,系统接收到用户点击或触摸Android终端设备的事件时,会将所述事件封装成事件对象,然后通过系统回调的方式将事件对象传递给处理该事件的功能函数。由于横屏和竖屏之间相同的业务逻辑所对应的功能都存储在我们自定义的业务逻辑类ViewHolder中,因此要调用相应的功能函数处理用户的操作事件,需要先将事件对象传递给业务逻辑类ViewHolder,为了实现传递,在所述业务逻辑类ViewHolder中定义一个与系统回调给横屏或竖屏的事件函数onTouchEvent的参数完全一致的事件处理函数,通过所述事件处理函数,就能够将将系统所捕获到的事件传递至所定义的业务逻辑类的实例化对象中进行处理,从而实现横屏和竖屏的功能业务处理。
基于上述实施例,所述步骤S3进一步包括:
将所述Android系统回调给横屏或竖屏的事件函数onTouchEvent所捕获到的事件对象透传至所述事件处理函数中进行处理。
具体地,透传是指将系统回调给横屏或竖屏界面的事件函数 onTouchEvent所捕获到的所有事件对象传递至所述事件处理函数中进行处理,即不对事件对象进行筛选,将所有的触发事件都传递至所述业务逻辑类的事件处理函数中进行处理。
其中,所述步骤S3还包括:
所述事件处理函数接收到事件对象后,获取事件对象所对应的事件类型;
若所述事件类型为与更新UI有关,则所述业务逻辑类的实例化对象向横屏或竖屏发送更新UI的消息;或者,
若所述事件类型为非UI相关,则在所述事件处理函数的内部调用相应的功能函数对所述事件对象进行处理。
具体地,在业务逻辑类ViewHolder的事件处理函数中实现真实的业务功能处理。由于所述业务逻辑类ViewHolder中存储的是横屏和竖屏之间相同的业务逻辑所对应的功能函数,因此,在需要处理涉及非UI相关的事件时,事件处理函数可以直接进行处理,而如果要处理涉及到更新UI等与UI操作有关的事件时,由于横屏和竖屏的UI界面是不一样的,无法通过ViewHolder进行统一处理,此时为了解决该问题,ViewHolder需要向需要更新UI的地方发送一个更新UI的消息Msg,然后横屏界面或竖屏界面接收到该消息后,调用相应的功能函数去更新横屏的UI逻辑或竖屏的UI逻辑,这样就使得所有的触发事件都能够被集合到ViewHolder中来进行处理了,后续横屏和竖屏的功能业务逻辑也能够完全通过ViewHolder来达到共享的目的了。即所述事件处理函数接收到事件对象后,首先获取事件对象所对应的事件类型;然后,判断事件类型是否与UI操作有关,若所述事件类型为与更新UI有关,则所述业务逻辑类的实例化对象向横屏或竖屏发送更新UI的消息;若所述事件类型为非UI相关,则在所述事件处理函数的内部调用相应的功能函数对所述事件对象进行处理。
基于上述实施例,所述步骤S3进一步包括:
对所述Android系统回调给横竖或竖屏的事件函数onTouchEvent 所捕获到的事件对象进行筛选,并将筛选后的事件对象传递至所述事件处理函数中进行处理。
具体地,将系统回调给横竖或竖屏界面的事件函数onTouchEvent所捕获到的事件对象先进行筛选后再传递,将筛选放在传递的步骤之前,从而实现将筛选和事件触发逻辑分开。将筛选后的事件对象传递至所述事件处理函数中进行处理,事件处理函数调用相应的功能函数对所接收到的事件对象进行处理,即经过筛选后的事件对象全都可以在ViewHolder中直接进行处理。此方式适用于事件对象大多属于与更新UI相关的事件类型。
其中,对所述系统回调给横竖或竖屏界面的事件函数onTouchEvent所捕获到的事件对象进行筛选的步骤进一步包括:
获取系统回调给横竖或竖屏界面的事件函数onTouchEvent所捕获到的事件对象所对应的事件类型;
筛选出事件类型为非UI相关的事件对象。
具体地,在用户操作事件发生时,首先获取事件对象所对应的事件类型,筛选出的非UI相关的事件对象直接传递给业务逻辑类ViewHolder的事件处理函数进行处理,而与更新UI有关的事件对象就通过消息的形式发送给横屏或竖屏进行处理,而不会被传递给业务逻辑类ViewHolder。
由于我们在ViewHolder中本身就是实现的横竖屏共享的方法,这样就使得横竖屏的业务逻辑能够统一到ViewHolder中来。对于VIewHolder相同业务逻辑中又包含不同UI处理的部分,我们使用了消息机制来解决该问题,将差异性的部分延迟到横屏和竖屏的业务类中来进行处理,这样也就保证了ViewHolder对业务的公共性的特点,也就能够确保ViewHolder能够在横屏和竖屏之间进行共享。
如图2所示,为本发明另一实施例提供的Android系统中横竖屏业务逻辑共享的装置的结构示意图,包括:第一定义单元21、第二定义单元22和业务逻辑处理单元23,其中,
第一定义单元21,用于为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;
第二定义单元22,用于根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;
业务逻辑处理单元23,用于将Android系统回调给横竖或竖屏界面的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
第一定义单元21通过对横竖屏的业务逻辑进行抽象和分离,将横屏和竖屏之间相同的业务逻辑定义为一个业务逻辑类,用于控制横竖屏的业务逻辑。我们可以将ViewHolder定义为业务逻辑类,也就是说ViewHolder主要用于控制横竖屏的业务逻辑。以礼物面板的业务逻辑共享为例,当我们点击礼物面板的时候我们需要把礼物面板展示出来,点击礼物面板中的一个礼物并点击发送按钮的时候,需要发送礼物并将该消息通知给服务器。不管是横屏还是竖屏的礼物面板,都包含赠送礼物这个功能,赠送礼物这个功能就通过ViewHolder来实现。
通过上面的描述我们可以发现ViewHolder中主要存放的是业务逻辑的实施方法。同样以赠送礼物为例来进行说明,我们在横竖屏的业务逻辑中都包含有赠送礼物这个功能。横竖屏的赠送礼物除了UI上有差异性以外其他功能都是相同的,比如向服务器发送赠送礼物的价格,服务器返回用户剩余礼物信息的解析等过程都是相同的。这样我们就将赠送礼物这个功能编写为函数sendGift,并将该函数sendGift存储在ViewHolder中,这样我们定义的一个ViewHolder就拥有了除UI以外的赠送礼物的所有功能。通过上述举例我们可以看出,赠送礼物是横屏和竖屏中都需要的业务方法,我们将该业务方法独立出来存储到 ViewHolder中后续方便横屏和竖屏来进行使用。
前面实现了将横屏和竖屏之间相同的业务逻辑所对应的功能函数存储至自定义的业务逻辑类中,那么,要实现横屏和竖屏,还需要实现横屏和竖屏之间不同的业务逻辑,横屏和竖屏之间不同的业务逻辑即是指那些与改变UI有关的功能。因此,第二定义单元22,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类。横屏的第一业务类用于实现横屏页面,竖屏的第二业务类用于实现竖屏页面。目前,横屏的第一业务类中仅包含与横屏UI实现相关的功能函数,竖屏的第二业务类中仅包含与竖屏的UI实现相关的功能函数,而负责具体业务功能实现的业务功能函数都在步骤S1中所定义的业务逻辑类中,因此,第二定义单元22通过一种方法将横屏和竖屏共有的业务逻辑添加进所定义的横屏的第一业务类和竖屏的第二业务类中,具体地,横屏页面和竖屏页面在创建的时候会对应地调用所述横屏的第一业务类和所述竖屏的第二业务类的构造函数,在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化,即在横屏和竖屏页面的构造函数中对ViewHolder类进行实例化,这样横屏和竖屏页面中均含有一个VIewHolder对象,即业务逻辑类所对应的实例化对象,横屏和竖屏的业务逻辑就完整了。后续业务逻辑的展开就可以使用ViewHolder来作为一个桥接,来桥接横屏和竖屏业务逻辑中的共享业务功能函数了。例如,上述举例的函数sendGift既可以在横屏中使用也可以在竖屏中进行使用了。
由于Android系统是通过事件来进行触发的,即应用程序的执行流程是通过外部事件的触发来进行推进的。整个应用程序的生命周期由一系列的触发事件来维系。经过第一定义单元21和第二定义单元22,将横屏和竖屏之间相同的业务逻辑所对应的功能函数存放在业务处理类ViewHolder的实例化对象中,业务逻辑处理单元23需要将所有触发事件所对应的业务功能通过ViewHolder来进行完成,由于系统回调 的事件函数onTouchEvent是系统回调到页面上所有触发事件的入口,因此将系统回调给横竖或竖屏界面的事件函数onTouchEvent所捕获到的事件对象传递到ViewHolder的实例化对象中来进行处理,才能够真正实现横竖屏的业务逻辑。然后,在业务逻辑类ViewHolder的实例化对象中调用相应的横屏和竖屏之间相同的业务逻辑所对应的功能函数,从而实现横竖屏的业务功能处理。业务逻辑处理单元23将原本应该放在横屏和竖屏页面中各自处理的消息事件统一到ViewHolder中来进行处理。
其中,所述第一定义单元还包括:
定义子单元,用于在所述业务逻辑类中定义与Android系统回调给横竖或竖屏的事件函数onTouchEvent的参数相同的事件处理函数。
具体地,系统接收到用户点击或触摸Android终端设备的事件时,会将所述事件封装成事件对象,然后通过系统回调的方式将事件对象传递给处理该事件的功能函数。由于横屏和竖屏之间相同的业务逻辑所对应的功能都存储在我们自定义的业务逻辑类ViewHolder中,因为要调用相应地功能函数处理用户的操作事件,需要先将事件对象传递给业务逻辑类ViewHolder,为了实现透传,定义子单元在所述业务逻辑类ViewHolder中定义一个与系统回调给横屏或竖屏的事件函数onTouchEvent的参数完全一致的事件处理函数,通过所述事件处理函数,将系统所捕获到的事件传递至所定义的业务逻辑类的实例化对象中进行处理,从而实现横屏和竖屏的功能业务处理。
如图3所述,为本发明另一实施例提供的Android系统中横竖屏业务逻辑共享的设备的结构示意图,包括存储器31、处理器32、以及总线33,
所述处理器32和存储器31通过所述总线33完成相互间的通信;
所述存储器31存储有可被所述处理器32执行的程序指令,所述处理器32调用所述存储器中的程序指令,以执行如前任一所述的方法,例如包括:S1,为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑 类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;S2,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;S3,将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
根据本发明的又一个方面,提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如前任一所述的方法,例如包括:S1,为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;S2,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;S3,将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
本实施例公开一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,计算机能够执行上述各方法实施例所提供的方法,例如包括:S1,为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;S2,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;S3,将Android系统回调给横竖或竖 屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所描述的Android系统中横竖屏业务逻辑共享的设备实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分所述的方法。
最后,本发明的方法仅为较佳的实施方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (11)

  1. Android系统中横竖屏业务逻辑共享的方法,其特征在于,包括:
    S1,为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;
    S2,根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;
    S3,将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
  2. 根据权利要求1所述的方法,其特征在于,所述步骤S1还包括:
    在所述业务逻辑类中定义与Android系统回调给横竖或竖屏的事件函数onTouchEvent的参数相同的事件处理函数。
  3. 根据权利要求2所述的方法,其特征在于,所述步骤S3进一步包括:
    将所述Android系统回调给横屏或竖屏的事件函数onTouchEvent所捕获到的事件对象透传至所述事件处理函数中进行处理。
  4. 根据权利要求2所述的方法,其特征在于,所述步骤S3进一步包括:
    对所述Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象进行筛选,并将筛选后的事件对象传递至所述事 件处理函数中进行处理。
  5. 根据权利要求3所述的方法,其特征在于,所述步骤S3还包括:
    所述事件处理函数接收到事件对象后,获取事件对象所对应的事件类型;
    若所述事件类型为与更新UI有关,则所述业务逻辑类的实例化对象向横屏或竖屏发送更新UI的消息;或者,
    若所述事件类型为非UI相关,则在所述事件处理函数的内部调用相应的功能函数对所述事件对象进行处理。
  6. 根据权利要求4所述的方法,其特征在于,对所述Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象进行筛选的步骤进一步包括:
    获取Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象所对应的事件类型;
    筛选出事件类型为非UI相关的事件对象。
  7. Android系统中横竖屏业务逻辑共享的装置,其特征在于,包括:
    第一定义单元,用于为横屏和竖屏之间相同的业务逻辑定义一个业务逻辑类,所述业务逻辑类中存储有横屏和竖屏之间相同的业务逻辑所对应的功能函数;
    第二定义单元,用于根据横屏和竖屏之间不同的业务逻辑,定义所述横屏的第一业务类和所述竖屏的第二业务类,并在所述第一业务类的构造函数和所述第二业务类的构造函数中对所述业务逻辑类进行实例化;
    业务逻辑处理单元,用于将Android系统回调给横竖或竖屏的事件函数onTouchEvent所捕获到的事件对象传递至所述业务逻辑类的实例化对象,以供所述业务逻辑类的实例化对象调用相应的功能函数对所述事件对象进行处理。
  8. 根据权利要求7所述的装置,其特征在于,所述第一定义单元还包括:
    定义子单元,用于在所述业务逻辑类中定义与Android系统回调给横竖或竖屏的事件函数onTouchEvent的参数相同的事件处理函数。
  9. Android系统中横竖屏业务逻辑共享的设备,包括存储器、处理器、以及总线,
    所述处理器和存储器通过所述总线完成相互间的通信;
    所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述存储器中的程序指令,以执行如权利要求1至6任一所述的方法。
  10. 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行如权利要求1至6任一所述的方法。
  11. 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行如权利要求1至6任一所述的方法。
PCT/CN2017/120194 2017-08-31 2017-12-29 Android系统中横竖屏业务逻辑共享的方法及装置 WO2019041709A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710773929.1 2017-08-31
CN201710773929.1A CN109460269B (zh) 2017-08-31 2017-08-31 Android系统中横竖屏业务逻辑共享的方法及装置

Publications (1)

Publication Number Publication Date
WO2019041709A1 true WO2019041709A1 (zh) 2019-03-07

Family

ID=65526197

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/120194 WO2019041709A1 (zh) 2017-08-31 2017-12-29 Android系统中横竖屏业务逻辑共享的方法及装置

Country Status (2)

Country Link
CN (1) CN109460269B (zh)
WO (1) WO2019041709A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1536818A (zh) * 2003-04-10 2004-10-13 华为技术有限公司 一种业务逻辑运行环境实现的方法
CN103729188A (zh) * 2013-12-31 2014-04-16 福建三元达软件有限公司 Android系统应用程序的开发方法、运行方法、运行装置
US20150234642A1 (en) * 2013-01-29 2015-08-20 ArtinSoft Corporation User Interfaces of Application Porting Software Platform
CN107087236A (zh) * 2017-03-22 2017-08-22 北京潘达互娱科技有限公司 一种直播信息展示方法及装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104423931B (zh) * 2013-08-20 2017-12-22 北大方正集团有限公司 用于横屏和竖屏显示的共用资源的生成方法和系统
CN103472997B (zh) * 2013-09-24 2016-05-25 沈阳美行科技有限公司 一种根据横竖屏自动切换软件界面显示风格的方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1536818A (zh) * 2003-04-10 2004-10-13 华为技术有限公司 一种业务逻辑运行环境实现的方法
US20150234642A1 (en) * 2013-01-29 2015-08-20 ArtinSoft Corporation User Interfaces of Application Porting Software Platform
CN103729188A (zh) * 2013-12-31 2014-04-16 福建三元达软件有限公司 Android系统应用程序的开发方法、运行方法、运行装置
CN107087236A (zh) * 2017-03-22 2017-08-22 北京潘达互娱科技有限公司 一种直播信息展示方法及装置

Also Published As

Publication number Publication date
CN109460269B (zh) 2020-07-10
CN109460269A (zh) 2019-03-12

Similar Documents

Publication Publication Date Title
US11803451B2 (en) Application exception recovery
CN107391114B (zh) 页面可视化渲染方法及装置
CN103282875B (zh) 多操作系统
JP6092381B2 (ja) ウェブクライアントを介したリモートアプリケーションへのアクセスを提供する方法、システム、及びコンピュータ読取可能記憶媒体
US11507796B2 (en) Method and system for sharing avatars through instant messaging application
US11340970B2 (en) Distributed queueing over a Redis cluster
CN112118459A (zh) 共享摄像头数据实现多个app共同直播的方法及可读介质
US9667703B1 (en) System, method and computer program product for generating remote views in a virtual mobile device platform
CN112181439A (zh) 一种微服务部署方法、装置、电子设备及可读存储介质
CN108008950B (zh) 一种用户界面更新的实现方法及装置
US20190087289A1 (en) Unified data layer backup system
CN109739661B (zh) 一种协同模块间消息更新的方法、装置及系统
WO2019201340A1 (zh) 处理器核心调度方法、装置、终端及存储介质
CN111198892A (zh) 信息处理方法、装置、电子设备及存储介质
CN113268212A (zh) 投屏方法、装置、存储介质及电子设备
CN108401453B (zh) 一种控制显示屏的方法、装置和智能终端
CN111078348B (zh) 一种界面管理方法、装置、设备和存储介质
US11249771B2 (en) Terminal input invocation
US10802874B1 (en) Cloud agnostic task scheduler
WO2019041709A1 (zh) Android系统中横竖屏业务逻辑共享的方法及装置
CN107346217A (zh) 一种云硬盘管理方法、云计算管理平台及虚拟化平台
CN116048515A (zh) 一种虚拟场景编辑方法、装置、设备和可读存储介质
CN110447016B (zh) 数据丢失故障转移的应用服务级别配置
CN113467656B (zh) 一种屏幕触摸事件的通知方法和车机
CN110599112A (zh) 一种网络页面开发、维护方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17923130

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17923130

Country of ref document: EP

Kind code of ref document: A1