WO2019019683A1 - Method for automatically registering bullet screen event in android, storage medium, device and system - Google Patents

Method for automatically registering bullet screen event in android, storage medium, device and system Download PDF

Info

Publication number
WO2019019683A1
WO2019019683A1 PCT/CN2018/081311 CN2018081311W WO2019019683A1 WO 2019019683 A1 WO2019019683 A1 WO 2019019683A1 CN 2018081311 W CN2018081311 W CN 2018081311W WO 2019019683 A1 WO2019019683 A1 WO 2019019683A1
Authority
WO
WIPO (PCT)
Prior art keywords
mark
barrage
event
registration
parser
Prior art date
Application number
PCT/CN2018/081311
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 WO2019019683A1 publication Critical patent/WO2019019683A1/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/37Compiler construction; Parser generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing

Definitions

  • the invention relates to the technical field of Android (Android) development, in particular to a method, a storage medium, a device and a system for automatically registering an Android bullet event.
  • Android Android
  • the barrage technology has also been widely used in the field of live broadcasting.
  • an Android software system applied to the field of live broadcasting, there will be a lot of places where barrage message reception processing is required.
  • the traditional implementation method is that all the places that need to receive the barrage message need to be manually registered by the developer to receive the message.
  • the similarity of the code in the registration process is very high, the use of the same code segment in the code will result in redundant code structure, unfavorable maintenance, and low development efficiency.
  • the object of the present invention is to overcome the deficiencies of the above background art, and to provide a method, a storage medium, a device and a system for automatically registering an Android bullet event, which can improve a code segment that needs to be manually registered by a developer in the prior art.
  • the automatic generation of the registration method not only makes the program structure simple and conducive to maintenance, but also greatly improves the development efficiency.
  • the technical solution adopted by the present invention is to provide a method for automatically registering an Android bullet-in event, the method comprising the following steps:
  • a custom registration mark Mark is created based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered;
  • step S1 based on the existing annotation function of the Android system, the specific process of creating a customized registration mark Mark is: using the @Target annotation provided by the Android system, the registration mark Mark is defined as being The markup of the method; using the @Retention annotation provided by the Android system, the registration mark Mark is defined to exist only in the class file and does not exist during execution; the name of the registration mark Mark is defined, and a parameter for passing the parsing parameter is defined. The parsing parameters.
  • step S3 the specific process of obtaining the barrage event marked by the registered mark Mark in the compiling stage by using the created tag parser is: using the created tag in the compile phase.
  • the parser obtains a set of methods for all the barrage events marked by the registered mark by calling the existing tag element obtaining method; and sequentially extracts each element in the current set by the for loop; After an element in the middle, the existing type get function is called to obtain the type corresponding to the element, and it is determined whether the type corresponding to the element is a method type. If yes, the function is obtained by calling an existing method to obtain the corresponding element.
  • the present invention also provides a storage medium having stored thereon a computer program, the computer program being executed by the processor to implement the steps of the method for automatically registering the Android bullet-shadow event.
  • the present invention also provides an apparatus for automatically registering an Android bullet-in event, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, the processor implementing the computer program to implement the above The steps of the method of automatically registering the Android screen event.
  • the invention also provides a system for automatically registering an Android bullet-in event, the system comprising a registration mark creation module, a markup parser creation module, and an automatic registration implementation module;
  • the registration mark Mark creation module is configured to: create a customized registration mark Mark based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered;
  • the tag parser creation module is configured to: create a tag parser, and the tag parser is configured to find and save all the barrage events marked by the markup Mark;
  • the automatic registration implementation module is configured to: when the method of registering the barrage event is marked with the mark mark, use the created tag parser to parse in the compiling stage, and obtain the method of the barrage event marked by the registered mark Mark. ; Register the methods for all barrage events that are obtained.
  • the specific process of the registration mark creation module to create a custom registration mark Mark is: using the @Target annotation provided by the Android system, the registration mark Mark is defined as a mark of the method; using Android
  • the @Retention annotation provided by the system defines the registration mark Mark as being present only in the class file and not during execution; defining the name of the registration mark Mark and defining a parsing parameter for passing the parsing parameter information.
  • the specific process of the markup parser creation module to create a markup parser is to create a markup parser, such that the markup parser inherits from an existing abstract parser of the operating system;
  • the abstract parsing method in the parser causes the created tag parser to find and save all the methods of the barrage event marked by the registered mark.
  • the automatic registration implementation module uses the created tag parser to parse in the compiling stage, and the specific process of obtaining the barrage event marked by the registered mark Mark is:
  • the existing markup parser by using the created markup parser, by calling the existing markup element acquisition method, a set of methods of the barrage events marked by the registered mark Mark is obtained; and each of the current set is sequentially taken by the for loop.
  • the existing type get function is called to obtain the type corresponding to the element, and it is determined whether the type corresponding to the element is a method type, and if so, by calling the existing method
  • the obtaining function obtains the method of the barrage event corresponding to the element, and marks the method of the barrage event as the method to be registered; if not, does not do any processing; and marks all the methods of the barrage event marked as the method to be registered Save to a preset collection of methods to be registered.
  • the specific process of the automatic registration implementation module for registering all the methods of the barrage event obtained is: sequentially acquiring each barrage event in the set of methods to be registered by using a for loop Method; each time a method of a barrage event in the collection is fetched, the method of the barrage event is registered by calling an existing registration function.
  • the method of registering the barrage event is marked by the custom registration mark Mark; then the created mark is utilized in the compile phase.
  • the parser parses the registration mark Mark to obtain all the methods of the barrage event marked by the registered mark Mark; finally, the method of all the barrage events obtained is automatically registered, thereby realizing the purpose of automatic registration.
  • the present invention improves the automatic generation of the registration of the barrage event, which not only does not need to use the same code segment in the code, but also simplifies the program structure. Conducive to maintenance, and greatly improved development efficiency.
  • each type in the set is first type-determined, and only after the method type requirement is met, the corresponding bomb is obtained.
  • FIG. 1 is a flowchart of a method for automatically registering an Android bullet-in event in an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of an apparatus for automatically registering an Android bullet-in event in an embodiment of the present invention
  • FIG. 3 is a structural block diagram of a system for automatically registering an Android bullet scene event in an embodiment of the present invention.
  • an embodiment of the present invention provides a method for automatically registering an Android bullet-in event, the method comprising the following steps:
  • Step S1 Creation of the registration mark Mark: Based on the existing Annotation function of the Android system, a custom registration mark Mark is created; the registration mark Mark is used to mark the method of the barrage event that needs to be automatically registered.
  • Android provides a set of pre-compiled functions - Annotation (the annotation) function, its main function is to perform some functions in the compilation phase, and do some preliminary work on the compiled code.
  • the present invention utilizes the characteristics of the annotation function to design a custom registration mark Mark, which can mark the method of the barrage event that needs to be automatically registered, so that we compile the application. You can do some things with the method of registering the mark Mark (such as auto-complete registration). That is to say, the registration mark Mark we designed will be embedded in the program later, parsed by the compiler during the compilation phase, and then parsed and processed the marked method of the bullet event.
  • the native annotations provided by Android have the following types:
  • @Target - indicates the scope of the program element that can be annotated for annotations of this type, such as the type of the program element that can indicate the annotation is the method METHOD;
  • @Documented - indicates that elements with this annotation can be documented by tools such as javadoc;
  • the registration mark Mark is defined as a markup for the method METHOD; using the @Retention annotation provided by the Android system, the registration mark Mark is defined to exist only in the class file and not in the Exists during execution; defines the name of the registration mark Mark, and defines a parsing parameter for passing parsing parameter information, the default value of which can be set to null.
  • the implementation code of the created registration mark Mark can be as follows:
  • the name of the registration mark Mark is Register; @Target(ElementType.METHOD) indicates that the registration mark Mark is a mark on the method; @Retention(RetentionPolicy.CLASS) indicates that the registration mark Mark exists only in the class file. Will exist during execution; Object params() default null indicates that the registration mark Mark has a parsing parameter for passing parameter information to the parser, and the default value of the parsing parameter is null.
  • Step S2 Creation of the markup parser: Create a markup parser for finding and saving all the barrage events marked by the registered mark Mark.
  • step S2 specifically includes the following process:
  • Step S201 Create a markup parser (such as MyProcessor), so that the markup parser inherits from the abstract parser AbstractProcessor existing in the operating system.
  • a markup parser such as MyProcessor
  • Step S202 By rewriting the abstract parsing method process in the abstract parser AbstractProcessor, the created token parser is used to find and save all the salvage events marked by the registered mark Mark. Understandably, since the abstract parser AbstractProcessor is a system-provided abstract parser, we need to override the abstract methods in the abstract parser AbstractProcessor, and the most important abstract method is the abstract parsing process. Therefore, we need to override the process method to enable the created tag parser to be used to find and save all the barrage events marked by the mark Mark when parsing.
  • Step S3. After the registration mark Mark is applied to the method for registering the barrage event, the method is performed by using the created tag parser in the compiling stage to obtain all the barrage events marked by the registered mark Mark; Register the operation of all the methods of the barrage event to achieve the purpose of automatic registration.
  • the specific process of the method for parsing the barrage events marked by the registered mark Mark in the compile stage by using the created tag parser is as follows:
  • Each element in the current set is sequentially retrieved by a for loop (the element here corresponds to the above-mentioned method of the marked barrage event); each time an element in the set is fetched, the existing call is made
  • the type get function getKind obtains the type corresponding to the element, and determines whether the type corresponding to the element is a method type, and if so, obtains a method of the barrage event corresponding to the element by calling the existing method getMethod, and Mark the method of the barrage event as the method to be registered (such as regFunction); if not, do nothing.
  • each element in the set is first type-determined, and only after the method type requirement is met. , will get the corresponding method of the barrage event, and mark the method of the barrage event as the method to be registered and save. This not only ensures the validity of the obtained barrage event method marked by Mark, but also improves the accuracy; and avoids the subsequent registration of the invalid (or wrong) barrage event method, which improves the implementation efficiency.
  • the specific process for registering all methods of obtaining a barrage event is as follows:
  • the method of retrieving each of the barrage events in the set of methods to be registered (such as listRegFunction) by means of a for loop; each time a method of a barrage event in the set is fetched, the existing registration function register is called by the register.
  • the method of the curtain event performs the registration operation, thereby achieving the purpose of automatic registration.
  • the method of registering the barrage event is marked by the custom registration mark Mark; then, at the compile stage, the registered markup is performed by using the created markup parser. Parsing, get all the methods of the barrage event marked by the mark Mark; finally, it will automatically register all the methods of the barrage event obtained, thus achieving the purpose of automatic registration.
  • the invention can improve the code segment that needs to be manually registered by the developer in the prior art to be automatically generated to register, which not only makes the program structure simple and conducive to maintenance, but also greatly improves the development efficiency.
  • the embodiment of the present invention further provides a storage medium, where the computer program is stored, and the computer program is executed by the processor to implement the Android shot in the foregoing embodiments.
  • the steps of the method of automatic registration of the event includes a USB flash drive, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk, or an optical disk, and the like.
  • the medium of the program code includes a USB flash drive, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk, or an optical disk, and the like.
  • the embodiment of the present invention further provides an apparatus for automatically registering an Android bullet event, including a memory, a processor, and being stored in the memory.
  • an apparatus for automatically registering an Android bullet event including a memory, a processor, and being stored in the memory.
  • an embodiment of the present invention further provides a system for automatically registering an Android bullet-in event, the system comprising a registration mark creation module, a markup parser creation module, and an automatic registration implementation module.
  • the registration mark Mark creation module is configured to: create a customized registration mark Mark based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered.
  • the implementation process is: using the @Target annotation provided by the Android system, the registration mark Mark is defined as a markup of the method; using the @Retention annotation provided by the Android system, the registration mark Mark is defined as only in the class file. Exists but does not exist during execution; defines the name of the registration mark Mark and defines a parsing parameter for passing parsing parameter information.
  • the tag parser creation module is used to: create a tag parser that is used to find and save all the barrage events marked by the tag Mark.
  • the implementation process is: creating a tag parser, so that the tag parser inherits from the existing abstract parser of the operating system; by rewriting the abstract parsing method in the abstract parser, the created tag parser is used for Find all methods of the barrage event marked with the mark Mark and save it.
  • the automatic registration implementation module is used to: when the method of registering the barrage event is marked with the mark Mark, the parsing of the created markup is used in the compiling stage to obtain the method of the barrage event marked by the registered mark Mark; Get all the methods of the barrage event to register.
  • the automatic registration implementation module uses the created tag parser to parse in the compiling stage, and the specific process of obtaining the barrage event marked by the registered mark Mark is: using the created tag parser in the compiling stage, By calling an existing tag element acquisition method, a set of methods for all the barrage events marked by the markup mark is obtained; each element in the current set is sequentially fetched by a for loop; each time one of the sets is fetched After the element, the existing type get function is called to obtain the type corresponding to the element, and it is determined whether the type corresponding to the element is a method type, and if so, the corresponding method is obtained by calling an existing method to obtain a corresponding barrage of the element. The method of the event, and mark the method of the barrage event as the method to be registered; if not, do nothing; finally, save all the methods marked as the barrage event of the method to be registered to a preset to be registered Method collection.
  • the specific process of the automatic registration implementation module performing a registration operation on all the methods of the barrage event obtained is: sequentially acquiring each barrage event in the method set to be registered by a for loop; After the method of extracting a barrage event in the collection is taken, the method of the barrage event is registered by calling an existing registration function.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

