WO2019134288A1 - Method, apparatus and computer device for implementing view controller - Google Patents

Method, apparatus and computer device for implementing view controller Download PDF

Info

Publication number
WO2019134288A1
WO2019134288A1 PCT/CN2018/082184 CN2018082184W WO2019134288A1 WO 2019134288 A1 WO2019134288 A1 WO 2019134288A1 CN 2018082184 W CN2018082184 W CN 2018082184W WO 2019134288 A1 WO2019134288 A1 WO 2019134288A1
Authority
WO
WIPO (PCT)
Prior art keywords
floating layer
class
layer view
function
view
Prior art date
Application number
PCT/CN2018/082184
Other languages
French (fr)
Chinese (zh)
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 WO2019134288A1 publication Critical patent/WO2019134288A1/en

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/38Creation or generation of source code for implementing user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming

Definitions

  • the invention belongs to the technical field of network development, and in particular relates to a method, a device and a computer device for implementing a view controller.
  • the floating layer controller WindowManager is used in the development of the Android system.
  • the WindowManager floating layer controller is mainly used to display and destroy the floating layer view. In the traditional development process, if the same view is added to the floating layer controller multiple times, this will cause multiple identical floating layer elements to be displayed on the view layer controller, showing confusion. If the same floating layer element is removed multiple times by mistake, the system will crash directly, and the stability of the floating layer controller will not be guaranteed.
  • the present invention provides a method, an apparatus, and a computer device for implementing a view controller, which are used to solve the floating layer controller of the prior art when adding or deleting a floating layer view due to a floating layer.
  • the defect of the controller itself leads to technical problems that the stability of the floating layer controller is not guaranteed.
  • An embodiment of the present invention provides a method for implementing a view controller, where the method includes:
  • the object of the floating layer view controller class is called to add a floating layer view function to determine whether the ID of the current floating layer view exists in the array object, if any Rejecting the first request;
  • the acquiring the object of the floating layer view controller class by using the first acquiring function in the floating layer view controller class includes:
  • the third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to acquire the object windowManager of the window management class, and the object windowManager of the window management class is a parent class object of the object of the floating layer view controller class.
  • the object of the floating layer view controller class is used to call the added floating layer view function to determine whether the current floating layer view exists in the array object.
  • the ID if it does not exist, includes:
  • the object of the floating layer view controller class is used to call the remove floating layer view function to determine whether the array object exists.
  • the ID of the current floating layer view if any, includes:
  • the present invention also provides an apparatus for implementing a view controller, the apparatus comprising:
  • a first establishing unit configured to establish a floating layer view controller class, and set a window management class in the application platform as a parent class of the floating layer view controller class;
  • An obtaining unit configured to acquire an object of the floating layer view controller class by using a first acquiring function in the floating layer view controller class
  • a second establishing unit configured to create an array object in the floating layer view controller class, where the array object is used to store identifier IDs of multiple floating layer views;
  • a calling unit configured to determine, by using an object of the floating layer view controller class, a floating layer view function to determine whether the current floating layer view exists in the array object when receiving the first request to add a current floating layer view ID, if any, rejects the first request;
  • the establishing unit is specifically configured to:
  • the third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to acquire the object windowManager of the window management class, and the object windowManager of the window management class is a parent class object of the object of the floating layer view controller class.
  • the calling unit is specifically configured to:
  • the object of the floating layer view controller class is used to call the added floating layer view function to determine whether the ID of the current floating layer view exists in the array object. If not, the ID of the current floating layer view is converted into a floating layer view object by using a conversion function findViewByld (viewld);
  • the present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements a method as described in any of the above.
  • the invention also provides a computer device for implementing a view controller, comprising:
  • At least one processor At least one processor
  • At least one memory communicatively coupled to the processor, wherein
  • the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of the above.
  • the present invention provides a method, apparatus, and computer apparatus for implementing a view controller, the method comprising: establishing a floating layer view controller class, and setting a window management class in the application platform to the floating layer view control a parent class of the class; obtaining an object of the floating layer view controller class by using a first fetch function in the floating layer view controller class; creating an array object in the floating layer view controller class, the array object And storing an identifier ID of the plurality of floating layer views; when receiving the first request for adding the current floating layer view, using the object of the floating layer view controller class to call the added floating layer view function to determine whether the array object exists The ID of the current floating layer view, if present, rejecting the first request; when receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call The floating layer view function determines whether the ID of the current floating layer view exists in the array object, and if not, rejects the second request; thus, when receiving the current floating layer view is received When the first request is made, it first
  • the current floating layer view is added to avoid adding the same view to the view controller multiple times; similarly, when receiving When the second request of the current floating layer view is removed, the ID of the floating layer view is first determined in the array object. If not, the removal operation is not performed, thereby avoiding a system crash.
  • FIG. 1 is a schematic flowchart of a method for implementing a view controller according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic structural diagram of an apparatus for implementing a view controller according to Embodiment 2 of the present invention
  • FIG. 3 is a schematic structural diagram of a computer device for implementing a view controller according to Embodiment 3 of the present invention.
  • This embodiment provides a method for implementing a view controller. As shown in FIG. 1, the method includes:
  • a floating layer view controller DYFloatManage class is customized, and the DYFloatManage class inherits the window management WindowManager class in the application platform, that is, the window management class is the parent class of the floating layer view controller DYFloatManage class.
  • the first dyFloatManager object of the floating layer view controller class is obtained by using the first get function public static DYFloatManager getFloatManager() in the view controller DYFloatManage class, and the specific implementation is as follows:
  • the creation function oncreate in the DYApplication class is overwritten, and the oncreate is called when the application platform is started.
  • An application object application is created in the DYApplication class, and the this pointer of the DYApplication class is assigned to the application object by using the replication creation function oncreate, so that the application object has a value.
  • the third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to obtain a floating layer management service object. Since the object is an Object type object, the Object type object is required to be converted into a WindowManager object, and the specific implementation is implemented. as follows:
  • WindowManager windowManager (WindowManager)getDYApplication().getSystemService(Context.WINDOW_SERVICE);
  • the windowManager object is the parent class object of the dyApplication object, so it is equivalent to obtaining the dyApplication object of the DYFloatManage class.
  • a floating layer view function dyAddView is created in the WindowManager class, and a floating layer view function dyRemoveView is removed; and an array object viewlds is created in the floating layer view controller class DYApplication, and the array object viewlds is The int type is used to store the identifier ID of each of the floating layer views, and each floating layer view has a unique ID.
  • each floating layer view object when directly stored, it takes up a large memory space and has a large overhead on system resources, and this embodiment can maintain a view object by using an array object of type int.
  • the object of the floating layer view controller class is called to add a floating layer view function to determine whether the current floating layer exists in the array object.
  • View ID information specifically, adding a floating layer view function is determined by calling the conatins (viewld) function of the array object. If the function returns true, the current floating layer view already exists in the array object. That is to say, the floating layer view has been displayed on the display interface, so the first request is rejected.
  • the function returns flase, it means that there is no current floating layer view in the array object, then use the conversion function findViewByld (viewld) to convert the current floating layer view ID into a floating layer view object; call the Add in WindowManager class
  • the view function addview displays the floating layer view object, and calls the add ID function add() in the array object to add the ID of the current floating layer view to the array object.
  • the object of the floating layer view controller class when receiving the second request to remove the current floating layer view, the object of the floating layer view controller class is called to remove the floating layer view function to determine whether the current object exists in the array object.
  • the ID information of the floating layer view; specifically, the removal of the floating layer view function is determined by calling the conatins (viewld) function of the array object. If the function returns flase, the current floating layer does not exist in the array object. View, if removing the view at this time will cause an exception to occur, reject the second request and return directly.
  • the view object is an empty object, and the second request may be rejected if the operation cannot be performed.
  • the embodiment further provides an apparatus for implementing a view controller.
  • the apparatus includes: a first establishing unit 21, an obtaining unit 22, a second establishing unit 23, and a call. Unit 24; wherein
  • the first establishing unit 21 is configured to establish a floating layer view controller class, and set a window management class in the application platform as a parent class of the view controller class.
  • the first establishing unit 21 customizes a floating layer view controller DYFloatManage class, and the DYFloatManage class inherits the window management WindowManager class in the application platform, that is, the window management class is the parent class of the view controller DYFloatManage class.
  • the obtaining unit 22 is configured to acquire an object of the floating layer view controller class by using the first acquiring function in the floating layer view controller class.
  • the obtaining unit 22 obtains the object dyFloatManager of the floating layer view controller class by using the first get function public static DYFloatManager getFloatManager() in the view controller DYFloatManage class, and the specific implementation is as follows:
  • the creation function oncreate in the DYApplication class is overwritten, and the oncreate is called when the application platform is started.
  • An application object application is created in the DYApplication class, and the this pointer of the DYApplication class is assigned to the application object by using the replication creation function oncreate, so that the application object has a value.
  • the third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to obtain a floating layer management service object. Since the object is an Object type object, the Object type object is required to be converted into a WindowManager object, and the specific implementation is implemented. as follows:
  • WindowManager windowManager (WindowManager)getDYApplication().getSystemService(Context.WINDOW_SERVICE);
  • the windowManager object is the parent class object of the dyApplication object, so it is equivalent to obtaining the dyApplication object of the DYFloatManage class.
  • the second establishing unit 23 is configured to establish a floating layer view function dyAddView and a floating layer view function dyRemoveView in the WindowManager class; and add an array object viewlds in the floating layer view controller class DYApplication.
  • the array object viewlds is of the int type; the array object is used to store the identification ID of each of the floating layer views, and each floating layer view has a unique ID.
  • each floating layer view object when directly stored, it takes up a large memory space and has a large overhead on system resources, and this embodiment can maintain a view object by using an array object of type int.
  • the object of the floating layer view controller class is called to add a floating layer view function to determine whether the array object exists.
  • the ID information of the current floating layer view; specifically, the added floating layer view function is determined by calling the conatins (viewld) function of the array object. If the function returns true, the current floating layer already exists in the array object. The view, that is to say the floating layer view has been displayed on the display interface, so the first request is rejected.
  • the function returns flase, it means that there is no current floating layer view in the array object, then use the conversion function findViewByld (viewld) to convert the current floating layer view ID into a floating layer view object; call the Add in WindowManager class
  • the view function addview displays the floating layer view object, and calls the add ID function add() in the array object to add the ID of the current floating layer view to the array object.
  • the object of the floating layer view controller class is called to remove the floating layer view function to determine whether the array object exists.
  • the ID information of the current floating layer view; specifically, the removal of the floating layer view function is determined by calling a conatins (viewld) function of the array object. If the function returns a flase, the array object does not exist.
  • the current floating layer view if the removal of the view at this time causes an exception to occur, rejects the second request and returns directly.
  • the view object is an empty object, and the second request may be rejected if the operation cannot be performed.
  • the embodiment further provides a computer device for implementing a view controller.
  • the computer device includes: a radio frequency (RF) circuit 310, a memory 320, an input unit 330, and a display unit 340.
  • RF radio frequency
  • Components such as audio circuit 350, WiFi module 360, processor 370, and power supply 380.
  • FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
  • the RF circuit 310 can be used for receiving and transmitting signals, and in particular, receiving downlink information of the base station and processing it to the processor 370.
  • RF circuit 310 includes, but is not limited to, at least one amplifier, transceiver, coupler, Low Noise Amplifier (LNA), duplexer, and the like.
  • LNA Low Noise Amplifier
  • the memory 320 can be used to store software programs and modules, and the processor 370 executes various functional applications and data processing of the computer devices by running software programs and modules stored in the memory 320.
  • the memory 320 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function, and the like; the storage data area may store data created according to usage of the computer device, and the like.
  • memory 320 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the input unit 330 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the computer device.
  • the input unit 330 may include a touch panel 331 and other input devices 332.
  • the touch panel 331 can collect input operations of the user and drive the corresponding connecting device according to a preset program.
  • the touch panel 331 collects the output information and sends it to the processor 370.
  • the input unit 330 may also include other input devices 332.
  • other input devices 332 may include, but are not limited to, one or more of a touch panel, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 340 can be used to display information input by the user or information provided to the user as well as various menus of the computer device.
  • the display unit 340 can include a display panel 341.
  • the display panel 341 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
  • the touch panel 331 can cover the display panel 341. When the touch panel 331 detects a touch operation on or near the touch panel 331, it transmits to the processor 370 to determine the type of the touch event, and then the processor 370 according to the input event. The type provides a corresponding visual output on display panel 341.
  • the touch panel 331 and the display panel 341 are implemented as two separate components in FIG. 3 to implement input and input functions of the computer device, in some embodiments, the touch panel 331 may be integrated with the display panel 341. Implement the input and output functions of computer equipment.
  • An audio circuit 350, a speaker 351, and a microphone 352 can provide an audio interface between the user and the computer device.
  • the audio circuit 350 can transmit the converted electrical data of the received audio data to the speaker 351, and convert it into a sound signal output by the speaker 351;
  • WiFi is a short-range wireless transmission technology.
  • the computer device can help users to send and receive emails, browse web pages and access streaming media through the WiFi module 360. It provides users with wireless broadband Internet access.
  • FIG. 3 shows the WiFi module 360, it can be understood that it does not belong to the essential configuration of the computer device, and may be omitted as needed within the scope of not changing the essence of the invention.
  • Processor 370 is a control center for computer devices that connects various portions of the entire computer device using various interfaces and lines, by running or executing software programs and/or modules stored in memory 320, and recalling data stored in memory 320. , performing various functions and processing data of the computer device, thereby performing overall monitoring of the computer device.
  • the processor 370 may include one or more processing units; preferably, the processor 370 may integrate an application processor, wherein the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the computer device also includes a power source 380 (such as a power adapter) that powers the various components.
  • a power source 380 such as a power adapter
  • the power source can be logically coupled to the processor 370 via a power management system.
  • the present invention provides a method, apparatus, and computer apparatus for implementing a view controller, the method comprising: establishing a floating layer view controller class, and setting a window management class in the application platform to the floating layer view control a parent class of the class; the object of the floating layer view controller class is obtained by using the first fetch function in the floating layer view controller class; an array object is created in the floating layer view controller class, The array object is used to store the identifier IDs of the plurality of floating layer views; when receiving the first request to add the current floating layer view, the object of the floating layer view controller class is called to add the floating layer view function to determine the array object.
  • the object call removes the floating layer view function to determine whether the ID of the current floating layer view exists in the array object, and if not, rejects the second request; thus, when receiving the added current float
  • the first request of the view first determines whether there is a floating layer view ID in the array object.
  • the current floating layer view is added to avoid adding the same view to the view controller multiple times;
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processing (DSP) may be used in practice to implement some of the gateways, proxy servers, some or all of the components in accordance with embodiments of the present invention. Or all features.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • a program implementing the present invention may be stored on a computer readable storage medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

