CN109684009B - Protocol-based countdown synchronization method, device, storage medium and equipment - Google Patents

Protocol-based countdown synchronization method, device, storage medium and equipment Download PDF

Info

Publication number
CN109684009B
CN109684009B CN201811563535.4A CN201811563535A CN109684009B CN 109684009 B CN109684009 B CN 109684009B CN 201811563535 A CN201811563535 A CN 201811563535A CN 109684009 B CN109684009 B CN 109684009B
Authority
CN
China
Prior art keywords
countdown
control object
sharing
information
updated
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811563535.4A
Other languages
Chinese (zh)
Other versions
CN109684009A (en
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Ouyuan Network Video Co ltd
Original Assignee
Wuhan Ouyuan Network Video Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Ouyuan Network Video Co ltd filed Critical Wuhan Ouyuan Network Video Co ltd
Priority to CN201811563535.4A priority Critical patent/CN109684009B/en
Publication of CN109684009A publication Critical patent/CN109684009A/en
Application granted granted Critical
Publication of CN109684009B publication Critical patent/CN109684009B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Information Transfer Between Computers (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a protocol-based countdown synchronization method, a protocol-based countdown synchronization device, a protocol-based countdown synchronization storage medium and protocol-based countdown synchronization equipment. The method comprises the following steps: when a countdown triggering operation is monitored, a countdown shared object starts countdown; when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls a first countdown sharing function through the first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information; and/or calling a second countdown sharing function through the second control object, and sending the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information. By the technical scheme, countdown synchronization between the first control object and the second control object is realized.

Description

Protocol-based countdown synchronization method, device, storage medium and equipment
Technical Field
The embodiment of the invention relates to computer technology, in particular to a protocol-based countdown synchronization method, a protocol-based countdown synchronization device, a protocol-based countdown synchronization storage medium and protocol-based countdown synchronization equipment.
Background
There is a general business requirement in the Android system that needs to maintain countdown synchronization between multiple widgets, for example, for the countdown lottery business, it is required to maintain countdown synchronization between the Fragment widget and the Dialog widget laid out in the Fragment widget.
In the prior art, an implementation scheme of countdown synchronization is that each control maintains an independent countdown object, and a value of a parameter millis uviilfinished representing a countdown remaining time length is transmitted between each countdown object. For example, one countdown object is set in Fragment, another countdown object is set in Dialog, and each countdown object needs to set two countdown parameters, namely total time allTime and timing speed time tiggerTime. When Fragment is started, a countdown object in the Fragment is triggered, so that countdown is started based on the set allTime1, and the countdown remaining time millis unintilefinshed 1 is automatically updated according to the set tiggerTime 1. When Fragment monitors that Dialog clicking operation starts Dialog, in order to ensure that countdown synchronization in two widgets at Dialog starting time, the parameter value of current countdown remaining time milliUntilFinishd 1 in Fragment is transmitted to Dialog. Dialog sets allTime2 in its countdown object to the received millis uvitilfinished 1 parameter value, and then starts the countdown based on allTime2 synchronization.
In the above scheme, since the countdown in Fragment is never interrupted or suspended, at the time of starting the Dialog, there is a time difference between the countdown starting time in Fragment and the countdown starting time in Dialog, where the time difference corresponds to a time period from when the countdown remaining time length in Fragment is updated to the current countdown remaining time length to when the transmission of the current countdown remaining time length to Dialog is ended, and the maximum time difference is tiggerTime1 in Fragment, so that the countdown between two widgets cannot be synchronized.
Disclosure of Invention
The embodiment of the invention provides a protocol-based countdown synchronization method, a protocol-based countdown synchronization device, a protocol-based countdown synchronization storage medium and protocol-based countdown synchronization equipment, which are used for realizing countdown synchronization among different controls.
In a first aspect, an embodiment of the present invention provides a protocol-based countdown synchronization method, including:
when a countdown triggering operation is monitored, a countdown shared object starts countdown;
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls a first countdown sharing function through a first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information; and/or the presence of a gas in the gas,
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and sends the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information;
wherein the first and second countdown sharing functions are respectively obtained by the first and second control objects based on a predefined countdown sharing protocol.
Optionally, the monitoring whether there is a countdown triggering operation includes:
monitoring whether the first control object sends a countdown total timing time to the countdown shared object, wherein the total timing time is a countdown parameter for creating the countdown shared object; or the like, or, alternatively,
monitoring whether the first control object sends a countdown information acquisition request or not; or the like, or, alternatively,
and monitoring whether the first control object is started.
Optionally, after the countdown of the shared object starts the countdown, the method further includes:
and if the control object list exists and the number of elements in the control object list is greater than 0, acquiring the first control object and/or the second control object from the control object list.
Further, before obtaining the first control object and/or the second control object from the control object list if the control object list exists and the number of elements in the control object list is greater than 0, the method further includes:
creating the control object list according to the countdown sharing protocol;
after the first control object is created, taking the first control object as a function input parameter, calling a list element adding function through the countdown sharing object, and adding the first control object to the control object list;
after the second control object is created, the second control object is used as a function input parameter, the list element adding function is called through the countdown sharing object, and the second control object is added to the control object list.
Optionally, before the countdown sharing object uses the updated current countdown information as a function input parameter, and calls the first countdown sharing function through the first control object, and/or calls the second countdown sharing function through the second control object, the method further includes:
defining a countdown sharing protocol of an interface type and a countdown sharing function in the countdown sharing protocol, wherein the countdown sharing function has a public authority modifier;
the first control object and the second control object inherit the countdown sharing protocol through protocol inheritance keywords respectively so as to obtain the first countdown sharing function and the second countdown sharing function respectively.
Optionally, the countdown sharing object uses the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and sends the updated countdown information to the second countdown object, and before the countdown sharing object, the method further includes:
displaying a preset cache picture in a display area corresponding to the second control object;
correspondingly, after the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and sends the updated countdown remaining duration to the second countdown object, the method further includes:
hiding the preset cache picture, and displaying a display picture corresponding to the second control object in the display area.
Optionally, the first control object is a fragment control object in an Android system, and the second control object is a dialog box control object in the Android system.
In a second aspect, an embodiment of the present invention further provides a protocol-based countdown synchronization apparatus, where the apparatus includes:
the countdown starting module is used for starting countdown of the countdown sharing object when the countdown triggering operation is monitored;
the first countdown information sending module is used for calling a first countdown sharing function through a first control object to send updated countdown information to the first control object by taking the updated current countdown information as a function input parameter when the countdown information is updated, so that the first control object executes a first countdown operation based on the updated countdown information; and/or the presence of a gas in the gas,
a second countdown information sending module, configured to, when the countdown information is updated, call, by the second control object, the second countdown sharing function with the updated current countdown information as a function input parameter, and send the updated countdown information to the second countdown object, so that the second control object performs a second countdown operation based on the updated countdown information;
wherein the first and second countdown sharing functions are respectively obtained by the first and second control objects based on a predefined countdown sharing protocol.
Optionally, the countdown starting module is specifically configured to:
monitoring whether the first control object sends a countdown total timing time to the countdown shared object, wherein the total timing time is a countdown parameter for creating the countdown shared object; or the like, or, alternatively,
monitoring whether the first control object sends a countdown information acquisition request or not; or the like, or, alternatively,
and monitoring whether the first control object is started.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes a control object obtaining module, configured to:
after the countdown of the countdown sharing object is started, if a control object list exists and the number of elements of the control object list is greater than 0, acquiring the first control object and/or the second control object from the control object list.
Further, on the basis of the above apparatus, the apparatus further includes a list creation module configured to:
if a control object list exists and the number of elements of the control object list is greater than 0, before the first control object and/or the second control object are/is acquired from the control object list, the control object list is created according to the countdown sharing protocol;
after the first control object is created, taking the first control object as a function input parameter, calling a list element adding function through the countdown sharing object, and adding the first control object to the control object list;
after the second control object is created, the second control object is used as a function input parameter, the list element adding function is called through the countdown sharing object, and the second control object is added to the control object list.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes a protocol inheritance module, configured to:
before the countdown sharing object takes the updated current countdown information as a function input parameter, a first countdown sharing function is called through a first control object, and/or a second countdown sharing function is called through a second control object, an interface type countdown sharing protocol and a countdown sharing function in the countdown sharing protocol are defined, wherein the countdown sharing function has a public authority modifier;
the first control object and the second control object inherit the countdown sharing protocol through protocol inheritance keywords respectively so as to obtain the first countdown sharing function and the second countdown sharing function respectively.
Optionally, on the basis of the above apparatus, the apparatus further includes a display module, configured to:
calling a second countdown sharing function through a second control object by taking the updated current countdown information as a function input parameter in the countdown sharing object, and displaying a preset cache picture in a display area corresponding to the second control object before sending the updated countdown information to the second countdown object;
and taking the updated current countdown information as a function input parameter, calling a second countdown sharing function through a second control object, sending the updated countdown remaining time to the second countdown object, hiding the preset cache picture, and displaying a display picture corresponding to the second control object in the display area.
Optionally, the first control object is a fragment control object in an Android system, and the second control object is a dialog box control object in the Android system.
In a third aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the protocol-based countdown synchronization method provided in any embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a protocol-based countdown synchronization method provided by any embodiment of the invention.
According to the embodiment of the invention, the countdown shared object is set to maintain the countdown shared by the control objects, and when the countdown shared object updates the countdown information each time, the countdown information is sent to the first control object and/or the second control object, so that the countdown information received by the control objects is the same, the countdown synchronization between the first control object and the second control object is realized, the problem of time difference between the countdown starting time of the first control object and the countdown starting time of the second control object is solved, and the countdown synchronization between the first control object and the second control object is improved.
Drawings
Fig. 1 is a flowchart of a protocol-based countdown synchronization method according to a first embodiment of the present invention;
fig. 2 is a flowchart of a protocol-based countdown synchronization method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a protocol-based countdown synchronization apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus in the fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
The protocol-based countdown synchronization method provided by the embodiment can be applied to the condition of keeping countdown synchronization among a plurality of controls in an Android system. The method can be executed by a protocol-based countdown synchronization device, the device can be implemented in a software and/or hardware manner, and the device can be integrated in equipment carrying an Android system, for example, typical user terminal equipment such as a mobile phone, a tablet computer, or a smart television. Referring to fig. 1, the method of the present embodiment includes:
and S110, when the countdown triggering operation is monitored, the countdown shared object starts countdown.
The countdown triggering operation refers to an operation of triggering countdown to start. The countdown sharing object refers to a Java object created and initialized in advance, which is used to implement a countdown function. Illustratively, the countdown sharing object is created and initialized based on the system countdown class provided by the Android system. When the method is specifically implemented, a countdown sharing class is defined, and the code implementation can be as follows: public class CountDownShare { }, in the embodiment of the present invention, the countdown sharing class CountDownShare is defined as a public class with a public authority modifier public, so that the CountDownShare class and its instantiation object can be accessed and held by other control objects. And, the countdown sharing class is inherited to the system countdown class countdown timer. Then, a countdown sharing object mCountDownShar ═ new CountDownShar (allTime, tiggerTime) { }isgenerated and initialized. The function input parameter allTime of the countdown shared object is total time, which indicates the total countdown length of the countdown, for example, 60 seconds in total, and the first total timing time is set to 60 seconds. the tiggerTime is a timer speed time, which represents the speed of the countdown operation, for example, if a countdown is performed once in 1 second, the timer speed time is 1000 milliseconds. In the countdown parameter setting, the total time needs to be an integral multiple of the timer speed time. The countdown sharing object at least comprises a countdown function onTick (locking milliUtilFinished) { }, which is used for executing countdown, the milliUtilFinishd is the countdown remaining time, and the parameter value is automatically updated by system countdown following the execution of the onTick function.
Specifically, the countdown sharing object monitors whether a countdown triggering operation exists in real time, and when the monitoring result is yes, a countdown starting function start () in the countdown sharing object is called to start the sharing countdown. After the countdown is started, the countdown shared object triggers and executes a countdown function onTick () every other timing speed time and updates countdown information. The countdown information refers to information related to the countdown, and may be at least one of the number of times the countdown has been performed, the time the countdown has been performed (i.e., the counted down period), and the remaining period of time for the countdown, for example.
Illustratively, monitoring for a countdown triggering operation includes: monitoring whether the first control object sends a countdown total timing time to the countdown sharing object or not, wherein the total timing time is a countdown parameter for creating the countdown sharing object; or, monitoring whether the first control object sends a request for acquiring countdown information; or, whether the first control object is started or not is monitored.
The first control object is a control object which needs to keep countdown synchronization and is started first in the Android system.
Specifically, the countdown triggering operation may include three cases. The first case is that the first control object sends the total timed time for it by accessing the countdown sharing object. And when the countdown sharing object monitors that the total timing time parameter value is updated, monitoring a countdown triggering operation. At the moment, the initial value of the total timing time is preset in the countdown sharing object, and then the total timing time parameter value in the countdown execution process is transmitted by the first control object, so that the setting and the modification of the total timing time can be facilitated. The second situation is that the first control object requests the countdown sharing object to acquire countdown information for the first time, and when the countdown sharing object monitors the data request, a countdown triggering operation is monitored. At this time, the total timing time is set in the countdown sharing object, and the first control object does not maintain the total timing time any more, so that the service implementation logic can be simplified. In the third case, when the countdown sharing object monitors that the first control object is started, the countdown triggering operation is monitored. At this time, the total timing time is also set in the countdown sharing object, and the first control object starts to share the countdown information when being started, so that the service implementation logic can be further simplified.
And S120, when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls the first countdown sharing function through the first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information.
The first countdown sharing function refers to a function in the first control object, and is used for transferring countdown information. Illustratively, the first countdown sharing function is that the first control object is obtained based on a predefined countdown sharing protocol. The countdown sharing protocol is a communication protocol for communicating the countdown sharing object to the control object, is an interface type, and comprises a countdown sharing protocol function for realizing communication. If the countdown sharing object needs to send information to the first control object, the first control object needs to inherit the countdown sharing protocol and realize a countdown sharing protocol function in the first control object, and then the first countdown sharing function is obtained. The first control object may be registered to the countdown sharing object, or the access right may be modified to be a public right, so that the countdown sharing object may access the first control object.
Specifically, according to the description of S110, after the countdown is started, the first control object must have been started. Then, when the countdown sharing object executes the countdown function once and updates the countdown information, the first countdown sharing function in the first control object is called by accessing the first control object and taking the updated countdown information as a function input parameter, and the updated countdown information is sent to the first control object. The first control object performs a first countdown operation, such as determining a countdown display duration and/or displaying a countdown screen, based on the received updated countdown information.
Illustratively, the countdown information is a countdown remaining time period. Therefore, the countdown display duration determination operation in the control object can be omitted, and the countdown operation in the control object is simplified.
And S130, when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through the second control object, and sends the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information.
The second control object is a control object which needs to keep countdown synchronization in the Android system and is started after the first control object. It should be noted that the second control object may be one control object or may be a plurality of control objects. In the embodiment of the present invention, a second control object is taken as an example for explanation. The second countdown sharing function refers to a function in the second control object that is used to communicate countdown information. Illustratively, the second countdown sharing function is that the second control object is obtained based on a predefined countdown sharing protocol. If the countdown sharing object needs to send information to the second control object, the second control object needs to inherit the countdown sharing protocol and realize a countdown sharing function in the countdown sharing protocol, and then the second countdown sharing protocol function is obtained. The second control object may be registered to the countdown shared object, or the access right may be modified to a public right so that the countdown shared object may access the second control object.
Specifically, according to the description of S110, a countdown has been initiated before the second control object is initiated. Then, after the second control object is started, when the countdown sharing object executes the countdown function once and updates the countdown information, the second countdown sharing function in the second control object is called by accessing the second control object and taking the updated countdown information as a function input parameter, and the updated countdown information is sent to the second control object. The second control object performs a second countdown operation, such as determining a countdown display duration and/or displaying a countdown screen, based on the received updated countdown information.
In the embodiment of the invention, as long as the first control object and the second control object are started, the countdown information sent by the countdown sharing object can be received when the countdown sharing object updates the countdown information. For example, if the first control object is activated and the second control object is not activated, S120 is executed; when the first control object and the second control object are both started, the sending operation of the plurality of countdown information in the countdown shared object is executed in parallel, that is, S120 and S130 are executed in parallel. It should be noted that, if the countdown shared object has updated the countdown information when the second control object is triggered to start, the countdown shared object does not temporarily send the countdown information to the second control object, but sends the countdown information to the second control object when the countdown object updates the countdown information next time. Therefore, the first control object and the second control object can be guaranteed to receive the same countdown information in time, and therefore countdown synchronization in the first control object and the second control object is guaranteed.
According to the technical scheme, the countdown shared object is set to maintain the countdown shared by the control objects, and when the countdown shared object updates the countdown information every time, the countdown information is sent to the first control object and/or the second control object, so that the countdown information received by the control objects is the same, the countdown synchronization between the first control object and the second control object is realized, the problem of time difference between the countdown starting time of the first control object and the countdown starting time of the second control object is solved, and the countdown synchronization between the first control object and the second control object is improved.
Based on the above scheme, before S120 and/or S130, the protocol-based countdown synchronization method of this embodiment further includes: defining a countdown sharing protocol of an interface type and a countdown sharing function in the countdown sharing protocol, wherein the countdown sharing function has a public authority modifier; the first control object and the second control object inherit the countdown sharing protocol through the protocol inheritance keyword respectively so as to obtain a first countdown sharing function and a second countdown sharing function respectively.
The protocol inheritance keyword is a keyword specified in Java language for carrying out protocol inheritance.
Specifically, in order to implement that the countdown information is directly sent to the control object in time, in the embodiment of the present invention, a countdown sharing protocol of an interface type is predefined, and the code implementation may be: public interface TimeSync { public void oneTimeTick (int time); and a countdown sharing protocol is named TimeSync and includes a countdown sharing protocol function ONTimeTick (), and a function input parameter of the function is updated countdown information time. And then all control objects needing to share the countdown information realize inheritance of the countdown sharing protocol TimeSync through the protocol inheritance key words instances, and duplicate and realize a countdown sharing protocol function ONTimeTick (). Therefore, a communication channel is established between the countdown sharing object and each control object, and the function of realizing countdown information transmission is provided, so that a basis is provided for realizing countdown information sharing subsequently.
Example two
In this embodiment, on the basis of the first embodiment, a step of creating a "control object list" is added. On the basis, the step of acquiring the first control object and/or the second control object can be further added. On the basis of the above, a step of displaying can be further added. Wherein explanations of the same or corresponding terms as those of the above embodiments are omitted. Referring to fig. 2, the protocol-based countdown synchronization method provided in this embodiment includes:
s210, creating a control object list according to a countdown sharing protocol.
The control object list is a list for storing each control object, and is arranged in the countdown sharing object. Storing the control object in the countdown shared object means that the countdown shared object holds the reference relationship of the control object, and the countdown information can be subsequently transferred based on the reference relationship.
Specifically, since each control object is stored in the control object list and is directly accessed by the countdown sharing object, the data type of the element in the control object list should be consistent with the type of the countdown sharing protocol. In specific implementation, a control object List listTimeSync is created according to a countdown sharing protocol TimeSync, and the control object List is initialized by using a dynamic array type ArrayList of an Android system, and the code implementation may be List < TimeSync > listTimeSync ═ new ArrayList < TimeSync >.
S220, after the first control object is created, the first control object is used as a function input parameter, a list element adding function is called through the countdown sharing object, and the first control object is added to the control object list.
The list element adding function is predefined and can perform an element adding operation function on the control object list.
Specifically, to maintain the validity of the elements in the control object list, each control object is added to the control object list after it is created. Since the control object list is a member of the countdown sharing class, in order to improve the access efficiency, a list element with a Public authority is set in the countdown sharing class to add a Public void addTimeSync (TimesSync mTimeSeync), and a function input parameter of the function is an object of the countdown sharing protocol type. And then, each control object can directly access the function through the countdown sharing object so as to add the reference relation of the control object to the control object list.
In specific implementation, when the first control object is created, in the lifecycle initiation function onCreated, the first control object is used as a function input parameter, a list element is called to add a function addTimeSync (), and the created first control object is added to the control object list.
Illustratively, taking the first control object as a function input parameter, calling a list element adding function through the countdown sharing object, and adding the first control object to the list of control objects comprises: according to the countdown sharing protocol, judging keywords through a first control object calling instance, and judging whether the first control object inherits the countdown sharing protocol; if so, taking the first control object as a function input parameter, calling a list element adding function through the countdown sharing object, and adding the first control object to the control object list.
The example judgment keyword is specified in Java language, and is used for judging whether a certain object is a keyword of an example of a certain class, the use method is that the object result is "bolt result of class", the function is that the example judgment keyword is used for judging whether a left object of the bolt result is an example of the right class of class, and a return value of the boolean type bolt is returned.
Specifically, according to the description that the countdown sharing object sends the countdown information and the definition of the control object list, before adding the control object into the control object list, it should be determined whether the control object inherits the countdown sharing protocol. If the judgment result is negative, the subsequent operations of adding the list elements and sending the countdown information cannot be executed, and the operation of protocol inheritance needs to be executed first. And if so, adding the control object to the control object list. In specific implementation, before the list element adding operation is executed, whether the first control object to be added is an instance of the countdown sharing protocol is determined through an instance judgment keyword instanceof. If the return value is a deterministic identification such as true, indicating that the first control object to be added is an instance of the countdown sharing protocol, then an element addition operation is performed. Otherwise, the list element adding operation is directly ended.
And S230, after the second control object is created, taking the second control object as a function input parameter, calling a list element adding function through the countdown sharing object, and adding the second control object to the control object list.
The execution process of this step is the same as S220, except that the execution object is changed from the first control object to the second control object, and this step should also include an operation of determining whether the second control object inherits the countdown sharing protocol.
S240, when the countdown triggering operation is monitored, the countdown shared object starts countdown.
And S250, if the control object list exists and the number of elements in the control object list is greater than 0, acquiring the first control object and/or the second control object from the control object list.
Specifically, if the countdown sharing object needs to acquire the first control object and/or the second control object through the control object list, it is first necessary to determine whether the control object list exists. If the control object list does not exist, the reference relation of each control object is not established in the countdown sharing object, and the subsequent countdown information sharing cannot be executed, at the moment, an Exception message is thrown through an Exception prompt code throw Exception, so that developers can quickly position the error position.
If the control object list exists, whether the number of elements of the control object list is greater than 0 is further judged through a list element number acquisition function count (). If the number of the elements is not more than 0, the list does not store any elements therein although the list exists, and the sharing of the subsequent countdown information cannot be executed. And if the number of the list elements is more than 0, the countdown sharing object acquires the elements in the list of the control objects through the list of the control objects, namely the first control object and/or the second control object.
And S260, when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls the first countdown sharing function through the first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information.
And S270, displaying a preset cache picture in a display area corresponding to the second control object.
The preset cache picture refers to a preset transitional display picture, and is used when the previous display page is hidden and the next display page is not displayed in the switching process of the two display pages.
Specifically, for a scenario that the second control object is started, but the countdown information is not received yet, and the second control object needs to display a countdown screen, a reasonable display screen switching scheme needs to be set, so as to avoid a user from having a stuck illusion due to no display screen or unchanged display screen in the process of implementing the countdown synchronization scheme. In specific implementation, when the start triggering operation of the second control object is monitored and the countdown information sent by the countdown sharing object is not received, at least a preset cache picture is displayed in a display area corresponding to the second control object.
And S280, when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through the second control object, and sends the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information.
And S290, hiding the preset cache picture, and displaying a display picture corresponding to the second control object in the display area.
Specifically, when the start triggering operation of the second control object is monitored and the countdown information sent by the countdown sharing object is received, the previously displayed preset cache picture is hidden, and the display picture corresponding to the second control object is displayed in at least the display area corresponding to the second control object, which may be, for example, a countdown picture. It should be noted that, if the display screen corresponding to the second control object is already displayed, the operation of hiding the preset cache screen in S270 and this step is not executed any more.
It should be noted that the creation of the first control object and the creation of the second control object in S220 and S230 are only execution timings of the addition operation as list elements, and are not limited to the control object creation timing. In addition, S210-S230 may be performed only once at the time of control object creation. In addition, the execution order of S240 may not be limited, and it is only necessary to execute before S260.
On the basis of the technical scheme, the first control object in the embodiment of the invention is a fragment control object in an Android system, and the second control object is a dialog box control object in the Android system. Fragment control object Fragment is a control object for displaying page content in an Android system, and can generally carry Dialog control object Dialog. The application scene is more in a human-computer interaction scene in an Android system.
According to the technical scheme of the embodiment, the operation that the countdown sharing object accesses the first control object and/or the second control object is simplified through the creation and maintenance of the control object list, and the countdown synchronization efficiency is further improved. By switching the preset cache picture and the display picture displayed in the corresponding display area of the second control object at different occasions, a more reasonable display picture switching scheme is provided, and therefore user experience is further improved.
The following is an embodiment of the protocol-based countdown synchronization apparatus provided in the embodiments of the present invention, which belongs to the same inventive concept as the protocol-based countdown synchronization method in the embodiments described above, and reference may be made to the embodiment of the protocol-based countdown synchronization method for details that are not described in detail in the embodiments of the protocol-based countdown synchronization apparatus.
EXAMPLE III
The present embodiment provides a protocol-based countdown synchronization apparatus, and referring to fig. 3, the apparatus specifically includes:
a countdown starting module 310, configured to start countdown of the countdown sharing object when a countdown triggering operation is monitored, and update countdown information at intervals of a timing speed and a timing time;
a first countdown information sending module 320, configured to, when the countdown information is updated, call the first countdown sharing function through the first control object to send the updated countdown information to the first control object by using the updated current countdown information as a function input parameter, so that the first control object performs a first countdown operation based on the updated countdown information; and/or the presence of a gas in the gas,
a second countdown information sending module 330, configured to, when the countdown information is updated, call the second countdown sharing function through the second control object by using the updated current countdown information as a function input parameter, and send the updated countdown information to the second countdown object, so that the second control object performs a second countdown operation based on the updated countdown information;
the timing speed time is a countdown parameter for creating a countdown sharing object; the first countdown sharing function and the second countdown sharing function are respectively obtained by the first control object and the second control object based on a predefined countdown sharing protocol.
Optionally, the countdown starting module 310 is specifically configured to:
monitoring whether the first control object sends a countdown total timing time to the countdown sharing object or not, wherein the total timing time is a countdown parameter for creating the countdown sharing object; or the like, or, alternatively,
monitoring whether a first control object sends a countdown information acquisition request or not; or the like, or, alternatively,
monitoring whether the first control object is started.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes a control object obtaining module, configured to:
after the countdown of the countdown sharing object is started, if the control object list exists and the number of elements of the control object list is greater than 0, the first control object and/or the second control object are/is acquired from the control object list.
Further, on the basis of the above apparatus, the apparatus further includes a list creation module configured to:
if the control object list exists and the number of elements of the control object list is greater than 0, before the first control object and/or the second control object are/is acquired from the control object list, the control object list is created according to a countdown sharing protocol;
after the first control object is created, the first control object is used as a function input parameter, a list element adding function is called through a countdown sharing object, and the first control object is added to a control object list;
after the second control object is created, the second control object is used as a function input parameter, a list element adding function is called through the countdown sharing object, and the second control object is added to the control object list.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes a protocol inheritance module, configured to:
before the countdown sharing object takes the updated current countdown information as a function input parameter, a first countdown sharing function is called through a first control object, and/or a second countdown sharing function is called through a second control object, a countdown sharing protocol of an interface type and a countdown sharing function in the countdown sharing protocol are defined, wherein the countdown sharing function has a public authority modifier;
the first control object and the second control object inherit the countdown sharing protocol through the protocol inheritance keyword respectively so as to obtain a first countdown sharing function and a second countdown sharing function respectively.
Optionally, on the basis of the above apparatus, the apparatus further includes a display module, configured to:
the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and displays a preset cache picture in a display area corresponding to the second control object before the updated countdown information is sent to the second countdown object;
and when the countdown sharing object takes the updated current countdown information as a function input parameter, calling a second countdown sharing function through a second control object, after sending the updated countdown remaining time to the second countdown object, hiding a preset cache picture, and displaying a display picture corresponding to the second control object in a display area.
Optionally, the first control object is a fragment control object in the Android system, and the second control object is a dialog control object in the Android system.
By the protocol-based countdown synchronization device in the third embodiment of the invention, countdown synchronization between the first control object and the second control object is realized, the problem of time difference between countdown starting times of the first control object and the second control object is solved, and countdown synchronization between the first control object and the second control object is improved.
The protocol-based countdown synchronization device provided by the embodiment of the invention can execute the protocol-based countdown synchronization method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the protocol-based countdown synchronization apparatus, the included units and modules are only divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
Example four
The present embodiments provide a storage medium containing computer-executable instructions which, when executed by a computer processor, are operable to perform a protocol-based countdown synchronization method, the method comprising:
when a countdown triggering operation is monitored, a countdown shared object starts countdown;
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls a first countdown sharing function through the first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information; and/or the presence of a gas in the gas,
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through the second control object, and sends the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information;
the first countdown sharing function and the second countdown sharing function are respectively obtained by the first control object and the second control object based on a predefined countdown sharing protocol.
Of course, the storage medium containing the computer-executable instructions provided by the embodiments of the present invention is not limited to the above method operations, and may also perform related operations in the protocol-based countdown synchronization method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the protocol-based countdown synchronization method provided by the embodiments of the present invention.
EXAMPLE five
Referring to fig. 4, the present embodiment provides an apparatus 400 comprising: one or more processors 420; the storage device 410 is used for storing one or more programs, and when the one or more programs are executed by the one or more processors 420, the one or more processors 420 implement the protocol-based countdown synchronization method provided by the embodiment of the present invention, including:
when a countdown triggering operation is monitored, a countdown shared object starts countdown;
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls a first countdown sharing function through the first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information; and/or the presence of a gas in the gas,
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through the second control object, and sends the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information;
the first countdown sharing function and the second countdown sharing function are respectively obtained by the first control object and the second control object based on a predefined countdown sharing protocol.
Of course, those skilled in the art will understand that the processor 420 may also implement the technical solution of the protocol-based countdown synchronization method provided in any embodiment of the present invention.
The apparatus 400 shown in fig. 4 is only an example and should not bring any limitations to the functionality or scope of use of the embodiments of the present invention. As shown in fig. 4, the apparatus 400 includes a processor 420, a storage device 410, an input device 430, and an output device 440; the number of the processors 420 in the device may be one or more, and one processor 420 is taken as an example in fig. 4; the processor 420, the storage device 410, the input device 430 and the output device 440 of the apparatus may be connected by a bus or other means, for example, the bus 450 in fig. 4.
The storage device 410, which is a computer-readable storage medium, may be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the protocol-based countdown synchronization method in the embodiment of the present invention (for example, a countdown starting module, a first countdown information sending module, and a second countdown information sending module in the protocol-based countdown synchronization device).
The storage device 410 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the storage 410 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the storage 410 may further include memory located remotely from the processor 420, which may be connected to the device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means 430 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the apparatus. The output device 440 may include a display device such as a display screen.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A protocol-based countdown synchronization method, comprising:
when a countdown triggering operation is monitored, a countdown shared object starts countdown;
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, and calls a first countdown sharing function through a first control object to send the updated countdown information to the first control object, so that the first control object executes a first countdown operation based on the updated countdown information; and the combination of (a) and (b),
when the countdown information is updated, the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and sends the updated countdown information to the second countdown object so that the second control object executes a second countdown operation based on the updated countdown information;
wherein the first and second countdown sharing functions are respectively obtained by the first and second control objects based on a predefined countdown sharing protocol;
wherein the countdown sharing object is an object that is based on the countdown class and is initialized.
2. The method of claim 1, wherein monitoring for a countdown triggering operation comprises:
monitoring whether the first control object sends a countdown total timing time to the countdown shared object, wherein the total timing time is a countdown parameter for creating the countdown shared object; or the like, or, alternatively,
monitoring whether the first control object sends a countdown information acquisition request or not; or the like, or, alternatively,
and monitoring whether the first control object is started.
3. The method of claim 1, after the countdown shared object starts a countdown, further comprising:
and if the control object list exists and the number of elements in the control object list is greater than 0, acquiring the first control object and/or the second control object from the control object list.
4. The method according to claim 3, further comprising, before obtaining the first control object and/or the second control object from the control object list if the control object list exists and the number of elements in the control object list is greater than 0:
creating the control object list according to the countdown sharing protocol;
after the first control object is created, taking the first control object as a function input parameter, calling a list element adding function through the countdown sharing object, and adding the first control object to the control object list;
after the second control object is created, the second control object is used as a function input parameter, the list element adding function is called through the countdown sharing object, and the second control object is added to the control object list.
5. The method according to claim 1, before the countdown sharing object takes the updated current countdown information as a function input parameter, calls a first countdown sharing function through a first control object, and/or calls a second countdown sharing function through a second control object, further comprising:
defining a countdown sharing protocol of an interface type and a countdown sharing function in the countdown sharing protocol, wherein the countdown sharing function has a public authority modifier;
the first control object and the second control object inherit the countdown sharing protocol through protocol inheritance keywords respectively so as to obtain the first countdown sharing function and the second countdown sharing function respectively.
6. The method of claim 1, wherein before the countdown sharing object uses the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and sends the updated countdown information to the second countdown object, the method further comprises:
displaying a preset cache picture in a display area corresponding to the second control object;
correspondingly, after the countdown sharing object takes the updated current countdown information as a function input parameter, calls a second countdown sharing function through a second control object, and sends the updated countdown remaining duration to the second countdown object, the method further includes:
hiding the preset cache picture, and displaying a display picture corresponding to the second control object in the display area.
7. The method according to claim 1, wherein the first control object is a fragment control object in an Android system, and the second control object is a dialog control object in the Android system.
8. A protocol-based countdown synchronizer, comprising:
the countdown starting module is used for starting countdown of the countdown sharing object when the countdown triggering operation is monitored;
the first countdown information sending module is used for calling a first countdown sharing function through a first control object to send updated countdown information to the first control object by taking the updated current countdown information as a function input parameter when the countdown information is updated, so that the first control object executes a first countdown operation based on the updated countdown information; and the combination of (a) and (b),
a second countdown information sending module, configured to, when the countdown information is updated, call, by the second control object, the second countdown sharing function with the updated current countdown information as a function input parameter, and send the updated countdown information to the second countdown object, so that the second control object performs a second countdown operation based on the updated countdown information;
wherein the first and second countdown sharing functions are respectively obtained by the first and second control objects based on a predefined countdown sharing protocol;
wherein the countdown sharing object is an object that is based on the countdown class and is initialized.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the protocol-based countdown synchronization method according to any of claims 1-7.
10. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the protocol-based countdown synchronization method of any of claims 1-7.
CN201811563535.4A 2018-12-20 2018-12-20 Protocol-based countdown synchronization method, device, storage medium and equipment Active CN109684009B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811563535.4A CN109684009B (en) 2018-12-20 2018-12-20 Protocol-based countdown synchronization method, device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811563535.4A CN109684009B (en) 2018-12-20 2018-12-20 Protocol-based countdown synchronization method, device, storage medium and equipment

Publications (2)

Publication Number Publication Date
CN109684009A CN109684009A (en) 2019-04-26
CN109684009B true CN109684009B (en) 2022-03-08

Family

ID=66187977

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811563535.4A Active CN109684009B (en) 2018-12-20 2018-12-20 Protocol-based countdown synchronization method, device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN109684009B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111240655B (en) * 2020-01-07 2023-11-07 红有软件股份有限公司 Method for beautifying WinForm component based on GDI/GDI +

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102130969A (en) * 2011-04-26 2011-07-20 苏州阔地网络科技有限公司 Method and system for realizing timing synchronization based on webpage
CN102164142A (en) * 2011-04-26 2011-08-24 苏州阔地网络科技有限公司 Webpage-based timing security synchronization realization method and system
CN103680162A (en) * 2012-09-18 2014-03-26 王大海 Self-adaptive coordination control system for traffic signal
CN104731591A (en) * 2015-03-19 2015-06-24 天脉聚源(北京)教育科技有限公司 Method and device for processing control in content display process
CN107637091A (en) * 2015-05-19 2018-01-26 罗伯特·博世有限公司 The method and apparatus synchronous for sensor
CN107844355A (en) * 2017-11-09 2018-03-27 北京酷我科技有限公司 A kind of reminding method of pot machine countdown
CN109032815A (en) * 2018-07-18 2018-12-18 武汉斗鱼网络科技有限公司 Information interacting method, device, equipment and storage medium between functional module

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8701560B2 (en) * 2010-11-22 2014-04-22 Battelle Energy Alliance, Llc Apparatus, system, and method for synchronizing a timer key

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102130969A (en) * 2011-04-26 2011-07-20 苏州阔地网络科技有限公司 Method and system for realizing timing synchronization based on webpage
CN102164142A (en) * 2011-04-26 2011-08-24 苏州阔地网络科技有限公司 Webpage-based timing security synchronization realization method and system
CN103680162A (en) * 2012-09-18 2014-03-26 王大海 Self-adaptive coordination control system for traffic signal
CN104731591A (en) * 2015-03-19 2015-06-24 天脉聚源(北京)教育科技有限公司 Method and device for processing control in content display process
CN107637091A (en) * 2015-05-19 2018-01-26 罗伯特·博世有限公司 The method and apparatus synchronous for sensor
CN107844355A (en) * 2017-11-09 2018-03-27 北京酷我科技有限公司 A kind of reminding method of pot machine countdown
CN109032815A (en) * 2018-07-18 2018-12-18 武汉斗鱼网络科技有限公司 Information interacting method, device, equipment and storage medium between functional module

Also Published As

Publication number Publication date
CN109684009A (en) 2019-04-26

Similar Documents

Publication Publication Date Title
CN108536524B (en) Resource updating method, device, terminal and storage medium
WO2023093429A1 (en) Micro-application running method and apparatus, and device, storage medium and program product
CN105955792B (en) Start control method, device and equipment
KR102566622B1 (en) Method, apparatus, electronic device for multi-core communication and storage medium
CN106843977B (en) A kind of processing method, device and the mobile terminal of application program self-starting
CN109343983B (en) Information interaction method, device, equipment and storage medium between function modules
CN103514924B (en) The method of video, device and player is play in mobile terminal widget Widget
WO2021102691A1 (en) Resource subscription method and apparatus, computer device, and storage medium
TW201826102A (en) Execution of multiple applications on a device
CN109062650B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109388388B (en) Information interaction method, device, equipment and storage medium between function modules
CN109684009B (en) Protocol-based countdown synchronization method, device, storage medium and equipment
CN114222003A (en) Service calling method, system, device, equipment and storage medium
CN108810645B (en) Bullet screen message distribution method, device, equipment and storage medium
CN110324722B (en) Method, device, equipment and storage medium for acquiring data in live broadcast room
CN110045997B (en) Object initialization method, device, equipment and storage medium of basic function module
CN109144520B (en) Information interaction method, device, equipment and storage medium among different objects in Android
CN109089163B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109086115B (en) Android animation execution method, device, terminal and readable medium
WO2023124657A1 (en) Micro-application running method and apparatus, device, storage medium, and program product
CN111200651A (en) Method, system, device and medium for timed calling of microservice
CN109144638B (en) Android horizontal and vertical screen data synchronization method and device, terminal and readable medium
CN109005468B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109005448B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109086107B (en) Bullet screen message distribution method, device, equipment and storage medium

Legal Events

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