Disclosed in the present invention are a method for automatically registering a bullet screen event in Android, a storage medium, a device and a system, relating to the field of Android development technology. The method comprises: firstly creating a self-defined registration mark on the basis of the existing annotation functions of an Android system; then creating a mark parser, the mark parser being used for searching for all bullet screen event methods which are marked by the registration mark; finally, after the bullet screen event methods which are required to be registered, are marked by the registration mark, parsing same by using the created mark parser in a compilation stage to obtain all the bullet screen event methods marked by the registration mark; and performing a registration operation on all the obtained bullet screen event methods. The present invention can improve the registration of a code segment, which requires manual operations of a developer in the prior art, by means of an automatic generation mode, not only simplifying the program structure for maintenance convenience, but also greatly improving development efficiency.

Description

安卓中弹幕事件自动注册的方法、存储介质、设备及系统Method, storage medium, device and system for automatic registration of Android bombardment event 技术领域Technical field
本发明涉及Android(安卓)开发技术领域,具体来讲是一种安卓中弹幕事件自动注册的方法、存储介质、设备及系统。The invention relates to the technical field of Android (Android) development, in particular to a method, a storage medium, a device and a system for automatically registering an Android bullet event.
背景技术Background technique
在Android系统中常常有监听各种各样的事件的要求,比如最常见的按钮事件或者弹幕消息接收事件等。如果开发者想要在弹幕消息到达系统的时候能够知道弹幕信息,那么就需要在系统初始化阶段将相应内容初始化好,然后将监听器注册到事件总线中,这样当事件总线得到弹幕消息的时候才会将消息分发给注册者。In the Android system, there are often requirements for monitoring various events, such as the most common button events or barrage message reception events. If the developer wants to know the barrage information when the barrage message arrives at the system, then the corresponding content needs to be initialized during the system initialization phase, and then the listener is registered to the event bus, so that when the event bus gets the barrage message The message will be distributed to the registrant.
随着弹幕技术的不断发展,弹幕技术在直播领域也得到了广泛使用。然而,在一个应用于直播领域的Android软件系统中,会有非常多的地方需要进行弹幕消息接收处理。传统的实现方法是:在所有需要进行弹幕消息接收的地方全部都需要开发人员进行手动注册的方式来进行消息接收。但由于注册过程的代码的相似度非常高,这样在代码中大量使用相同代码段会导致代码程序结构冗余、后期不利于维护,而且开发效率也低。With the continuous development of the barrage technology, the barrage technology has also been widely used in the field of live broadcasting. However, in an Android software system applied to the field of live broadcasting, there will be a lot of places where barrage message reception processing is required. The traditional implementation method is that all the places that need to receive the barrage message need to be manually registered by the developer to receive the message. However, because the similarity of the code in the registration process is very high, the use of the same code segment in the code will result in redundant code structure, unfavorable maintenance, and low development efficiency.
发明内容Summary of the invention
本发明的目的是为了克服上述背景技术的不足,提供一种安卓中弹幕事件自动注册的方法、存储介质、设备及系统,能将现有技术中需要开发人员手工进行注册的代码段改进为自动生成的方式来进行注册,不但使得程序结构精简利于维护,而且极大地提高了开发效率。The object of the present invention is to overcome the deficiencies of the above background art, and to provide a method, a storage medium, a device and a system for automatically registering an Android bullet event, which can improve a code segment that needs to be manually registered by a developer in the prior art. The automatic generation of the registration method not only makes the program structure simple and conducive to maintenance, but also greatly improves the development efficiency.
为达到以上目的,本发明采取的技术方案是:提供一种安卓中弹幕事件自动注册的方法,该方法包括以下步骤:To achieve the above objective, the technical solution adopted by the present invention is to provide a method for automatically registering an Android bullet-in event, the method comprising the following steps:
S1、注册标记Mark的创建:基于安卓系统已有的注解功能,创建自定义的注册标记Mark;所述注册标记Mark用于标记需要被自动注册的弹幕事件的方法;S1. Creation of a registration mark Mark: a custom registration mark Mark is created based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered;
S2、标记解析器的创建:创建标记解析器,所述标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存;S2. Creation of a markup parser: creating a markup parser for finding and saving all the barrage events marked by the registered mark Mark;
S3、自动注册的实现:为需要注册的弹幕事件的方法打上注册标记Mark后,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;对得到的所有弹幕事件的方法进行注册操作。S3. Implementation of automatic registration: After the registration mark Mark is applied to the method of registering the barrage event, the created markup parser is used in the compiling stage to obtain the method of the barrage event marked by the registered mark Mark; Get all the methods of the barrage event to register.
在上述技术方案的基础上,步骤S1中,基于安卓系统已有的注解功能,创建自定义的注册标记Mark的具体流程为:利用安卓系统提供的@Target注解,将注册标记Mark定义为是对方法的标记;利用安卓系统提供的@Retention注解,将注册标记Mark定义为仅在class文件中存在而不会在执行期间存在;定义注册标记Mark的名称,并定义一个用于传递解析用参数信息的解析参数。Based on the above technical solution, in step S1, based on the existing annotation function of the Android system, the specific process of creating a customized registration mark Mark is: using the @Target annotation provided by the Android system, the registration mark Mark is defined as being The markup of the method; using the @Retention annotation provided by the Android system, the registration mark Mark is defined to exist only in the class file and does not exist during execution; the name of the registration mark Mark is defined, and a parameter for passing the parsing parameter is defined. The parsing parameters.
在上述技术方案的基础上,步骤S3中,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法的具体流程为:在编译阶段利用创建的标记解析器,通过调用已有的标记元素获取方法,获取到所有被注册标记Mark标记过的弹幕事件的方法的集合;通过for循环的方式依次取出当前集合中的每个元素;每次取出集合中的一个元素后,通过调用已有的类型获取函数获取到该元素对应的类型,并判断该元素对应的类型是否是方法类型,若是,则通过调用已有的方法获取函数获取到该元素对应的弹幕 事件的方法,并将该弹幕事件的方法标记为待注册方法;若否,则不做任何处理;将所有标记为待注册方法的弹幕事件的方法保存至一个预设的待注册方法集合中。Based on the above technical solution, in step S3, the specific process of obtaining the barrage event marked by the registered mark Mark in the compiling stage by using the created tag parser is: using the created tag in the compile phase. The parser obtains a set of methods for all the barrage events marked by the registered mark by calling the existing tag element obtaining method; and sequentially extracts each element in the current set by the for loop; After an element in the middle, the existing type get function is called to obtain the type corresponding to the element, and it is determined whether the type corresponding to the element is a method type. If yes, the function is obtained by calling an existing method to obtain the corresponding element. The method of the barrage event, and mark the method of the barrage event as the method to be registered; if not, do nothing; save all the methods marked as the barrage event of the method to be registered to a preset Registered in the collection of methods.
本发明还提供一种存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述安卓中弹幕事件自动注册的方法的步骤。The present invention also provides a storage medium having stored thereon a computer program, the computer program being executed by the processor to implement the steps of the method for automatically registering the Android bullet-shadow event.
本发明还提供一种安卓中弹幕事件自动注册的设备,包括存储器、处理器及存储在存储器上并在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述安卓中弹幕事件自动注册的方法的步骤。The present invention also provides an apparatus for automatically registering an Android bullet-in event, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, the processor implementing the computer program to implement the above The steps of the method of automatically registering the Android screen event.
本发明还提供一种安卓中弹幕事件自动注册的系统,该系统包括注册标记Mark创建模块、标记解析器创建模块、自动注册实现模块;The invention also provides a system for automatically registering an Android bullet-in event, the system comprising a registration mark creation module, a markup parser creation module, and an automatic registration implementation module;
所述注册标记Mark创建模块用于:基于安卓系统已有的注解功能,创建自定义的注册标记Mark;所述注册标记Mark用于标记需要被自动注册的弹幕事件的方法;The registration mark Mark creation module is configured to: create a customized registration mark Mark based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered;
所述标记解析器创建模块用于:创建标记解析器,所述标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存;The tag parser creation module is configured to: create a tag parser, and the tag parser is configured to find and save all the barrage events marked by the markup Mark;
所述自动注册实现模块用于:当需要注册的弹幕事件的方法打上注册标记Mark后,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;对得到的所有弹幕事件的方法进行注册操作。The automatic registration implementation module is configured to: when the method of registering the barrage event is marked with the mark mark, use the created tag parser to parse in the compiling stage, and obtain the method of the barrage event marked by the registered mark Mark. ; Register the methods for all barrage events that are obtained.
在上述技术方案的基础上,所述注册标记Mark创建模块创建自定义的注册标记Mark的具体流程为:利用安卓系统提供的@Target注解,将注册标记Mark定义为是对方法的标记;利用安卓系统提供的@Retention注解,将注册标记Mark定义为仅在class文件中存在 而不会在执行期间存在;定义注册标记Mark的名称,并定义一个用于传递解析用参数信息的解析参数。Based on the above technical solution, the specific process of the registration mark creation module to create a custom registration mark Mark is: using the @Target annotation provided by the Android system, the registration mark Mark is defined as a mark of the method; using Android The @Retention annotation provided by the system defines the registration mark Mark as being present only in the class file and not during execution; defining the name of the registration mark Mark and defining a parsing parameter for passing the parsing parameter information.
在上述技术方案的基础上,所述标记解析器创建模块创建标记解析器的具体流程为:创建一个标记解析器,使该标记解析器继承于操作系统已有的抽象解析器;通过重写抽象解析器中的抽象解析方法,使得创建的标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。Based on the above technical solution, the specific process of the markup parser creation module to create a markup parser is to create a markup parser, such that the markup parser inherits from an existing abstract parser of the operating system; The abstract parsing method in the parser causes the created tag parser to find and save all the methods of the barrage event marked by the registered mark.
在上述技术方案的基础上,所述自动注册实现模块在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法的具体流程为:On the basis of the above technical solution, the automatic registration implementation module uses the created tag parser to parse in the compiling stage, and the specific process of obtaining the barrage event marked by the registered mark Mark is:
在编译阶段利用创建的标记解析器,通过调用已有的标记元素获取方法,获取到所有被注册标记Mark标记过的弹幕事件的方法的集合;通过for循环的方式依次取出当前集合中的每个元素;每次取出集合中的一个元素后,通过调用已有的类型获取函数获取到该元素对应的类型,并判断该元素对应的类型是否是方法类型,若是,则通过调用已有的方法获取函数获取到该元素对应的弹幕事件的方法,并将该弹幕事件的方法标记为待注册方法;若否,则不做任何处理;将所有标记为待注册方法的弹幕事件的方法保存至一个预设的待注册方法集合中。In the compile stage, by using the created markup parser, by calling the existing markup element acquisition method, a set of methods of the barrage events marked by the registered mark Mark is obtained; and each of the current set is sequentially taken by the for loop. Each time after extracting an element in the collection, the existing type get function is called to obtain the type corresponding to the element, and it is determined whether the type corresponding to the element is a method type, and if so, by calling the existing method The obtaining function obtains the method of the barrage event corresponding to the element, and marks the method of the barrage event as the method to be registered; if not, does not do any processing; and marks all the methods of the barrage event marked as the method to be registered Save to a preset collection of methods to be registered.
在上述技术方案的基础上,所述自动注册实现模块对得到的所有弹幕事件的方法进行注册操作的具体流程为:通过for循环的方式依次取出待注册方法集合中的每个弹幕事件的方法;每次取出集合中的一个弹幕事件的方法后,通过调用已有的注册函数对该弹幕事件的方法进行注册操作。On the basis of the foregoing technical solution, the specific process of the automatic registration implementation module for registering all the methods of the barrage event obtained is: sequentially acquiring each barrage event in the set of methods to be registered by using a for loop Method; each time a method of a barrage event in the collection is fetched, the method of the barrage event is registered by calling an existing registration function.
本发明的有益效果在于:The beneficial effects of the invention are:
(1)本发明中,利用上述方法实现安卓系统中的弹幕事件注册时,会通过自定义的注册标记Mark为需要注册的弹幕事件的方法打上标记;然后在编译阶段会利用创建的标记解析器对注册标记Mark进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;最终,会自动对得到的所有弹幕事件的方法进行注册操作,从而实现自动注册的目的。(1) In the present invention, when the above-mentioned method is used to implement the registration of the barrage event in the Android system, the method of registering the barrage event is marked by the custom registration mark Mark; then the created mark is utilized in the compile phase. The parser parses the registration mark Mark to obtain all the methods of the barrage event marked by the registered mark Mark; finally, the method of all the barrage events obtained is automatically registered, thereby realizing the purpose of automatic registration.
与现有技术中需要开发人员手工进行弹幕事件注册的方式相比,本发明改进为自动生成的方式来进行弹幕事件的注册,不但无需在代码中大量使用相同代码段,使得程序结构精简利于维护,而且极大地提高了开发效率。Compared with the prior art, in which the developer needs to manually register the barrage event, the present invention improves the automatic generation of the registration of the barrage event, which not only does not need to use the same code segment in the code, but also simplifies the program structure. Conducive to maintenance, and greatly improved development efficiency.
(2)在获取到所有被注册标记Mark标记过的弹幕事件的方法集合后,会对集合中的每个元素先进行类型的判断,只有满足方法类型要求后,才会去获取对应的弹幕事件的方法,并将该弹幕事件的方法标记为待注册方法并保存。这样不但保证了获取到的被注册标记Mark标记过的弹幕事件方法的有效性,提高了准确性;而且避免了后续对无效(或错误)的弹幕事件方法进行注册操作,提高了实现效率。(2) After obtaining the method set of all the barrage events marked by the registered mark Mark, each type in the set is first type-determined, and only after the method type requirement is met, the corresponding bomb is obtained. The method of the curtain event, and mark the method of the barrage event as the method to be registered and save. This not only ensures the validity of the obtained barrage event method marked by Mark, but also improves the accuracy; and avoids the subsequent registration of the invalid (or wrong) barrage event method, which improves the implementation efficiency. .
附图说明DRAWINGS
图1为本发明实施例中的安卓中弹幕事件自动注册的方法的流程图;1 is a flowchart of a method for automatically registering an Android bullet-in event in an embodiment of the present invention;
图2为本发明实施例中的安卓中弹幕事件自动注册的设备的结构示意图;2 is a schematic structural diagram of an apparatus for automatically registering an Android bullet-in event in an embodiment of the present invention;
图3为本发明实施例中的安卓中弹幕事件自动注册的系统的结构框图。FIG. 3 is a structural block diagram of a system for automatically registering an Android bullet scene event in an embodiment of the present invention.
具体实施方式Detailed ways
下面结合附图及具体实施例对本发明作进一步的详细描述。The present invention will be further described in detail below with reference to the drawings and specific embodiments.
参见图1所示,本发明实施例提供一种安卓中弹幕事件自动注册的方法,该方法包括以下步骤:As shown in FIG. 1 , an embodiment of the present invention provides a method for automatically registering an Android bullet-in event, the method comprising the following steps:
步骤S1、注册标记Mark的创建:基于安卓系统已有的Annotation(注解)功能,创建一个自定义的注册标记Mark;所述注册标记Mark用于标记需要被自动注册的弹幕事件的方法。Step S1: Creation of the registration mark Mark: Based on the existing Annotation function of the Android system, a custom registration mark Mark is created; the registration mark Mark is used to mark the method of the barrage event that needs to be automatically registered.
可以理解的是,所谓自动化注册其实也就是让程序自己来完成注册的过程,将人工编写代码的部分通过程序的方式来自动完成。Understandably, the so-called automated registration is actually the process of letting the program complete the registration itself, and the part of the manual writing code is automatically completed by means of the program.
目前,在安卓的开发过程中,安卓系统提供了一套预编译的功能——Annotation(注解)功能,其主要功能是在编译阶段执行一些功能,对编译的代码进行一些前期工作。而本发明则是利用该注解功能的特性设计了一套自定义的注册标记Mark,该注册标记Mark能对需要被自动注册的弹幕事件的方法进行标记,从而使得我们对应用程序进行编译的时候能对打有注册标记Mark的方法进行一些操作(如自动完成注册)。也就是说我们所设计的注册标记Mark后期会嵌入到程序当中,在编译阶段被编译器进行解析,然后对标记过的弹幕事件的方法进行解析和处理操作。At present, in the Android development process, Android provides a set of pre-compiled functions - Annotation (the annotation) function, its main function is to perform some functions in the compilation phase, and do some preliminary work on the compiled code. The present invention utilizes the characteristics of the annotation function to design a custom registration mark Mark, which can mark the method of the barrage event that needs to be automatically registered, so that we compile the application. You can do some things with the method of registering the mark Mark (such as auto-complete registration). That is to say, the registration mark Mark we designed will be embedded in the program later, parsed by the compiler during the compilation phase, and then parsed and processed the marked method of the bullet event.
具体来说,安卓系统提供的原生注解有以下几种:Specifically, the native annotations provided by Android have the following types:
@Target——指明该类型的注解可以注解的程序元素的范围,如可以指明注解的程序元素的类型为方法METHOD;@Target - indicates the scope of the program element that can be annotated for annotations of this type, such as the type of the program element that can indicate the annotation is the method METHOD;
@Documented——指明拥有这个注解的元素可以被javadoc此类的工具文档化;@Documented - indicates that elements with this annotation can be documented by tools such as javadoc;
@Inherited——指明该注解类型被自动继承;@Inherited - indicates that the annotation type is automatically inherited;
@Retention——指明了该注解被保留的时间长短。@Retention - Indicates how long the annotation was retained.
在此基础上,本实施例中,基于安卓系统已有的Annotation(注解)功能,创建一个自定义的注册标记Mark的具体流程为:On this basis, in this embodiment, based on the existing Annotation function of the Android system, the specific process of creating a custom registration mark Mark is:
利用安卓系统提供的@Target注解,将注册标记Mark定义为是对方法METHOD的标记;利用安卓系统提供的@Retention注解,将注册标记Mark定义为仅在class(编译)文件中存在而不会在执行期间存在;定义注册标记Mark的名称,并定义一个用于传递解析用参数信息的解析参数,该解析参数的默认值可设置为空。Using the @Target annotation provided by Android, the registration mark Mark is defined as a markup for the method METHOD; using the @Retention annotation provided by the Android system, the registration mark Mark is defined to exist only in the class file and not in the Exists during execution; defines the name of the registration mark Mark, and defines a parsing parameter for passing parsing parameter information, the default value of which can be set to null.
对应上述创建流程,创建出的注册标记Mark的实现代码可如下:Corresponding to the above creation process, the implementation code of the created registration mark Mark can be as follows:
Figure PCTCN2018081311-appb-000001
Figure PCTCN2018081311-appb-000001
其中,注册标记Mark的名称为Register;@Target(ElementType.METHOD)表明该注册标记Mark是对方法的标记;@Retention(RetentionPolicy.CLASS)表明该注册标记Mark仅仅在class(编译)文件中存在不会在执行期间存在;Object params()default null表明该注册标记Mark具有一个用于传递参数信息到解析器使用的解析参数,且该解析参数的默认值为空。The name of the registration mark Mark is Register; @Target(ElementType.METHOD) indicates that the registration mark Mark is a mark on the method; @Retention(RetentionPolicy.CLASS) indicates that the registration mark Mark exists only in the class file. Will exist during execution; Object params() default null indicates that the registration mark Mark has a parsing parameter for passing parameter information to the parser, and the default value of the parsing parameter is null.
通过上述操作,我们就设计了一个自定义的注册标记Mark,该注册标记Mark能用于标记需要被自动注册的弹幕事件的方法,是完成后续自动注册操作的基础,为后续功能奠定了基础。Through the above operation, we have designed a custom registration mark Mark, which can be used to mark the method of the barrage event that needs to be automatically registered, which is the basis for completing the subsequent automatic registration operation, laying the foundation for the subsequent functions. .
步骤S2、标记解析器的创建:创建一个标记解析器,该标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。Step S2: Creation of the markup parser: Create a markup parser for finding and saving all the barrage events marked by the registered mark Mark.
在一种实施方式中,步骤S2具体包括以下流程:In an embodiment, step S2 specifically includes the following process:
步骤S201、创建一个标记解析器(如MyProcessor),使该标记解析器继承于操作系统已有的抽象解析器AbstractProcessor。Step S201: Create a markup parser (such as MyProcessor), so that the markup parser inherits from the abstract parser AbstractProcessor existing in the operating system.
步骤S202、通过重写抽象解析器AbstractProcessor中的抽象解析方法process,使得创建的标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。可以理解的是,由于抽象解析器AbstractProcessor是一个系统提供的抽象的解析器,所以我们需要重写抽象解析器AbstractProcessor中的抽象方法,而最关键的抽象方法是抽象解析方法process。因此,我们需要重写process方法来使得创建的标记解析器在进行解析时,能用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。Step S202: By rewriting the abstract parsing method process in the abstract parser AbstractProcessor, the created token parser is used to find and save all the salvage events marked by the registered mark Mark. Understandably, since the abstract parser AbstractProcessor is a system-provided abstract parser, we need to override the abstract methods in the abstract parser AbstractProcessor, and the most important abstract method is the abstract parsing process. Therefore, we need to override the process method to enable the created tag parser to be used to find and save all the barrage events marked by the mark Mark when parsing.
需要说明的是,上述实施方式仅是一种举例而已,开发人员在实际创建标记解析器时,也可不采用继承操作系统已有的抽象解析器的方式,而自行进行代码的自定义编写。It should be noted that the foregoing implementation manner is only an example. When the developer actually creates the marker parser, the developer may customize the code by using the abstract parser that inherits the operating system.
步骤S3、自动注册的实现:为需要注册的弹幕事件的方法打上注册标记Mark后,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;对得到的所有弹幕事件的方法进行注册操作,从而实现自动注册的目的。Step S3. Implementation of automatic registration: after the registration mark Mark is applied to the method for registering the barrage event, the method is performed by using the created tag parser in the compiling stage to obtain all the barrage events marked by the registered mark Mark; Register the operation of all the methods of the barrage event to achieve the purpose of automatic registration.
在一种实施方式中,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法的具体流程如下:In one embodiment, the specific process of the method for parsing the barrage events marked by the registered mark Mark in the compile stage by using the created tag parser is as follows:
1、在编译阶段利用创建的标记解析器,通过调用已有的标记元素获取方法getElementsAnnotatedWith(Register.class),获取到所有被注册标记Mark标记过的弹幕事件的方法的集合(如list)。1. At the compile stage, using the created markup parser, by calling the existing markup element get method getElementsAnnotatedWith(Register.class), a set of methods (such as a list) of all the barrage events marked by the registered mark Mark is obtained.
2、通过for循环的方式依次取出当前集合中的每个元素(此处的元素即对应上述的被标记过的弹幕事件的方法);每次取出集合中 的一个元素后,通过调用已有的类型获取函数getKind获取到该元素对应的类型,并判断该元素对应的类型是否是方法类型,若是,则通过调用已有的方法获取函数getMethod获取到该元素对应的弹幕事件的方法,并将该弹幕事件的方法标记为待注册方法(如regFunction);若不是,则不做任何处理。2. Each element in the current set is sequentially retrieved by a for loop (the element here corresponds to the above-mentioned method of the marked barrage event); each time an element in the set is fetched, the existing call is made The type get function getKind obtains the type corresponding to the element, and determines whether the type corresponding to the element is a method type, and if so, obtains a method of the barrage event corresponding to the element by calling the existing method getMethod, and Mark the method of the barrage event as the method to be registered (such as regFunction); if not, do nothing.
3、将所有标记为待注册方法的弹幕事件的方法保存至一个预设的待注册方法集合(如listRegFunction)中。3. Save all methods of the barrage event marked as the method to be registered to a preset set of methods to be registered (such as listRegFunction).
可以理解的是,在上述实施方式中,在获取到所有被注册标记Mark标记过的弹幕事件的方法集合后,会对集合中的每个元素先进行类型的判断,只有满足方法类型要求后,才会去获取对应的弹幕事件的方法,并将该弹幕事件的方法标记为待注册方法并保存。这样不但保证了获取到的被注册标记Mark标记过的弹幕事件方法的有效性,提高了准确性;而且避免了后续对无效(或错误)弹幕事件方法的注册,提高了实现效率。It can be understood that, in the foregoing embodiment, after all the method sets of the barrage events marked by the registered mark Mark are obtained, each element in the set is first type-determined, and only after the method type requirement is met. , will get the corresponding method of the barrage event, and mark the method of the barrage event as the method to be registered and save. This not only ensures the validity of the obtained barrage event method marked by Mark, but also improves the accuracy; and avoids the subsequent registration of the invalid (or wrong) barrage event method, which improves the implementation efficiency.
在一种实施方式中,对得到的所有弹幕事件的方法进行注册操作的具体流程如下:In one embodiment, the specific process for registering all methods of obtaining a barrage event is as follows:
通过for循环的方式依次取出待注册方法集合(如listRegFunction)中的每个弹幕事件的方法;每次取出集合中的一个弹幕事件的方法后,通过调用已有的注册函数register对该弹幕事件的方法进行注册操作,从而实现自动注册的目的。The method of retrieving each of the barrage events in the set of methods to be registered (such as listRegFunction) by means of a for loop; each time a method of a barrage event in the set is fetched, the existing registration function register is called by the register. The method of the curtain event performs the registration operation, thereby achieving the purpose of automatic registration.
利用上述方法实现安卓系统中的弹幕事件注册时,会通过自定义的注册标记Mark为需要注册的弹幕事件的方法打上标记;然后在编译阶段会利用创建的标记解析器对注册标记Mark进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;最终,会自动对得到的所有弹幕事件的方法进行注册操作,从而实现自动注册的目的。本 发明能将现有技术中需要开发人员手工进行注册的代码段改进为自动生成的方式来进行注册,不但使得程序结构精简利于维护,而且极大地提高了开发效率。When the above method is used to realize the registration of the barrage event in the Android system, the method of registering the barrage event is marked by the custom registration mark Mark; then, at the compile stage, the registered markup is performed by using the created markup parser. Parsing, get all the methods of the barrage event marked by the mark Mark; finally, it will automatically register all the methods of the barrage event obtained, thus achieving the purpose of automatic registration. The invention can improve the code segment that needs to be manually registered by the developer in the prior art to be automatically generated to register, which not only makes the program structure simple and conducive to maintenance, but also greatly improves the development efficiency.
对应上述的安卓中弹幕事件自动注册的方法,本发明实施例还提供一种存储介质,其上存储有计算机程序,该计算机程序被处理器执行时可实现上述各实施例中的安卓中弹幕事件自动注册的方法的步骤。需要说明的是,所述存储介质包括U盘、移动硬盘、ROM(Re ad-Only Memory,只读存储器)、RAM(Random Access Memory,随机存取存储器)、磁碟或者光盘等各种可以存储程序代码的介质。The embodiment of the present invention further provides a storage medium, where the computer program is stored, and the computer program is executed by the processor to implement the Android shot in the foregoing embodiments. The steps of the method of automatic registration of the event. It should be noted that the storage medium includes a USB flash drive, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a magnetic disk, or an optical disk, and the like. The medium of the program code.
另外,参见图2所示,对应上述的安卓中弹幕事件自动注册的方法,本发明实施例还提供一种安卓中弹幕事件自动注册的设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,该处理器执行计算机程序时可实现上述各实施例中的安卓中弹幕事件自动注册的方法的步骤。In addition, as shown in FIG. 2, in accordance with the foregoing method for automatically registering an Android bullet event, the embodiment of the present invention further provides an apparatus for automatically registering an Android bullet event, including a memory, a processor, and being stored in the memory. A computer program executable on a processor, the processor executing the computer program to implement the steps of the method for automatically registering an Android bullet event in the various embodiments described above.
参见图3所示,本发明实施例还提供一种安卓中弹幕事件自动注册的系统,该系统包括注册标记Mark创建模块、标记解析器创建模块、自动注册实现模块。Referring to FIG. 3, an embodiment of the present invention further provides a system for automatically registering an Android bullet-in event, the system comprising a registration mark creation module, a markup parser creation module, and an automatic registration implementation module.
其中,注册标记Mark创建模块用于:基于安卓系统已有的注解功能,创建自定义的注册标记Mark;所述注册标记Mark用于标记需要被自动注册的弹幕事件的方法。具体来说,其实现流程为:利用安卓系统提供的@Target注解,将注册标记Mark定义为是对方法的标记;利用安卓系统提供的@Retention注解,将注册标记Mark定义为仅在class文件中存在而不会在执行期间存在;定义注册标记Mark的名称,并定义一个用于传递解析用参数信息的解析参数。The registration mark Mark creation module is configured to: create a customized registration mark Mark based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered. Specifically, the implementation process is: using the @Target annotation provided by the Android system, the registration mark Mark is defined as a markup of the method; using the @Retention annotation provided by the Android system, the registration mark Mark is defined as only in the class file. Exists but does not exist during execution; defines the name of the registration mark Mark and defines a parsing parameter for passing parsing parameter information.
标记解析器创建模块用于:创建标记解析器,所述标记解析器用 于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。具体来说,其实现流程为:创建一个标记解析器,使该标记解析器继承于操作系统已有的抽象解析器;通过重写抽象解析器中的抽象解析方法,使得创建的标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。The tag parser creation module is used to: create a tag parser that is used to find and save all the barrage events marked by the tag Mark. Specifically, the implementation process is: creating a tag parser, so that the tag parser inherits from the existing abstract parser of the operating system; by rewriting the abstract parsing method in the abstract parser, the created tag parser is used for Find all methods of the barrage event marked with the mark Mark and save it.
自动注册实现模块用于:当需要注册的弹幕事件的方法打上注册标记Mark后,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;对得到的所有弹幕事件的方法进行注册操作。The automatic registration implementation module is used to: when the method of registering the barrage event is marked with the mark Mark, the parsing of the created markup is used in the compiling stage to obtain the method of the barrage event marked by the registered mark Mark; Get all the methods of the barrage event to register.
进一步地,所述自动注册实现模块在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法的具体流程为:在编译阶段利用创建的标记解析器,通过调用已有的标记元素获取方法,获取到所有被注册标记Mark标记过的弹幕事件的方法的集合;通过for循环的方式依次取出当前集合中的每个元素;每次取出集合中的一个元素后,通过调用已有的类型获取函数获取到该元素对应的类型,并判断该元素对应的类型是否是方法类型,若是,则通过调用已有的方法获取函数获取到该元素对应的弹幕事件的方法,并将该弹幕事件的方法标记为待注册方法;若否,则不做任何处理;最后,将所有标记为待注册方法的弹幕事件的方法保存至一个预设的待注册方法集合中。Further, the automatic registration implementation module uses the created tag parser to parse in the compiling stage, and the specific process of obtaining the barrage event marked by the registered mark Mark is: using the created tag parser in the compiling stage, By calling an existing tag element acquisition method, a set of methods for all the barrage events marked by the markup mark is obtained; each element in the current set is sequentially fetched by a for loop; each time one of the sets is fetched After the element, the existing type get function is called to obtain the type corresponding to the element, and it is determined whether the type corresponding to the element is a method type, and if so, the corresponding method is obtained by calling an existing method to obtain a corresponding barrage of the element. The method of the event, and mark the method of the barrage event as the method to be registered; if not, do nothing; finally, save all the methods marked as the barrage event of the method to be registered to a preset to be registered Method collection.
更进一步地,所述自动注册实现模块对得到的所有弹幕事件的方法进行注册操作的具体流程为:通过for循环的方式依次取出待注册方法集合中的每个弹幕事件的方法;每次取出集合中的一个弹幕事件的方法后,通过调用已有的注册函数对该弹幕事件的方法进行注册操作。Further, the specific process of the automatic registration implementation module performing a registration operation on all the methods of the barrage event obtained is: sequentially acquiring each barrage event in the method set to be registered by a for loop; After the method of extracting a barrage event in the collection is taken, the method of the barrage event is registered by calling an existing registration function.
需要说明的是:上述实施例提供的系统在实现安卓系统中的弹幕事件自动注册时,仅以上述各功能模块的划分进行举例说明,实际应用中,可根据需要而将上述功能分配由不同的功能模块完成,即将系统的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。It should be noted that, when the system provided by the foregoing embodiment implements the automatic registration of the barrage event in the Android system, only the division of the above functional modules is illustrated. In actual applications, the functions may be allocated differently according to requirements. The function module is completed, that is, the internal structure of the system is divided into different functional modules to complete all or part of the functions described above.
本发明不局限于上述实施方式,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也视为本发明的保护范围之内。The present invention is not limited to the above embodiments, and those skilled in the art can also make several improvements and retouchings without departing from the principles of the present invention. These improvements and retouchings are also considered as protection of the present invention. Within the scope.
本说明书中未作详细描述的内容属于本领域专业技术人员公知的现有技术。The contents not described in detail in the present specification belong to the prior art well known to those skilled in the art.