Abstract

The present invention provides a method, an apparatus and a computer device for implementing a view controller, said method comprising: establishing an overlay view controller class, and configuring a window management class in an application platform as a parent class of the overlay view controller class; using a first acquisition function in the overlay view controller class to acquire an object of the overlay view controller class; establishing an array object in the overlay view controller class, the array object being used to store IDs of a plurality of overlay views; upon reception of a first request for adding a current overlay view, using the object of the overlay view controller class to invoke an overlay view adding function to determine whether the ID of the current overlay view exists in the array object, and if so, rejecting the first request; and upon reception of a second request for removing the current overlay view, using the object of the overlay view controller class to invoke an overlay view removing function to determine whether the ID of the current overlay view exists in the array object, and if not, rejecting the second request.

Description

一种用于实现视图控制器的方法、装置及计算机设备Method, device and computer device for implementing view controller 技术领域Technical field
本发明属于网络开发技术领域,尤其涉及一种实现视图控制器的方法、装置及计算机设备。The invention belongs to the technical field of network development, and in particular relates to a method, a device and a computer device for implementing a view controller.
背景技术Background technique
在Android系统的开发过程中会使用到浮层控制器WindowManager,WindowManager浮层控制器主要是用于显示和销毁浮层视图。在传统的开发过程中如果多次将同一个视图添加到浮层控制器中,这样就会使得视图层控制器上会显示出多个相同的浮层元素,显示混乱。如果误操作多次移除同一个浮层元素会直接引起系统崩溃,导致浮层控制器的稳定性得不到保证。The floating layer controller WindowManager is used in the development of the Android system. The WindowManager floating layer controller is mainly used to display and destroy the floating layer view. In the traditional development process, if the same view is added to the floating layer controller multiple times, this will cause multiple identical floating layer elements to be displayed on the view layer controller, showing confusion. If the same floating layer element is removed multiple times by mistake, the system will crash directly, and the stability of the floating layer controller will not be guaranteed.
发明内容Summary of the invention
针对现有技术存在的问题,本发明实施例提供一种实现视图控制器的方法、装置及计算机设备,用于解决现有技术的浮层控制器在添加或删除浮层视图时,由于浮层控制器本身的缺陷,导致浮层控制器的稳定性得不到保证的技术问题。The present invention provides a method, an apparatus, and a computer device for implementing a view controller, which are used to solve the floating layer controller of the prior art when adding or deleting a floating layer view due to a floating layer. The defect of the controller itself leads to technical problems that the stability of the floating layer controller is not guaranteed.
本发明实施例提供一种用于实现视图控制器的方法,所述方法包括:An embodiment of the present invention provides a method for implementing a view controller, where the method includes:
建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;Establish a floating layer view controller class, and set a window management class in the application platform to a parent class of the floating layer view controller class;
利用所述浮层视图控制器类中的第一获取函数获取所述浮层视图控制器类的对象;Acquiring an object of the floating layer view controller class by using a first acquisition function in the floating layer view controller class;
在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;Establishing an array object in the floating layer view controller class, where the array object is used to store identifier IDs of multiple floating layer views;
当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;When the first request for adding the current floating layer view is received, the object of the floating layer view controller class is called to add a floating layer view function to determine whether the ID of the current floating layer view exists in the array object, if any Rejecting the first request;
当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求。When receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call the remove floating layer view function to determine whether the current floating layer view exists in the array object The ID, if not present, rejects the second request.
上述方案中,所述利用所述在所述浮层视图控制器类中的第一获取函数获取浮层视图控制器类的对象,包括:In the above solution, the acquiring the object of the floating layer view controller class by using the first acquiring function in the floating layer view controller class includes:
建立一个自定义应用DYApplication类,并将应用平台中的应用类Application设置为所述自定义应用DYApplication类的父类;Create a custom application DYApplication class, and set the application class Application in the application platform to the parent class of the custom application DYApplication class;
复写所述DYApplication类中的创建函数oncreate;Copy the create function oncreate in the DYApplication class;
在所述DYApplication类中建立一个应用对象application,利用所述复写创建函数oncreate将所述DYApplication类的this指针赋值给所述application对象;Establishing an application object application in the DYApplication class, and using the copy creation function oncreate to assign the this pointer of the DYApplication class to the application object;
将赋值后的所述application对象作为第二获取函数getDYApplication的入口函数进行返回,获取上下文对象applicationContext;Returning the assigned application object as an entry function of the second get function getDYApplication to obtain a context object applicationContext;
调用所述上下文对象applicationContext的第三获取函数getSystemService(Context.WINDOW_SERVICE)获取所述窗口管理类的对象windowManager,所述窗口管理类的对象windowManager为浮层视图控制器类的对象的父类对象。The third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to acquire the object windowManager of the window management class, and the object windowManager of the window management class is a parent class object of the object of the floating layer view controller class.
上述方案中,当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用所添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则包括:In the above solution, when the first request for adding the current floating layer view is received, the object of the floating layer view controller class is used to call the added floating layer view function to determine whether the current floating layer view exists in the array object. The ID, if it does not exist, includes:
利用转换函数findViewByld(viewld)将所述当前浮层视图的ID转换为一个浮层视图对象;Converting the ID of the current floating layer view into a floating layer view object by using a conversion function findViewByld (viewld);
调用添加视图函数addview对所述浮层视图对象进行显示,并调用所述数组对象中的添加ID函数将所述当前浮层视图的ID添加至数组对象中。Calling the add view function addview to display the floating layer view object, and calling the add ID function in the array object to add the ID of the current floating layer view to the array object.
上述方案中,当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用所述移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则包括:In the above solution, when the second request for removing the current floating layer view is received, the object of the floating layer view controller class is used to call the remove floating layer view function to determine whether the array object exists. The ID of the current floating layer view, if any, includes:
基于所述当前浮层视图的ID查找所述当前浮层视图的对象;Finding an object of the current floating layer view based on an ID of the current floating layer view;
判断所述当前浮层视图以及所述当前浮层视图的父类视图是否为空,若确定所述当前浮层视图不为空且所述当前浮层视图的父类视图也不为空,则调用所述移除浮层视图函数removeView移除所述当前浮层视图。Determining whether the current floating layer view and the parent class view of the current floating layer view are empty. If it is determined that the current floating layer view is not empty and the parent class view of the current floating layer view is not empty, then Calling the remove floating layer view function removeView removes the current floating layer view.
上述方案中,确定所述当前浮层视图及所述当前浮层视图的父类视图只有一个为空,或者所述当前浮层视图及所述当前浮层视图的父类视图均为空,则拒绝所述第二请求。In the above solution, if only one parent class view of the current floating layer view and the current floating layer view is empty, or the parent class view of the current floating layer view and the current floating layer view are both empty, The second request is rejected.
本发明还提供一种用于实现视图控制器的装置,所述装置包括:The present invention also provides an apparatus for implementing a view controller, the apparatus comprising:
第一建立单元,用于建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;a first establishing unit, configured to establish a floating layer view controller class, and set a window management class in the application platform as a parent class of the floating layer view controller class;
获取单元,用于利用所述浮层视图控制器类中的第一获取函数获取所述浮层视图控制器类的对象;An obtaining unit, configured to acquire an object of the floating layer view controller class by using a first acquiring function in the floating layer view controller class;
第二建立单元,用于在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;a second establishing unit, configured to create an array object in the floating layer view controller class, where the array object is used to store identifier IDs of multiple floating layer views;
调用单元,用于当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;a calling unit, configured to determine, by using an object of the floating layer view controller class, a floating layer view function to determine whether the current floating layer view exists in the array object when receiving the first request to add a current floating layer view ID, if any, rejects the first request;
当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求。When receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call the remove floating layer view function to determine whether the current floating layer view exists in the array object The ID, if not present, rejects the second request.
上述方案中,所述建立单元具体用于:In the above solution, the establishing unit is specifically configured to:
建立一个自定义应用类DYApplication,并将应用平台中的应用类Application设置为所述自定义应用类DYApplication的父类;Create a custom application class DYApplication, and set the application class Application in the application platform to the parent class of the custom application class DYApplication;
复写所述DYApplication类中的创建函数oncreate;Copy the create function oncreate in the DYApplication class;
在所述DYApplication类中建立一个应用对象application,利用所述复写创建函数oncreate将所述DYApplication类的this指针赋值给所述application对象;Establishing an application object application in the DYApplication class, and using the copy creation function oncreate to assign the this pointer of the DYApplication class to the application object;
将赋值后的所述application对象作为第二获取函数getDYApplication的入口函数进行返回,获取上下文对象applicationContext;Returning the assigned application object as an entry function of the second get function getDYApplication to obtain a context object applicationContext;
调用所述上下文对象applicationContext的第三获取函数getSystemService(Context.WINDOW_SERVICE)获取所述窗口管理类的对象windowManager,所述窗口管理类的对象windowManager为浮层视图控制器类的对象的父类对象。The third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to acquire the object windowManager of the window management class, and the object windowManager of the window management class is a parent class object of the object of the floating layer view controller class.
上述方案中,所述调用单元具体用于:In the above solution, the calling unit is specifically configured to:
当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用所添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则利用转换函数findViewByld(viewld)将所述当前浮层视图的ID转换为一个浮层视图对象;When the first request for adding the current floating layer view is received, the object of the floating layer view controller class is used to call the added floating layer view function to determine whether the ID of the current floating layer view exists in the array object. If not, the ID of the current floating layer view is converted into a floating layer view object by using a conversion function findViewByld (viewld);
调用添加视图函数addview对所述浮层视图对象进行显示,并调用所述数组对象中的添加ID函数将所述当前浮层视图的ID添加至数组对象中。Calling the add view function addview to display the floating layer view object, and calling the add ID function in the array object to add the ID of the current floating layer view to the array object.
本发明还提供一种计算机可读存储介质,其上存储有计算机程序,程序被处理器执行时实现能够执行如上述任一所述的方法。The present invention also provides a computer readable storage medium having stored thereon a computer program that, when executed by a processor, implements a method as described in any of the above.
本发明还提供一种用于实现视图控制器的计算机设备,包括:The invention also provides a computer device for implementing a view controller, comprising:
至少一个处理器;以及At least one processor;
与所述处理器通信连接的至少一个存储器,其中,At least one memory communicatively coupled to the processor, wherein
所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述 程序指令能够执行如上述任一所述的方法。The memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of the above.
本发明提供了一种用于实现视图控制器的方法、装置及计算机设备,所述方法包括:建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;利用所述浮层视图控制器类中的第一获取函数获取浮层视图控制器类的对象;在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求;如此,当接收到添加当前浮层视图的第一请求时,会先判断数组对象中是否存在浮层视图的ID,若不存在才会添加该当前浮层视图,避免多次将同一个视图添加至视图控制器中;同样的,当接收到移除当前浮层视图的第二请求时,会先判断数组对象中是否存在浮层视图的ID,若没有,则不会进行移除操作,进而避免引起系统崩溃。The present invention provides a method, apparatus, and computer apparatus for implementing a view controller, the method comprising: establishing a floating layer view controller class, and setting a window management class in the application platform to the floating layer view control a parent class of the class; obtaining an object of the floating layer view controller class by using a first fetch function in the floating layer view controller class; creating an array object in the floating layer view controller class, the array object And storing an identifier ID of the plurality of floating layer views; when receiving the first request for adding the current floating layer view, using the object of the floating layer view controller class to call the added floating layer view function to determine whether the array object exists The ID of the current floating layer view, if present, rejecting the first request; when receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call The floating layer view function determines whether the ID of the current floating layer view exists in the array object, and if not, rejects the second request; thus, when receiving the current floating layer view is received When the first request is made, it first determines whether there is an ID of the floating layer view in the array object. If it does not exist, the current floating layer view is added to avoid adding the same view to the view controller multiple times; similarly, when receiving When the second request of the current floating layer view is removed, the ID of the floating layer view is first determined in the array object. If not, the removal operation is not performed, thereby avoiding a system crash.
附图说明DRAWINGS
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those skilled in the art from a The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting. Throughout the drawings, the same reference numerals are used to refer to the same parts. In the drawing:
图1为本发明实施例一提供的用于实现视图控制器的方法流程示意图;1 is a schematic flowchart of a method for implementing a view controller according to Embodiment 1 of the present invention;
图2为本发明实施例二提供的用于实现视图控制器的装置结构示意图;2 is a schematic structural diagram of an apparatus for implementing a view controller according to Embodiment 2 of the present invention;
图3为本发明实施例三提供的用于实现视图控制器的计算机设备的结构示意图。FIG. 3 is a schematic structural diagram of a computer device for implementing a view controller according to Embodiment 3 of the present invention.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, the embodiments Rather, these embodiments are provided so that this disclosure will be more fully understood and the scope of the disclosure will be fully disclosed.
实施例一Embodiment 1
本实施例提供一种用于实现视图控制器的方法,如图1所示,所述方法包括:This embodiment provides a method for implementing a view controller. As shown in FIG. 1, the method includes:
S110,建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;S110. Establish a floating layer view controller class, and set a window management class in the application platform to a parent class of the floating layer view controller class.
本步骤中,自定义一个浮层视图控制器DYFloatManage类,所述DYFloatManage类继承应用平台中的窗口管理WindowManager类,即窗口管理类为所述浮层视图控制器DYFloatManage类的父类。In this step, a floating layer view controller DYFloatManage class is customized, and the DYFloatManage class inherits the window management WindowManager class in the application platform, that is, the window management class is the parent class of the floating layer view controller DYFloatManage class.
S111,利用所述浮层视图控制器类中的第一获取函数获取浮层视图控制器类的对象;S111. Acquire an object of the floating layer view controller class by using a first acquiring function in the floating layer view controller class.
建立好DYFloatManage类后,利用所述在所述视图控制器DYFloatManage类中的第一获取函数public static DYFloatManager getFloatManager()获取浮层视图控制器类的对象dyFloatManager,具体实现如下:After the DYFloatManage class is created, the first dyFloatManager object of the floating layer view controller class is obtained by using the first get function public static DYFloatManager getFloatManager() in the view controller DYFloatManage class, and the specific implementation is as follows:
先一个自定义应用DYApplication类,并将应用平台中的应用类Application设置为所述自定义应用DYApplication类的父类;First customize the application DYApplication class, and set the application class Application in the application platform to the parent class of the custom application DYApplication class;
复写所述DYApplication类中的创建函数oncreate,所述oncreate会在应用平台启动的时候被调用。The creation function oncreate in the DYApplication class is overwritten, and the oncreate is called when the application platform is started.
在所述DYApplication类中建立一个应用对象application,利用所述复写创建函数oncreate将所述DYApplication类的this指针赋值给所述application对象,这样application对象就会有一个值。An application object application is created in the DYApplication class, and the this pointer of the DYApplication class is assigned to the application object by using the replication creation function oncreate, so that the application object has a value.
再将赋值后的所述application对象作为第二获取函数getDYApplication的入口函数进行返回,获取上下文对象applicationContext;其中,所述第二获取函数getDYApplication是在DYApplication类中预先定义的,所述第二获取函数getDYApplication具有一个出口函数和一个入口函数,将所述application对象作为所述第二获取函数getDYApplication的入口函数,那么运行所述第二获取函数getDYApplication后,就会获取一个出口函数,所述上下文对象applicationContext即为该出口函数。And returning the assigned application object as an entry function of the second get function getDYApplication to obtain a context object applicationContext; wherein the second get function getDYApplication is predefined in the DYApplication class, and the second get function The getDYApplication has an exit function and an entry function, and the application object is used as an entry function of the second get function getDYApplication, then after running the second get function getDYApplication, an exit function is obtained, the context object applicationContext That is the exit function.
然后调用所述上下文对象applicationContext的第三获取函数getSystemService(Context.WINDOW_SERVICE)获取一个浮层管理服务对象,由于该对象是Object类型的对象,因此需要该Object类型的对象强制转换成WindowManager对象,具体实现如下:Then, the third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to obtain a floating layer management service object. Since the object is an Object type object, the Object type object is required to be converted into a WindowManager object, and the specific implementation is implemented. as follows:
WindowManager          windowManager=(WindowManager)getDYApplication().getSystemService(Context.WINDOW_SERVICE);WindowManager windowManager=(WindowManager)getDYApplication().getSystemService(Context.WINDOW_SERVICE);
这样就获取到窗口管理类的对象windowManager了。This gets the windowManager object of the window management class.
这里,因WindowManager类为所述视图控制器DYFloatManage类的父类,所以所述windowManager对象为dyApplication对象的父类对象,因此相当于获取到了DYFloatManage类的dyApplication对象了。Here, since the WindowManager class is the parent class of the view controller DYFloatManage class, the windowManager object is the parent class object of the dyApplication object, so it is equivalent to obtaining the dyApplication object of the DYFloatManage class.
S112,在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;S112, creating an array object in the floating layer view controller class, where the array object is used to store identifier IDs of multiple floating layer views;
获取到dyApplication对象后,在所述WindowManager类中建立浮层视图函数dyAddView、移除浮层视图函数dyRemoveView;在所述浮层视图控制器类DYApplication中建立添加数组对象viewlds,所述数组对象viewlds为int类型的;所述数组对象用于存储各所述浮层视图的标识ID,每个浮层视图都具有一个唯一的ID。After the dyApplication object is obtained, a floating layer view function dyAddView is created in the WindowManager class, and a floating layer view function dyRemoveView is removed; and an array object viewlds is created in the floating layer view controller class DYApplication, and the array object viewlds is The int type is used to store the identifier ID of each of the floating layer views, and each floating layer view has a unique ID.
这里,因直接将各浮层视图对象进行存储时,会占用很大的内存空间且会对系统资源的开销较大,而本实施例利用一个int类型的数组对象就可以维护一个视图对象。Here, when each floating layer view object is directly stored, it takes up a large memory space and has a large overhead on system resources, and this embodiment can maintain a view object by using an array object of type int.
S113,当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求。S113, when receiving the first request for adding the current floating layer view, using an object of the floating layer view controller class to call the add floating layer view function to determine whether the ID of the current floating layer view exists in the array object, If yes, rejecting the first request; when receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call the remove floating layer view function to determine the array Whether the ID of the current floating layer view exists in the object, and if not, rejects the second request.
数组对象建立好之后,当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID信息;具体地,添加浮层视图函数通过调用数组对象在中的conatins(viewld)函数来进行判断的,若该函数返回为true,则说明数组对象中已经存在当前浮层视图,也就是说显示界面上已经显示过该浮层视图了,因此则拒绝第一请求。After the array object is created, when the first request for adding the current floating layer view is received, the object of the floating layer view controller class is called to add a floating layer view function to determine whether the current floating layer exists in the array object. View ID information; specifically, adding a floating layer view function is determined by calling the conatins (viewld) function of the array object. If the function returns true, the current floating layer view already exists in the array object. That is to say, the floating layer view has been displayed on the display interface, so the first request is rejected.
若该函数返回为flase,则说明数组对象中还没有当前浮层视图,则利用转换函数findViewByld(viewld)将所述当前浮层视图的ID转换为一个浮层视图对象;调用WindowManager类中的添加视图函数addview对所述浮层视图对象进行显示,并调用所述数组对象中的添加ID函数add()将所述当前浮层视图的ID添加至数组对象中。If the function returns flase, it means that there is no current floating layer view in the array object, then use the conversion function findViewByld (viewld) to convert the current floating layer view ID into a floating layer view object; call the Add in WindowManager class The view function addview displays the floating layer view object, and calls the add ID function add() in the array object to add the ID of the current floating layer view to the array object.
同样的道理,当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID信息;具体地,移除浮层视图函数通过调用数组对象在中的conatins(viewld)函数来进行判断的,若该函数返回为flase,则说明数组对象中不存在当前浮层视图,如果此时移除视图会导致异常情况发生,则拒绝所述第二请求,直接返回。By the same token, when receiving the second request to remove the current floating layer view, the object of the floating layer view controller class is called to remove the floating layer view function to determine whether the current object exists in the array object. The ID information of the floating layer view; specifically, the removal of the floating layer view function is determined by calling the conatins (viewld) function of the array object. If the function returns flase, the current floating layer does not exist in the array object. View, if removing the view at this time will cause an exception to occur, reject the second request and return directly.
若该函数返回为true,则说明数组对象中已经存在当前浮层视图,那么会 基于所述当前浮层视图的ID查找所述当前浮层视图的对象;If the function returns true, it indicates that the current floating layer view already exists in the array object, and then the object of the current floating layer view is searched based on the ID of the current floating layer view;
判断所述当前浮层视图以及所述当前浮层视图的父类视图是否为空,若确定所述当前浮层视图不为空且所述当前浮层视图的父类视图也不为空,则调用所述移除浮层视图函数removeView移除所述当前浮层视图。Determining whether the current floating layer view and the parent class view of the current floating layer view are empty. If it is determined that the current floating layer view is not empty and the parent class view of the current floating layer view is not empty, then Calling the remove floating layer view function removeView removes the current floating layer view.
若确定所述当前浮层视图不为空但是所述当前浮层视图的父类视图为空,则说明该浮层视图不是依附于本实施例中的浮层控制器中的,因此拒绝第二请求;或者,If it is determined that the current floating layer view is not empty but the parent class view of the current floating layer view is empty, it indicates that the floating layer view is not attached to the floating layer controller in this embodiment, and therefore rejects the second Request; or,
若确定所述当前浮层视图为空但是所述当前浮层视图的父类视图不为空,也拒绝第二请求;If the current floating layer view is determined to be empty but the parent class view of the current floating layer view is not empty, the second request is also rejected;
或者,所述当前浮层视图及所述当前浮层视图的父类视图均为空,则表示该视图对象是一个空对象,无法对其进行操作,就拒绝所述第二请求。Alternatively, if the parent class view of the current floating layer view and the current floating layer view are both empty, the view object is an empty object, and the second request may be rejected if the operation cannot be performed.
这样就会避免多次将同一个视图添加至视图控制器中引起显示界面混乱,且避免因误操作移除浮层视图,进而避免引起系统崩溃。This will avoid adding the same view to the view controller multiple times, causing the display interface to be confusing, and avoid removing the floating layer view due to misoperation, thus avoiding system crash.
实施例二Embodiment 2
相应于实施例一,本实施例还提供一种用于实现视图控制器的装置,如图2所示,所述装置包括:第一建立单元21、获取单元22、第二建立单元23、调用单元24;其中,Corresponding to the first embodiment, the embodiment further provides an apparatus for implementing a view controller. As shown in FIG. 2, the apparatus includes: a first establishing unit 21, an obtaining unit 22, a second establishing unit 23, and a call. Unit 24; wherein
第一建立单元21用于建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述视图控制器类的父类。The first establishing unit 21 is configured to establish a floating layer view controller class, and set a window management class in the application platform as a parent class of the view controller class.
具体地,第一建立单元21自定义一个浮层视图控制器DYFloatManage类,所述DYFloatManage类继承应用平台中的窗口管理WindowManager类,即窗口管理类为所述视图控制器DYFloatManage类的父类。Specifically, the first establishing unit 21 customizes a floating layer view controller DYFloatManage class, and the DYFloatManage class inherits the window management WindowManager class in the application platform, that is, the window management class is the parent class of the view controller DYFloatManage class.
获取单元22用于利用所述浮层视图控制器类中的第一获取函数获取浮层视图控制器类的对象。The obtaining unit 22 is configured to acquire an object of the floating layer view controller class by using the first acquiring function in the floating layer view controller class.
具体地,建立好DYFloatManage类后,获取单元22利用所述在所述视图控制器DYFloatManage类中的第一获取函数public static DYFloatManager getFloatManager()获取浮层视图控制器类的对象dyFloatManager,具体实现如下:Specifically, after the DYFloatManage class is created, the obtaining unit 22 obtains the object dyFloatManager of the floating layer view controller class by using the first get function public static DYFloatManager getFloatManager() in the view controller DYFloatManage class, and the specific implementation is as follows:
先一个自定义应用DYApplication类,并将应用平台中的应用类Application设置为所述自定义应用DYApplication类的父类;First customize the application DYApplication class, and set the application class Application in the application platform to the parent class of the custom application DYApplication class;
复写所述DYApplication类中的创建函数oncreate,所述oncreate会在应用平台启动的时候被调用。The creation function oncreate in the DYApplication class is overwritten, and the oncreate is called when the application platform is started.
在所述DYApplication类中建立一个应用对象application,利用所述复写创建函数oncreate将所述DYApplication类的this指针赋值给所述 application对象,这样application对象就会有一个值。An application object application is created in the DYApplication class, and the this pointer of the DYApplication class is assigned to the application object by using the replication creation function oncreate, so that the application object has a value.
再将赋值后的所述application对象作为第二获取函数getDYApplication的入口函数进行返回,获取上下文对象applicationContext;其中,所述第二获取函数getDYApplication是在DYApplication类中预先定义的,所述第二获取函数getDYApplication具有一个出口函数和一个入口函数,将所述application对象作为所述第二获取函数getDYApplication的入口函数,那么运行所述第二获取函数getDYApplication后,就会获取一个出口函数,所述上下文对象applicationContext即为该出口函数。And returning the assigned application object as an entry function of the second get function getDYApplication to obtain a context object applicationContext; wherein the second get function getDYApplication is predefined in the DYApplication class, and the second get function The getDYApplication has an exit function and an entry function, and the application object is used as an entry function of the second get function getDYApplication, then after running the second get function getDYApplication, an exit function is obtained, the context object applicationContext That is the exit function.
然后调用所述上下文对象applicationContext的第三获取函数getSystemService(Context.WINDOW_SERVICE)获取一个浮层管理服务对象,由于该对象是Object类型的对象,因此需要该Object类型的对象强制转换成WindowManager对象,具体实现如下:Then, the third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to obtain a floating layer management service object. Since the object is an Object type object, the Object type object is required to be converted into a WindowManager object, and the specific implementation is implemented. as follows:
WindowManager      windowManager=(WindowManager)getDYApplication().getSystemService(Context.WINDOW_SERVICE);WindowManager windowManager=(WindowManager)getDYApplication().getSystemService(Context.WINDOW_SERVICE);
这样就获取到窗口管理类的对象windowManager了。This gets the windowManager object of the window management class.
这里,因WindowManager类为所述视图控制器DYFloatManage类的父类,所以所述windowManager对象为dyApplication对象的父类对象,因此相当于获取到了DYFloatManage类的dyApplication对象了。Here, since the WindowManager class is the parent class of the view controller DYFloatManage class, the windowManager object is the parent class object of the dyApplication object, so it is equivalent to obtaining the dyApplication object of the DYFloatManage class.
获取到dyApplication对象后,第二建立单元23用于在所述WindowManager类中建立浮层视图函数dyAddView、移除浮层视图函数dyRemoveView;在所述浮层视图控制器类DYApplication中建立添加数组对象viewlds,所述数组对象viewlds为int类型的;所述数组对象用于存储各所述浮层视图的标识ID,每个浮层视图都具有一个唯一的ID。After the dyApplication object is obtained, the second establishing unit 23 is configured to establish a floating layer view function dyAddView and a floating layer view function dyRemoveView in the WindowManager class; and add an array object viewlds in the floating layer view controller class DYApplication. The array object viewlds is of the int type; the array object is used to store the identification ID of each of the floating layer views, and each floating layer view has a unique ID.
这里,因直接将各浮层视图对象进行存储时,会占用很大的内存空间且会对系统资源的开销较大,而本实施例利用一个int类型的数组对象就可以维护一个视图对象。Here, when each floating layer view object is directly stored, it takes up a large memory space and has a large overhead on system resources, and this embodiment can maintain a view object by using an array object of type int.
数组对象建立好之后,当调用单元24接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID信息;具体地,添加浮层视图函数通过调用数组对象在中的conatins(viewld)函数来进行判断的,若该函数返回为true,则说明数组对象中已经存在当前浮层视图,也就是说显示界面上已经显示过该浮层视图了,因此则拒绝第一请求。After the array object is established, when the calling unit 24 receives the first request to add the current floating layer view, the object of the floating layer view controller class is called to add a floating layer view function to determine whether the array object exists. The ID information of the current floating layer view; specifically, the added floating layer view function is determined by calling the conatins (viewld) function of the array object. If the function returns true, the current floating layer already exists in the array object. The view, that is to say the floating layer view has been displayed on the display interface, so the first request is rejected.
若该函数返回为flase,则说明数组对象中还没有当前浮层视图,则利用转换函数findViewByld(viewld)将所述当前浮层视图的ID转换为一个浮层视 图对象;调用WindowManager类中的添加视图函数addview对所述浮层视图对象进行显示,并调用所述数组对象中的添加ID函数add()将所述当前浮层视图的ID添加至数组对象中。If the function returns flase, it means that there is no current floating layer view in the array object, then use the conversion function findViewByld (viewld) to convert the current floating layer view ID into a floating layer view object; call the Add in WindowManager class The view function addview displays the floating layer view object, and calls the add ID function add() in the array object to add the ID of the current floating layer view to the array object.
同样的道理,当调用单元24接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID信息;具体地,移除浮层视图函数通过调用数组对象在中的conatins(viewld)函数来进行判断的,若该函数返回为flase,则说明数组对象中不存在当前浮层视图,如果此时移除视图会导致异常情况发生,则拒绝所述第二请求,直接返回。By the same token, when the calling unit 24 receives the second request to remove the current floating layer view, the object of the floating layer view controller class is called to remove the floating layer view function to determine whether the array object exists. The ID information of the current floating layer view; specifically, the removal of the floating layer view function is determined by calling a conatins (viewld) function of the array object. If the function returns a flase, the array object does not exist. The current floating layer view, if the removal of the view at this time causes an exception to occur, rejects the second request and returns directly.
若该函数返回为true,则说明数组对象中已经存在当前浮层视图,那么会基于所述当前浮层视图的ID查找所述当前浮层视图的对象;If the function returns true, it indicates that the current floating layer view already exists in the array object, and then the object of the current floating layer view is searched based on the ID of the current floating layer view;
判断所述当前浮层视图以及所述当前浮层视图的父类视图是否为空,若确定所述当前浮层视图不为空且所述当前浮层视图的父类视图也不为空,则调用所述移除浮层视图函数removeView移除所述当前浮层视图。Determining whether the current floating layer view and the parent class view of the current floating layer view are empty. If it is determined that the current floating layer view is not empty and the parent class view of the current floating layer view is not empty, then Calling the remove floating layer view function removeView removes the current floating layer view.
若确定所述当前浮层视图不为空但是所述当前浮层视图的父类视图为空,则说明该浮层视图不是依附于本实施例中的浮层控制器中的,因此拒绝第二请求;或者,If it is determined that the current floating layer view is not empty but the parent class view of the current floating layer view is empty, it indicates that the floating layer view is not attached to the floating layer controller in this embodiment, and therefore rejects the second Request; or,
若确定所述当前浮层视图为空但是所述当前浮层视图的父类视图不为空,也拒绝第二请求;If the current floating layer view is determined to be empty but the parent class view of the current floating layer view is not empty, the second request is also rejected;
或者,所述当前浮层视图及所述当前浮层视图的父类视图均为空,则表示该视图对象是一个空对象,无法对其进行操作,就拒绝所述第二请求。Alternatively, if the parent class view of the current floating layer view and the current floating layer view are both empty, the view object is an empty object, and the second request may be rejected if the operation cannot be performed.
这样就会避免多次将同一个视图添加至视图控制器中引起显示界面混乱,且避免因误操作移除浮层视图,进而避免引起系统崩溃。This will avoid adding the same view to the view controller multiple times, causing the display interface to be confusing, and avoid removing the floating layer view due to misoperation, thus avoiding system crash.
实施例三Embodiment 3
本实施例还提供一种用于实现视图控制器的计算机设备,如图3所示,所述计算机设备包括:射频(Radio Frequency,RF)电路310、存储器320、输入单元330、显示单元340、音频电路350、WiFi模块360、处理器370、以及电源380等部件。本领域技术人员可以理解,图3中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。The embodiment further provides a computer device for implementing a view controller. As shown in FIG. 3, the computer device includes: a radio frequency (RF) circuit 310, a memory 320, an input unit 330, and a display unit 340. Components such as audio circuit 350, WiFi module 360, processor 370, and power supply 380. Those skilled in the art will appreciate that the computer device architecture illustrated in FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
下面结合图3对计算机设备的各个构成部件进行具体的介绍:The specific components of the computer device will be specifically described below with reference to FIG. 3:
RF电路310可用于信号的接收和发送,特别地,将基站的下行信息接收后,给处理器370处理。通常,RF电路310包括但不限于至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。The RF circuit 310 can be used for receiving and transmitting signals, and in particular, receiving downlink information of the base station and processing it to the processor 370. Generally, RF circuit 310 includes, but is not limited to, at least one amplifier, transceiver, coupler, Low Noise Amplifier (LNA), duplexer, and the like.
存储器320可用于存储软件程序以及模块,处理器370通过运行存储在存储器320的软件程序以及模块,从而执行计算机设备的各种功能应用以及数据处理。存储器320可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据计算机设备的使用所创建的数据等。此外,存储器320可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The memory 320 can be used to store software programs and modules, and the processor 370 executes various functional applications and data processing of the computer devices by running software programs and modules stored in the memory 320. The memory 320 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function, and the like; the storage data area may store data created according to usage of the computer device, and the like. Moreover, memory 320 can include high speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
输入单元330可用于接收输入的数字或字符信息,以及产生与计算机设备的用户设置以及功能控制有关的键信号输入。具体地,输入单元330可包括触控面板331以及其他输入设备332。触控面板331,可收集用户在其上的输入操作,并根据预先设定的程式驱动相应的连接装置。触控面板331采集到输出信息后再送给处理器370。除了触控面板331,输入单元330还可以包括其他输入设备332。具体地,其他输入设备332可以包括但不限于触控面板、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。The input unit 330 can be configured to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the computer device. Specifically, the input unit 330 may include a touch panel 331 and other input devices 332. The touch panel 331 can collect input operations of the user and drive the corresponding connecting device according to a preset program. The touch panel 331 collects the output information and sends it to the processor 370. In addition to the touch panel 331, the input unit 330 may also include other input devices 332. Specifically, other input devices 332 may include, but are not limited to, one or more of a touch panel, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, joysticks, and the like.
显示单元340可用于显示由用户输入的信息或提供给用户的信息以及计算机设备的各种菜单。显示单元340可包括显示面板341,可选的,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板341。进一步的,触控面板331可覆盖显示面板341,当触控面板331检测到在其上或附近的触摸操作后,传送给处理器370以确定触摸事件的类型,随后处理器370根据输入事件的类型在显示面板341上提供相应的视觉输出。虽然在图3中触控面板331与显示面板341是作为两个独立的部件来实现计算机设备的输入和输入功能,但是在某些实施例中,可以将触控面板331与显示面板341集成而实现计算机设备的输入和输出功能。The display unit 340 can be used to display information input by the user or information provided to the user as well as various menus of the computer device. The display unit 340 can include a display panel 341. Alternatively, the display panel 341 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Further, the touch panel 331 can cover the display panel 341. When the touch panel 331 detects a touch operation on or near the touch panel 331, it transmits to the processor 370 to determine the type of the touch event, and then the processor 370 according to the input event. The type provides a corresponding visual output on display panel 341. Although the touch panel 331 and the display panel 341 are implemented as two separate components in FIG. 3 to implement input and input functions of the computer device, in some embodiments, the touch panel 331 may be integrated with the display panel 341. Implement the input and output functions of computer equipment.
音频电路350、扬声器351,传声器352可提供用户与计算机设备之间的音频接口。音频电路350可将接收到的音频数据转换后的电信号,传输到扬声器351,由扬声器351转换为声音信号输出;An audio circuit 350, a speaker 351, and a microphone 352 can provide an audio interface between the user and the computer device. The audio circuit 350 can transmit the converted electrical data of the received audio data to the speaker 351, and convert it into a sound signal output by the speaker 351;
WiFi属于短距离无线传输技术,计算机设备通过WiFi模块360可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图3示出了WiFi模块360,但是可以理解的是,其并不属于计算机设备的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。WiFi is a short-range wireless transmission technology. The computer device can help users to send and receive emails, browse web pages and access streaming media through the WiFi module 360. It provides users with wireless broadband Internet access. Although FIG. 3 shows the WiFi module 360, it can be understood that it does not belong to the essential configuration of the computer device, and may be omitted as needed within the scope of not changing the essence of the invention.
处理器370是计算机设备的控制中心,利用各种接口和线路连接整个计算机设备的各个部分,通过运行或执行存储在存储器320内的软件程序和/或模块,以及调用存储在存储器320内的数据,执行计算机设备的各种功能和处理 数据,从而对计算机设备进行整体监控。可选的,处理器370可包括一个或多个处理单元;优选的,处理器370可集成应用处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等。 Processor 370 is a control center for computer devices that connects various portions of the entire computer device using various interfaces and lines, by running or executing software programs and/or modules stored in memory 320, and recalling data stored in memory 320. , performing various functions and processing data of the computer device, thereby performing overall monitoring of the computer device. Optionally, the processor 370 may include one or more processing units; preferably, the processor 370 may integrate an application processor, wherein the application processor mainly processes an operating system, a user interface, an application, and the like.
计算机设备还包括给各个部件供电的电源380(比如电源适配器),优选的,电源可以通过电源管理系统与处理器370逻辑相连。The computer device also includes a power source 380 (such as a power adapter) that powers the various components. Preferably, the power source can be logically coupled to the processor 370 via a power management system.
本发明实施例提供的用于实现视图控制器的方法、装置及计算机设备能带来的有益效果至少是:The beneficial effects of the method, device and computer device for implementing the view controller provided by the embodiments of the present invention are at least:
本发明提供了一种用于实现视图控制器的方法、装置及计算机设备,所述方法包括:建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;利用所述在所述浮层视图控制器类中的第一获取函数获取浮层视图控制器类的对象;在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求;如此,当接收到添加当前浮层视图的第一请求时,会先判断数组对象中是否存在浮层视图的ID,若不存在才会添加该当前浮层视图,避免多次将同一个视图添加至视图控制器中;同样的,当接收到移除当前浮层视图的第二请求时,会先判断数组对象中是否存在浮层视图的ID,若没有,则不会进行移除操作,进而避免引起系统崩溃;并且本实施例在对各浮层视图对象进行存储时,存储的是各浮层视图的ID,因此减少了占用的内存空间。The present invention provides a method, apparatus, and computer apparatus for implementing a view controller, the method comprising: establishing a floating layer view controller class, and setting a window management class in the application platform to the floating layer view control a parent class of the class; the object of the floating layer view controller class is obtained by using the first fetch function in the floating layer view controller class; an array object is created in the floating layer view controller class, The array object is used to store the identifier IDs of the plurality of floating layer views; when receiving the first request to add the current floating layer view, the object of the floating layer view controller class is called to add the floating layer view function to determine the array object. Whether the ID of the current floating layer view exists, if yes, rejecting the first request; when receiving the second request to remove the current floating layer view, using the floating layer view controller class The object call removes the floating layer view function to determine whether the ID of the current floating layer view exists in the array object, and if not, rejects the second request; thus, when receiving the added current float The first request of the view first determines whether there is a floating layer view ID in the array object. If it does not exist, the current floating layer view is added to avoid adding the same view to the view controller multiple times; When receiving the second request to remove the current floating layer view, it is first determined whether the ID of the floating layer view exists in the array object, and if not, the removal operation is not performed, thereby avoiding causing a system crash; and the embodiment When storing each floating layer view object, the ID of each floating layer view is stored, thus reducing the occupied memory space.
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general purpose systems can also be used with the teaching based on the teachings herein. The structure required to construct such a system is apparent from the above description. Moreover, the invention is not directed to any particular programming language. It is to be understood that the invention may be embodied in a variety of programming language, and the description of the specific language has been described above in order to disclose the preferred embodiments of the invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of the description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法 解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, the various features of the invention are sometimes grouped together into a single embodiment, in the above description of the exemplary embodiments of the invention, Figure, or a description of it. However, the method disclosed is not to be interpreted as reflecting the intention that the claimed invention requires more features than those recited in the claims. Rather, as the following claims reflect, inventive aspects reside in less than all features of the single embodiments disclosed herein. Therefore, the claims following the specific embodiments are hereby explicitly incorporated into the embodiments, and each of the claims as a separate embodiment of the invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components. In addition to such features and/or at least some of the processes or units being mutually exclusive, any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined. Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
此外,本领域的技术人员能够理解,尽管在此的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。In addition, those skilled in the art will appreciate that although some embodiments herein include certain features included in other embodiments and not other features, combinations of features of different embodiments are intended to be within the scope of the present invention. And different embodiments are formed. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP,Digital Signal Processing)来实现根据本发明实施例的网关、代理服务器、系统中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读存储介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processing (DSP) may be used in practice to implement some of the gateways, proxy servers, some or all of the components in accordance with embodiments of the present invention. Or all features. The invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the present invention may be stored on a computer readable storage medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体 体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It is to be noted that the above-described embodiments are illustrative of the invention and are not intended to be limiting, and that the invention may be devised without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as a limitation. The word "comprising" does not exclude the presence of the elements or steps that are not recited in the claims. The word "a" or "an" The invention can be implemented by means of hardware comprising several distinct elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means can be embodied by the same hardware item. The use of the words first, second, and third does not indicate any order. These words can be interpreted as names.
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above is only the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in Within the scope of protection of the present invention.

Claims (10)

  1. 一种用于实现视图控制器的方法,其特征在于,所述方法包括:A method for implementing a view controller, the method comprising:
    建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;Establish a floating layer view controller class, and set a window management class in the application platform to a parent class of the floating layer view controller class;
    利用所述浮层视图控制器类中的第一获取函数获取所述浮层视图控制器类的对象;Acquiring an object of the floating layer view controller class by using a first acquisition function in the floating layer view controller class;
    在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;Establishing an array object in the floating layer view controller class, where the array object is used to store identifier IDs of multiple floating layer views;
    当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;When the first request for adding the current floating layer view is received, the object of the floating layer view controller class is called to add a floating layer view function to determine whether the ID of the current floating layer view exists in the array object, if any Rejecting the first request;
    当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求。When receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call the remove floating layer view function to determine whether the current floating layer view exists in the array object The ID, if not present, rejects the second request.
  2. 如权利要求1所述的方法,其特征在于,所述利用所述在所述浮层视图控制器类中的第一获取函数获取浮层视图控制器类的对象,包括:The method of claim 1, wherein the obtaining the object of the floating layer view controller class by using the first acquisition function in the floating layer view controller class comprises:
    建立一个自定义应用DYApplication类,并将应用平台中的应用类Application设置为所述自定义应用DYApplication类的父类;Create a custom application DYApplication class, and set the application class Application in the application platform to the parent class of the custom application DYApplication class;
    复写所述DYApplication类中的创建函数oncreate;Copy the create function oncreate in the DYApplication class;
    在所述DYApplication类中建立一个应用对象application,利用所述复写创建函数oncreate将所述DYApplication类的this指针赋值给所述application对象;Establishing an application object application in the DYApplication class, and using the copy creation function oncreate to assign the this pointer of the DYApplication class to the application object;
    将赋值后的所述application对象作为第二获取函数getDYApplication的入口函数进行返回,获取上下文对象applicationContext;Returning the assigned application object as an entry function of the second get function getDYApplication to obtain a context object applicationContext;
    调用所述上下文对象applicationContext的第三获取函数getSystemService(Context.WINDOW_SERVICE)获取所述窗口管理类的对象windowManager,所述窗口管理类的对象windowManager为浮层视图控制器类的对象的父类对象。The third acquisition function getSystemService(Context.WINDOW_SERVICE) of the context object applicationContext is called to acquire the object windowManager of the window management class, and the object windowManager of the window management class is a parent class object of the object of the floating layer view controller class.
  3. 如权利要求1所述的方法,其特征在于,当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用所添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则包括:The method according to claim 1, wherein when the first request for adding the current floating layer view is received, the object of the floating layer view controller class is used to call the added floating layer view function to determine the array object. Whether the ID of the current floating layer view exists, and if not, includes:
    利用转换函数findViewByld(viewld)将所述当前浮层视图的ID转换为一个浮层视图对象;Converting the ID of the current floating layer view into a floating layer view object by using a conversion function findViewByld (viewld);
    调用添加视图函数addview对所述浮层视图对象进行显示,并调用所述数 组对象中的添加ID函数将所述当前浮层视图的ID添加至数组对象中。The add view function addview is called to display the floating layer view object, and the add ID function in the array object is called to add the ID of the current floating layer view to the array object.
  4. 如权利要求1所述的方法,其特征在于,当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用所述移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则包括:The method of claim 1 wherein said removing said floating layer view function is invoked with an object of said floating layer view controller class upon receiving a second request to remove said current floating layer view Determining whether the ID of the current floating layer view exists in the array object, if yes, including:
    基于所述当前浮层视图的ID查找所述当前浮层视图的对象;Finding an object of the current floating layer view based on an ID of the current floating layer view;
    判断所述当前浮层视图以及所述当前浮层视图的父类视图是否为空,若确定所述当前浮层视图不为空且所述当前浮层视图的父类视图也不为空,则调用所述移除浮层视图函数removeView移除所述当前浮层视图。Determining whether the current floating layer view and the parent class view of the current floating layer view are empty. If it is determined that the current floating layer view is not empty and the parent class view of the current floating layer view is not empty, then Calling the remove floating layer view function removeView removes the current floating layer view.
  5. 如权利要求4所述的方法,其特征在于,确定所述当前浮层视图及所述当前浮层视图的父类视图只有一个为空,或者所述当前浮层视图及所述当前浮层视图的父类视图均为空,则拒绝所述第二请求。The method of claim 4, wherein only one of the parent class view of the current floating layer view and the current floating layer view is empty, or the current floating layer view and the current floating layer view are determined. If the parent class view is empty, the second request is rejected.
  6. 一种用于实现视图控制器的装置,其特征在于,所述装置包括:An apparatus for implementing a view controller, the apparatus comprising:
    第一建立单元,用于建立浮层视图控制器类,并将应用平台中的窗口管理类设置为所述浮层视图控制器类的父类;a first establishing unit, configured to establish a floating layer view controller class, and set a window management class in the application platform as a parent class of the floating layer view controller class;
    获取单元,用于利用所述浮层视图控制器类中的第一获取函数获取所述浮层视图控制器类的对象;An obtaining unit, configured to acquire an object of the floating layer view controller class by using a first acquiring function in the floating layer view controller class;
    第二建立单元,用于在所述浮层视图控制器类中建立数组对象,所述数组对象用于存储多个浮层视图的标识ID;a second establishing unit, configured to create an array object in the floating layer view controller class, where the array object is used to store identifier IDs of multiple floating layer views;
    调用单元,用于当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若存在,则拒绝所述第一请求;a calling unit, configured to determine, by using an object of the floating layer view controller class, a floating layer view function to determine whether the current floating layer view exists in the array object when receiving the first request to add a current floating layer view ID, if any, rejects the first request;
    当接收到移除所述当前浮层视图的第二请求时,利用所述浮层视图控制器类的对象调用移除浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则拒绝所述第二请求。When receiving the second request to remove the current floating layer view, using the object of the floating layer view controller class to call the remove floating layer view function to determine whether the current floating layer view exists in the array object The ID, if not present, rejects the second request.
  7. 如权利要求6所述的装置,其特征在于,所述建立单元具体用于:The apparatus according to claim 6, wherein the establishing unit is specifically configured to:
    建立一个自定义应用类DYApplication,并将应用平台中的应用类Application设置为所述自定义应用类DYApplication的父类;Create a custom application class DYApplication, and set the application class Application in the application platform to the parent class of the custom application class DYApplication;
    复写所述DYApplication类中的创建函数oncreate;Copy the create function oncreate in the DYApplication class;
    在所述DYApplication类中建立一个应用对象application,利用所述复写创建函数oncreate将所述DYApplication类的this指针赋值给所述application对象;Establishing an application object application in the DYApplication class, and using the copy creation function oncreate to assign the this pointer of the DYApplication class to the application object;
    将赋值后的所述application对象作为第二获取函数getDYApplication的入口函数进行返回,获取上下文对象applicationContext;Returning the assigned application object as an entry function of the second get function getDYApplication to obtain a context object applicationContext;
    调用所述上下文对象applicationContext的第三获取函数 getSystemService(Context.WINDOW_SERVICE)获取所述窗口管理类的对象windowManager,所述窗口管理类的对象windowManager为浮层视图控制器类的对象的父类对象。The third acquisition function getSystemService(Context.WINDOW_SERVICE) that invokes the context object applicationContext acquires the object windowManager of the window management class, and the object windowManager of the window management class is a parent class object of the object of the floating layer view controller class.
  8. 如权利要求6所述的装置,其特征在于,所述调用单元具体用于:The device according to claim 6, wherein the calling unit is specifically configured to:
    当接收到添加当前浮层视图的第一请求时,利用所述浮层视图控制器类的对象调用所添加浮层视图函数判断所述数组对象中是否存在所述当前浮层视图的ID,若不存在,则利用转换函数findViewByld(viewld)将所述当前浮层视图的ID转换为一个浮层视图对象;When the first request for adding the current floating layer view is received, the object of the floating layer view controller class is used to call the added floating layer view function to determine whether the ID of the current floating layer view exists in the array object. If not, the ID of the current floating layer view is converted into a floating layer view object by using a conversion function findViewByld (viewld);
    调用添加视图函数addview对所述浮层视图对象进行显示,并调用所述数组对象中的添加ID函数将所述当前浮层视图的ID添加至数组对象中。Calling the add view function addview to display the floating layer view object, and calling the add ID function in the array object to add the ID of the current floating layer view to the array object.
  9. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现能够执行如权利要求1至5任一所述的方法。A computer readable storage medium having stored thereon a computer program, wherein the program, when executed by a processor, implements the method of any one of claims 1 to 5.
  10. 一种用于实现视图控制器的计算机设备,其特征在于,包括:A computer device for implementing a view controller, comprising:
    至少一个处理器;以及At least one processor;
    与所述处理器通信连接的至少一个存储器,其中,At least one memory communicatively coupled to the processor, wherein
    所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行如权利要求1至5任一所述的方法。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 5.