Claims (10)

  1. 一种安卓中弹幕事件自动注册的方法,其特征在于,该方法包括以下步骤:A method for automatically registering an Android bullet scene event, characterized in that the method comprises the following steps:
    S1、注册标记Mark的创建:基于安卓系统已有的注解功能,创建自定义的注册标记Mark;所述注册标记Mark用于标记需要被自动注册的弹幕事件的方法;S1. Creation of a registration mark Mark: a custom registration mark Mark is created based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered;
    S2、标记解析器的创建:创建标记解析器,所述标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存;S2. Creation of a markup parser: creating a markup parser for finding and saving all the barrage events marked by the registered mark Mark;
    S3、自动注册的实现:为需要注册的弹幕事件的方法打上注册标记Mark后,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;对得到的所有弹幕事件的方法进行注册操作。S3. Implementation of automatic registration: After the registration mark Mark is applied to the method of registering the barrage event, the created markup parser is used in the compiling stage to obtain the method of the barrage event marked by the registered mark Mark; Get all the methods of the barrage event to register.
  2. 如权利要求1所述的安卓中弹幕事件自动注册的方法,其特征在于:步骤S1中,基于安卓系统已有的注解功能,创建自定义的注册标记Mark的具体流程为:The method for automatically registering an Android bullet-in event according to claim 1, wherein in step S1, the specific process of creating a customized registration mark Mark based on an existing annotation function of the Android system is:
    利用安卓系统提供的@Target注解,将注册标记Mark定义为是对方法的标记;利用安卓系统提供的@Retention注解,将注册标记Mark定义为仅在class文件中存在而不会在执行期间存在;定义注册标记Mark的名称,并定义一个用于传递解析用参数信息的解析参数。Using the @Target annotation provided by Android, the registration mark Mark is defined as a markup of the method; using the @Retention annotation provided by the Android system, the registration mark Mark is defined to exist only in the class file and does not exist during execution; Define the name of the registration mark Mark and define a parsing parameter for passing the parsing parameter information.
  3. 如权利要求1所述的安卓中弹幕事件自动注册的方法,其特征在于:步骤S3中,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法的具体流程为:The method for automatically registering an Android bullet-shadow event according to claim 1, wherein in step S3, the created marker parser is used in the compiling stage to obtain a bullet-off event marked by the registered mark Mark. The specific process of the method is:
    在编译阶段利用创建的标记解析器,通过调用已有的标记元素获取方法,获取到所有被注册标记Mark标记过的弹幕事件的方法的集合;At the compile stage, by using the created markup parser, by calling the existing markup element acquisition method, a set of methods for all the barrage events marked by the registered mark Mark is obtained;
    通过for循环的方式依次取出当前集合中的每个元素;每次取出集合中的一个元素后,通过调用已有的类型获取函数获取到该元素对应的类型,并判断该元素对应的类型是否是方法类型,若是,则通过调用已有的方法获取函数获取到该元素对应的弹幕事件的方法,并将该弹幕事件的方法标记为待注册方法;若否,则不做任何处理;Each element in the current set is sequentially fetched by a for loop; each time an element in the set is fetched, the type corresponding to the element is obtained by calling an existing type fetch function, and it is determined whether the corresponding type of the element is The method type, if yes, obtains the method of acquiring the corresponding barrage event of the element by calling the existing method, and marks the method of the barrage event as the method to be registered; if not, no processing is performed;
    将所有标记为待注册方法的弹幕事件的方法保存至一个预设的待注册方法集合中。Saves all methods marked as barrage events for the method to be registered to a preset set of methods to be registered.
  4. 一种存储介质,其上存储有计算机程序,其特征在于:所述计算机程序被处理器执行时实现上述权利要求1至3中任一项所述方法的步骤。A storage medium having stored thereon a computer program, characterized in that the computer program is executed by a processor to carry out the steps of the method of any one of claims 1 to 3.
  5. 一种安卓中弹幕事件自动注册的设备,包括存储器、处理器及存储在所述存储器上并在所述处理器上运行的计算机程序,其特征在于:所述处理器执行所述计算机程序时实现上述权利要求1至3中任一项所述方法的步骤。An apparatus for automatically registering an Android bullet event, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, wherein the processor executes the computer program The steps of the method of any of the preceding claims 1 to 3.
  6. 一种安卓中弹幕事件自动注册的系统,其特征在于:该系统包括注册标记Mark创建模块、标记解析器创建模块、自动注册实现模块;A system for automatically registering an Android bullet scene event, the system comprising: a registration mark creation module, a markup parser creation module, and an automatic registration implementation module;
    所述注册标记Mark创建模块用于:基于安卓系统已有的注解功能,创建自定义的注册标记Mark;所述注册标记Mark用于标记需要被自动注册的弹幕事件的方法;The registration mark Mark creation module is configured to: create a customized registration mark Mark based on an existing annotation function of the Android system; the registration mark Mark is used to mark a method of a barrage event that needs to be automatically registered;
    所述标记解析器创建模块用于:创建标记解析器,所述标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存;The tag parser creation module is configured to: create a tag parser, and the tag parser is configured to find and save all the barrage events marked by the markup Mark;
    所述自动注册实现模块用于:当需要注册的弹幕事件的方法打上注册标记Mark后,在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法;对得到的所有弹 幕事件的方法进行注册操作。The automatic registration implementation module is configured to: when the method of registering the barrage event is marked with the mark mark, use the created tag parser to parse in the compiling stage, and obtain the method of the barrage event marked by the registered mark Mark. ; Register the methods for all barrage events that are obtained.
  7. 如权利要求6所述的安卓中弹幕事件自动注册的系统,其特征在于:所述注册标记Mark创建模块创建自定义的注册标记Mark的具体流程为:The system for automatically registering an Android bullet scene event according to claim 6, wherein the specific process of the registration mark creation module to create a customized registration mark Mark is:
    利用安卓系统提供的@Target注解,将注册标记Mark定义为是对方法的标记;利用安卓系统提供的@Retention注解,将注册标记Mark定义为仅在class文件中存在而不会在执行期间存在;定义注册标记Mark的名称,并定义一个用于传递解析用参数信息的解析参数。Using the @Target annotation provided by Android, the registration mark Mark is defined as a markup of the method; using the @Retention annotation provided by the Android system, the registration mark Mark is defined to exist only in the class file and does not exist during execution; Define the name of the registration mark Mark and define a parsing parameter for passing the parsing parameter information.
  8. 如权利要求6所述的安卓中弹幕事件自动注册的系统,其特征在于:所述标记解析器创建模块创建标记解析器的具体流程为:The system for automatically registering an Android bullet scene event according to claim 6, wherein the specific process of the marker parser creation module to create a marker parser is:
    创建一个标记解析器,使该标记解析器继承于操作系统已有的抽象解析器;Create a tag parser that inherits from the abstract parser already in the operating system;
    通过重写抽象解析器中的抽象解析方法,使得创建的标记解析器用于查找所有被注册标记Mark标记过的弹幕事件的方法并保存。By overriding the abstract parsing method in the abstract parser, the created token parser is used to find and save all the trapping events marked by the mark Mark.
  9. 如权利要求6所述的安卓中弹幕事件自动注册的系统,其特征在于,所述自动注册实现模块在编译阶段利用创建的标记解析器进行解析,得到所有被注册标记Mark标记过的弹幕事件的方法的具体流程为:The system for automatically registering an Android bullet-in event according to claim 6, wherein the automatic registration implementation module parses the created tag parser during the compiling phase to obtain a barrage marked by the registered mark Mark. The specific process of the method of the event is:
    在编译阶段利用创建的标记解析器,通过调用已有的标记元素获取方法,获取到所有被注册标记Mark标记过的弹幕事件的方法的集合;At the compile stage, by using the created markup parser, by calling the existing markup element acquisition method, a set of methods for all the barrage events marked by the registered mark Mark is obtained;
    通过for循环的方式依次取出当前集合中的每个元素;每次取出集合中的一个元素后,通过调用已有的类型获取函数获取到该元素对应的类型,并判断该元素对应的类型是否是方法类型,若是,则通过调用已有的方法获取函数获取到该元素对应的弹幕事件的方法,并将 该弹幕事件的方法标记为待注册方法;若否,则不做任何处理;Each element in the current set is sequentially fetched by a for loop; each time an element in the set is fetched, the type corresponding to the element is obtained by calling an existing type fetch function, and it is determined whether the corresponding type of the element is The method type, if yes, obtains the method of acquiring the corresponding barrage event of the element by calling the existing method, and marks the method of the barrage event as the method to be registered; if not, no processing is performed;
    将所有标记为待注册方法的弹幕事件的方法保存至一个预设的待注册方法集合中。Saves all methods marked as barrage events for the method to be registered to a preset set of methods to be registered.
  10. 如权利要求9所述的安卓中弹幕事件自动注册的系统,其特征在于,所述自动注册实现模块对得到的所有弹幕事件的方法进行注册操作的具体流程为:通过for循环的方式依次取出待注册方法集合中的每个弹幕事件的方法;每次取出集合中的一个弹幕事件的方法后,通过调用已有的注册函数对该弹幕事件的方法进行注册操作。The system for automatically registering an Android bullet-in event according to claim 9, wherein the automatic registration implementation module performs a registration operation on all the methods of the barrage event obtained by the method of the for loop: The method of extracting each barrage event in the set of methods to be registered; after each method of extracting a barrage event in the set, the method of registering the barrage event is performed by calling an existing registration function.