PCT/CN2018/082184 2018-01-08 2018-04-08 Method, apparatus and computer device for implementing view controller WO2019134288A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810015266.1 2018-01-08
CN201810015266.1A CN108052325B (en) 2018-01-08 2018-01-08 A kind of method, apparatus and computer equipment for realizing view controller

Publications (1)

Publication Number Publication Date
WO2019134288A1 true WO2019134288A1 (en) 2019-07-11

Family

ID=62126841

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/082184 WO2019134288A1 (en) 2018-01-08 2018-04-08 Method, apparatus and computer device for implementing view controller

Country Status (2)

Country Link
CN (1) CN108052325B (en)
WO (1) WO2019134288A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108958876B (en) * 2018-07-23 2022-02-01 郑州云海信息技术有限公司 Display method and device of browser page

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6425016B1 (en) * 1997-05-27 2002-07-23 International Business Machines Corporation System and method for providing collaborative replicated objects for synchronous distributed groupware applications
CN103853737A (en) * 2012-11-29 2014-06-11 怡丰联合(北京)科技有限责任公司 Hypertext markup language (HTML) content visualization compiling method and system
CN107329654A (en) * 2017-06-26 2017-11-07 武汉斗鱼网络科技有限公司 Draw method, device and the computer-readable recording medium of element floating layer

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107426599B (en) * 2017-06-29 2020-02-07 武汉斗鱼网络科技有限公司 Floating layer management method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6425016B1 (en) * 1997-05-27 2002-07-23 International Business Machines Corporation System and method for providing collaborative replicated objects for synchronous distributed groupware applications
CN103853737A (en) * 2012-11-29 2014-06-11 怡丰联合(北京)科技有限责任公司 Hypertext markup language (HTML) content visualization compiling method and system
CN107329654A (en) * 2017-06-26 2017-11-07 武汉斗鱼网络科技有限公司 Draw method, device and the computer-readable recording medium of element floating layer