PCT/CN2018/081311 2017-07-27 2018-03-30 Method for automatically registering bullet screen event in android, storage medium, device and system WO2019019683A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710624143.3A CN107450922B (en) 2017-07-27 2017-07-27 Method, storage medium, device and system for automatically registering popup events in android
CN201710624143.3 2017-07-27

Publications (1)

Publication Number Publication Date
WO2019019683A1 true WO2019019683A1 (en) 2019-01-31

Family

ID=60489706

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/081311 WO2019019683A1 (en) 2017-07-27 2018-03-30 Method for automatically registering bullet screen event in android, storage medium, device and system

Country Status (2)

Country Link
CN (1) CN107450922B (en)
WO (1) WO2019019683A1 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107450922B (en) * 2017-07-27 2020-01-03 武汉斗鱼网络科技有限公司 Method, storage medium, device and system for automatically registering popup events in android
CN108882053B (en) * 2018-06-29 2021-04-09 武汉斗鱼网络科技有限公司 Bullet screen message distribution method, device, equipment and storage medium
CN109348303B (en) * 2018-09-30 2021-02-02 武汉斗鱼网络科技有限公司 Bullet screen message distribution method, bullet screen message distribution device, terminal and storage medium
CN109495782B (en) * 2018-10-30 2021-04-09 武汉斗鱼网络科技有限公司 Storage method, system and storage medium for barrage message
CN111338659B (en) * 2020-02-28 2023-06-02 广州市百果园信息技术有限公司 Installation package generation method, message management method, device, equipment and storage medium
CN113961191A (en) * 2021-11-03 2022-01-21 北京沃东天骏信息技术有限公司 Method and device for automatically registering hierarchical code and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130151463A1 (en) * 2011-12-08 2013-06-13 Sap Ag Information Validation
CN106528261A (en) * 2016-12-02 2017-03-22 武汉斗鱼网络科技有限公司 Application page initialization compiling and controlling device and method
CN106648569A (en) * 2015-11-02 2017-05-10 腾讯科技(深圳)有限公司 Target serialization achieving method and device
CN107450922A (en) * 2017-07-27 2017-12-08 武汉斗鱼网络科技有限公司 Method, storage medium, equipment and the system that barrage event is registered automatically in Android

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130151463A1 (en) * 2011-12-08 2013-06-13 Sap Ag Information Validation
CN106648569A (en) * 2015-11-02 2017-05-10 腾讯科技(深圳)有限公司 Target serialization achieving method and device
CN106528261A (en) * 2016-12-02 2017-03-22 武汉斗鱼网络科技有限公司 Application page initialization compiling and controlling device and method
CN107450922A (en) * 2017-07-27 2017-12-08 武汉斗鱼网络科技有限公司 Method, storage medium, equipment and the system that barrage event is registered automatically in Android