Also Published As

Publication number Publication date
CN108052325A (en) 2018-05-18
CN108052325B (en) 2019-09-10

Similar Documents

Publication Publication Date Title
CN107277029B (en) Remote procedure call method and device and computer equipment
RU2689203C2 (en) Flexible circuit for adjusting language model
CN105278937B (en) A kind of method and device showing pop-up box message
CN104639672B (en) The method and apparatus for carrying out domain name mapping
CN106331213B (en) A kind of domain name system DNS processing method and processing device
CN104142868B (en) Establish the method and device of connection
US20150065095A1 (en) Method for transmitting notification information and electronic device thereof
CN110869907B (en) Method and terminal for browsing application page
CN107204964B (en) Authority management method, device and system
CN106371964B (en) Method and device for prompting message
CN106502906A (en) A kind of method and apparatus of test application program
CN105491135B (en) Establish the method and device of data connection
CN108881930B (en) Method and system for presenting gift and electronic equipment
CN103716331A (en) Method, terminal, server and system for numerical value transfer
CN103631625B (en) A kind of method of data acquisition, user terminal, server and system
WO2017219293A1 (en) Method and device for acquiring web content
WO2019001073A1 (en) Remote process calling method and apparatus, and computer device
CN103763112A (en) User identity protection method and apparatus
CN103491421B (en) Content displaying method, device and intelligent television
CN103179026A (en) Communication method and system in user interactive system, server and client
CN103607431A (en) Mobile terminal resource processing method, apparatus and equipment thereof
CN106919458B (en) Method and device for Hook target kernel function
CN104135504A (en) An application-based service providing method, device and system
WO2019134288A1 (en) Method, apparatus and computer device for implementing view controller
KR101876394B1 (en) Method and device for playing media data on a terminal

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: 18898863

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: 18898863

Country of ref document: EP

Kind code of ref document: A1