Also Published As

Publication number Publication date
CN107450922A (en) 2017-12-08
CN107450922B (en) 2020-01-03

Similar Documents

Publication Publication Date Title
WO2019019683A1 (en) Method for automatically registering bullet screen event in android, storage medium, device and system
CN109739894B (en) Method, device, equipment and storage medium for supplementing metadata description
WO2018196559A1 (en) Method and apparatus for dealing with abnormality of application program, and storage medium
CN107515739B (en) Method and device for improving code execution performance
WO2018176822A1 (en) Method and device for performing elasticsearch operation
CN107305488A (en) One kind application method for internationalizing, device and terminal
CN107451045A (en) A kind of method and device of abnormal information positioning
US8752056B2 (en) Running native code across single or multi-core hybrid processor achitecture
CN114090671A (en) Data import method and device, electronic equipment and storage medium
CN116560642A (en) Code generation method and device, electronic equipment and storage medium
CN104484179A (en) Stack recalling method
CN106919374B (en) Script generation method and device
CN111222324A (en) Time identification method and device, computer readable storage medium and electronic equipment
CN114356964A (en) Data blood margin construction method and device, storage medium and electronic equipment
CN110851514A (en) ETL (extract transform and load) processing method based on FLINK (Linear rotation index)
CN112800194B (en) Interface change identification method, device, equipment and storage medium
CN111444208B (en) Data updating method and related equipment
US11449554B2 (en) Extensible search solution for asset information
CN104899042A (en) Embedded machine vision inspection program development method and system
RU2008139875A (en) PROCESSING DEVICE FOR DETECTING A SPECIFIC COMPUTER TEAM
CN108228161B (en) System and method for extending structured command line
JP2011013887A (en) Software development support device
CN111240790A (en) Multi-language adaptation method and device for application, client and storage medium
CN116107639A (en) Register renaming and instruction decoding method and device, processor and electronic equipment
CN103902895A (en) Botnet network control protocol mining method and device

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

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

Country of ref document: EP

Kind code of ref document: A1