CN109062620B - Android frame animation execution method, device, terminal and readable medium - Google Patents

Android frame animation execution method, device, terminal and readable medium Download PDF

Info

Publication number
CN109062620B
CN109062620B CN201810862413.9A CN201810862413A CN109062620B CN 109062620 B CN109062620 B CN 109062620B CN 201810862413 A CN201810862413 A CN 201810862413A CN 109062620 B CN109062620 B CN 109062620B
Authority
CN
China
Prior art keywords
frame animation
information
handler
frame
animation
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
CN201810862413.9A
Other languages
Chinese (zh)
Other versions
CN109062620A (en
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201810862413.9A priority Critical patent/CN109062620B/en
Publication of CN109062620A publication Critical patent/CN109062620A/en
Application granted granted Critical
Publication of CN109062620B publication Critical patent/CN109062620B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • 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/4401Bootstrapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention discloses an Android frame animation execution method, an Android frame animation execution device, a terminal and a readable medium, wherein the method comprises the following steps: generating an Android frame animation by using a Handler mechanism, specifically, starting the frame animation according to a frame animation starting state message, executing the frame animation according to a frame animation executing state message, and updating a frame animation progress through a cycle timer in a Handler class to control pictures to be sequentially called from a picture set corresponding to the frame animation, so that the frame animation execution is realized; and in the frame animation executing process, the picture set corresponding to the frame animation can be changed according to the received frame animation change message. According to the Android frame animation execution method, device, terminal and readable medium provided by the embodiment of the invention, the frame animation content is dynamically changed in the frame animation execution process, so that the frame animation is executed more smoothly, and the user experience is improved.

Description

Android frame animation execution method, device, terminal and readable medium
Technical Field
The embodiment of the invention relates to a computer technology, in particular to an Android frame animation execution method, an Android frame animation execution device, a terminal and a readable medium.
Background
The frame animation provided by the embodiment of the invention can be understood as animation formed by adding different pictures on each frame of a time axis and continuously playing the pictures.
The existing Android frame animation is generally constructed by frame animation types carried by an Android system, and the content of the frame animation cannot be dynamically changed in the execution process of the frame animation. If the frame animation content modification message sent by the server is received in the frame animation execution process, only the current frame animation can be stopped, and the modified frame animation is started. For example, in the process of executing the frame animation of 24 frames, if an update message sent by the server and inserting a 4-frame picture at a certain position of the frame animation is received, the execution of the frame animation of the current 24 frames can only be stopped, a frame animation object of a frame animation class in which a 4-frame picture is inserted at the position is reconstructed, and the modified frame animation is started again. Therefore, in the frame animation executing process, if the frame animation content change message sent by the server is received, the frame animation is closed and restarted, so that the frame animation is jammed, and the user experience is reduced.
Disclosure of Invention
In view of this, embodiments of the present invention provide an Android frame animation execution method, an Android frame animation execution device, a terminal, and a readable medium, which implement that frame animation content is dynamically changed in a frame animation execution process, so that frame animation execution is smoother, and user experience is improved.
In a first aspect, an embodiment of the present invention provides an Android frame animation execution method, including:
s1, receiving an opening instruction, acquiring a first information object according to the opening instruction, initializing an information identifier of the first information object into a frame animation opening state, and sending the first information object after the information identifier is initialized to a message processing function of a Handler object;
s2, when the message processing function of the Handler object judges that the received information identifier of the first information object is in a frame animation starting state, acquiring a second information object, initializing the information identifier of the second information object into a frame animation executing state, and sending the second information object after the information identifier initialization to the message processing function of the Handler object;
s3, when the message processing function of the Handler object judges that the received information identification of the second information object is the frame animation execution state, defining the frame animation progress of the Handler object, and initializing the frame animation progress to 0;
s4, circularly sending the second information object after the information identifier initialization to the message processing function of the Handler object every other execution period of the frame animation;
s5, when the message processing function of the Handler object receives a second information object after the information identification initialization, updating the frame animation progress, calling the pictures in the picture set corresponding to the sequence value and the updated frame animation progress, and stopping sending the second information object after the information identification initialization until the updated frame animation progress is equal to the capacity value of the picture set;
when a frame animation change message is received in the frame animation execution process, whether a change condition is met is judged, and if yes, a picture set corresponding to the frame animation is changed according to the frame animation change message.
Optionally, the S1 includes:
s11, receiving a starting instruction, and calling an information obtaining method according to the starting instruction to obtain a first information object;
s12, calling an information identifier initialization method to initialize the information identifier of the first information object to a frame animation starting state value;
and S13, calling an empty message sending method of the Handler object to send the first information object after the information identifier is initialized to a message processing function of the Handler object.
Optionally, the S2 includes:
s21, when the message processing function of the Handler object judges that the received information mark of the first information object is in a frame animation opening state, calling an information acquiring method to acquire a second information object;
s22, calling an information identifier initialization method to initialize the information identifier of the second information object to a frame animation execution state value;
and S23, calling an empty message sending method of the Handler object to send the second information object after the information identifier is initialized to a message processing function of the Handler object.
Optionally, the calling a picture in which the sequence value corresponds to the updated frame animation progress in the picture set includes:
and calling a picture information calling method to call picture information of which the sequence value corresponds to the updated frame animation progress in the picture set, and calling a bitmap obtaining method to obtain a picture corresponding to the picture information.
Optionally, after the picture in which the sequence value corresponds to the updated frame animation progress in the called picture set, the method further includes:
and calling a bitmap destroying method to destroy the fetched picture corresponding to the animation schedule of the frame before updating.
Optionally, when a frame animation change message is received in the frame animation execution process, determining whether a change condition is satisfied, if so, changing a picture set corresponding to the frame animation according to the frame animation change message, including:
when a frame animation change message is received in the frame animation execution process, determining the change position and change information of a picture set corresponding to the frame animation according to the frame animation change message;
acquiring the animation progress of the current frame according to a preset protocol interface, and judging whether the animation progress of the current frame is in front of the change position;
and if so, changing the picture set corresponding to the frame animation according to the change message.
Optionally, before the step S1, the method further includes:
calling a Handler object definition method to define a Handler object of the Handler type, and rewriting a message processing function in the Handler object;
calling a constant definition method to define the execution period of the frame animation;
and calling a set definition method to define a picture set of the frame animation, and calling a picture information adding method to add picture information in the picture set.
In a second aspect, an embodiment of the present invention provides an Android frame animation executing apparatus, including:
the first information object sending module is used for receiving an opening instruction, acquiring a first information object according to the opening instruction, initializing an information identifier of the first information object into a frame animation opening state, and sending the first information object after the information identifier is initialized to a message processing function of a Handler object;
the second information object sending module is used for acquiring a second information object when the message processing function of the Handler object judges that the received information identifier of the first information object is in a frame animation starting state, initializing the information identifier of the second information object into a frame animation executing state, and sending the second information object after the information identifier initialization to the message processing function of the Handler object;
the frame animation progress initialization module is used for defining the frame animation progress of the Handler object and initializing the frame animation progress to 0 when the message processing function of the Handler object judges that the received information identifier of the second information object is in a frame animation execution state;
the second information object circulating sending module is used for circularly sending the second information object after the information identifier is initialized to a message processing function of the Handler object every other execution period of the frame animation;
the frame animation progress updating module is used for updating the frame animation progress when a message processing function of the Handler object receives a second information object after information identification initialization, calling a picture corresponding to a sequence value in the picture set and the updated frame animation progress, and stopping sending the second information object after the information identification initialization until the updated frame animation progress is equal to a capacity value of the picture set;
and the frame animation changing module is used for judging whether a changing condition is met or not when a frame animation changing message is received in the frame animation executing process, and if so, changing the picture set corresponding to the frame animation according to the frame animation changing message.
In a third aspect, an embodiment of the present invention provides a terminal, including:
one or more processors;
a memory for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors implement the Android frame animation execution method according to any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention provides a readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for executing an Android frame animation according to any embodiment of the present invention.
According to the Android frame animation execution method, device, terminal and readable medium, the Android frame animation is generated by using a Handler mechanism, and specifically, a first information object is obtained, an information identifier of the first information object is initialized, and then the first information object is sent to a message processing function of the Handler object; when the message processing function of the Handler object judges that the received information identifier of the first information object is in a frame animation opening state, acquiring a second information object, initializing the information identifier of the second information object, and sending the initialized information identifier to the message processing function of the Handler object; when the message processing function of the Handler object judges that the received information identifier of the second information object is in a frame animation execution state, defining the frame animation progress of the Handler object and initializing the progress to 0; circularly sending the second information object after the information identifier initialization to a message processing function of the Handler object every other execution period of the frame animation by using a Handler-like circular timer so as to control pictures to be sequentially called from a picture set corresponding to the frame animation, thereby realizing the execution of the frame animation; and in the frame animation executing process, the picture set corresponding to the frame animation can be changed according to the received frame animation change message. The dynamic change of the frame animation content in the frame animation execution process is realized, the frame animation is executed more smoothly, and the user experience is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of an Android frame animation execution method according to an embodiment of the present invention;
fig. 2 is a flowchart of S1 in an Android frame animation execution method according to an embodiment of the present invention;
fig. 3 is a flowchart of S2 in an Android frame animation execution method according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an Android frame animation execution device according to a second embodiment of the present invention;
fig. 5 is a schematic structural diagram of a terminal according to a third embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described through embodiments with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Fig. 1 is a flowchart of an Android frame animation execution method according to an embodiment of the present invention, where this embodiment is applicable to a situation where contents of a frame animation are dynamically changed in a frame animation execution process, and the method may be implemented by a terminal, and may specifically be implemented by software and/or hardware in the terminal.
Referring to fig. 1, the Android frame animation execution method includes the following steps:
s1, receiving an opening instruction, acquiring a first information object according to the opening instruction, initializing the information identifier of the first information object to be in a frame animation opening state, and sending the initialized information identifier of the first information object to a message processing function of the Handler object.
The opening instruction can be understood as an instruction for opening the Android frame animation and executing the frame animation; the starting instruction may be generated by pressing a physical key of the Android terminal, or by clicking a virtual key of a screen of the Android terminal, which is not specifically limited herein. The first information object may be a new message object or an instantiated object; the first information object may be an instantiated object, so as to reduce resource overhead for the system and improve system operation efficiency.
By acquiring the first information object and initializing the information identifier of the first information object, the processing message function of the Handler object can perform an animation opening operation according to the information identifier of the first information object after receiving the first information object, and the specific animation opening operation can be referred to in step S2.
Optionally, fig. 2 is a flowchart of S1 in the Android frame animation execution method according to the first embodiment of the present invention, where the flowchart includes:
and S11, receiving an opening instruction, and calling an information acquisition method according to the opening instruction to acquire the first information object.
The information obtaining method may specifically be:
1.Message msg10=new Message();
2.Message msg11=Message.obtain();
3.Message msg12=handler.obtainMessage();
the method 1 is to create a Message object, the method 2 is to return a Message instance from the whole Message pool, the Message object can be prevented from being repeatedly created through the Message.
The object () is a static method, and only when the Message pool is empty, a Message object is newly created, and if the Message pool is not empty, the Message objects are all instances taken from the Message pool, so that the Message objects are repeatedly used, the resource overhead of the system is reduced, and the system operation efficiency is improved.
And S12, calling an information identifier initialization method to initialize the information identifier of the first information object to the frame animation starting state value.
The information identifier initialization method may specifically be:
msg1.what=1;
wherein, 1 represents the value of the open state of the frame animation, and the value may also be a value corresponding to other preset open states of the frame animation, for example, 2, 3, 4, etc., and the information for identifying the first object information identifies the open state of the frame animation. By initializing the information identifier of the first information object to a value corresponding to a preset frame animation open state (namely, a frame animation open state value), when the message processing function of the Handler object receives the first information object, the frame animation open operation can be performed according to the information identifier of the first information object.
And S13, calling an empty message sending method of the Handler object to send the first information object after the information identifier is initialized to a message processing function of the Handler object.
The method for sending the air message of the Handler object may specifically be:
mHandler.sendEmptyMessage(msg1);
the msg1 is the name of the first information object, which is used to represent the first information object, and the name of the first information object may also be other names, and is not limited to msg 1; the mHandler is the name of a Handler object, the mHandler represents an object of a Handler class, and the name of the Handler object can be other names and is not limited to the mHandler; by adopting the sendEmptyMessage method, the first information object can be known to be a null message with the message identifier being the animation starting state value, and the speed of message transmission and processing can be increased by sending the null message, so that the animation execution efficiency is increased.
Through the method for sending the empty message of the Handler object, the first information object can be sent to the message processing function of the Handler object, so that the message processing function of the Handler object can successfully receive the first information object.
And S2, when the message processing function of the Handler object judges that the received information identifier of the first information object is in the frame animation starting state, acquiring a second information object, initializing the information identifier of the second information object to be in the frame animation executing state, and sending the second information object after the information identifier initialization to the message processing function of the Handler object.
After the message processing function of the Handler object receives the first information object, the information identifier of the received first information object may be determined, and when the information identifier of the first information object is in a frame animation open state, a frame animation open operation may be performed, where the frame animation open operation specifically may be:
and acquiring a second information object, initializing the information identifier of the second information object into a frame animation execution state, and sending the second information object after the information identifier is initialized to a message processing function of the Handler object.
By acquiring the second information object and initializing the information identifier of the second information object, the message processing function of the Handler object can perform a frame animation operation according to the information identifier of the second information object after receiving the second information object, and the specific frame animation operation can be performed in step S3.
Optionally, fig. 3 is a flowchart of S2 in the Android frame animation execution method according to the first embodiment of the present invention, where the flowchart includes:
and S21, when the message processing function of the Handler object judges that the received information identifier of the first information object is in the frame animation opening state, calling an information acquiring method to acquire a second information object.
The message processing function of the Handler object judges whether the received information identifier of the first information object is in a frame animation starting state, namely, the message processing function of the Handler object judges whether msg1.what of the first information object is in the frame animation starting state value, and if yes, the received information identifier of the first information object can be judged to be in the frame animation starting state.
The information acquiring method for acquiring the second information object is the same as the information acquiring method in step S11, specifically, see step S11, it is to be noted that the second information object is two different information objects from the first information object, and specifically, the object name of the second information object may be considered to be different from the object name of the first information object.
And S22, calling an information identifier initialization method to initialize the information identifier of the second information object to the frame animation execution state value.
The information tag initialization method is the same as the information tag initialization method in step S12, and particularly, referring to step S12, it should be noted that the information tag of the second information object is a frame animation executing state value, which is different from the information tag of the first information object being a frame animation open state value, and the frame animation executing state value and the frame animation open state value cannot be preset to the same value.
And S23, calling an empty message sending method of the Handler object to send the second information object after the information identifier is initialized to a message processing function of the Handler object.
The empty message sending method is consistent with the empty message sending method in step S13, and specifically, refer to step S13. Through the method for sending the empty message of the Handler object, the second information object can be sent to the message processing function of the Handler object, so that the message processing function of the Handler object can successfully receive the second information object.
And S3, when the message processing function of the Handler object judges that the received information mark of the second information object is the frame animation execution state, defining the frame animation progress of the Handler object and initializing the frame animation progress to 0.
After the message processing function of the Handler object receives the second information object, the information identifier of the received second information object may be determined, and when the information identifier of the second information object is a frame animation executing state, a frame animation executing operation may be executed, where the frame animation executing operation may specifically be: a frame animation progress of the Handler object is defined and initialized to 0. By defining the frame animation progress and initializing the frame animation progress to 0, the frame animation progress can be updated to control the pictures to be sequentially called from the picture set corresponding to the frame animation, so that the frame animation execution is realized.
And S4, circularly sending the second information object after the information identifier initialization to the message processing function of the Handler object every other execution period of the frame animation.
The animation execution period may be predefined, and may be understood as an update period of a frame animation progress, or may be understood as a period of a timer constructed by a Handler mechanism. The second information object is sent in a circulating mode every other frame animation execution period, so that the frame animation progress can be updated regularly, and the frame animation execution fluency is guaranteed.
Optionally, S4 specifically includes:
and calling an empty message delayed sending method loop of the Handler object to send the second information object after the information identifier initialization to a message processing function of the Handler object every other execution period of the frame animation.
The delayed sending method of the air message of the Handler object may specifically be:
mHandler.sendEmptyMessageDelay(msg2,ANIM_DURATION);
the msg2 is a name of the second information object, which is used to represent the second information object, and the name of the second information object may also be other names, and is not limited to msg 2; the ANIM _ DURATION is a name of an execution period of the frame animation, and is used for representing the execution period of the frame animation, and the name of the execution period of the frame animation may be other names, and is not limited to ANIM _ DURATION; the mHandler is the name of a Handler object, the mHandler represents an object of a Handler class, and the name of the Handler object can be other names and is not limited to the mHandler; by adopting the sendEmptyMessageDelay method, the second information object can be known to be a null message with the message identifier being the frame animation execution state value, and the speed of message transmission and processing can be increased by sending the null message, so that the animation execution efficiency is increased.
Through the delayed sending method of the empty message of the Handler object, the second information object can be circularly sent to the message processing function of the Handler object every other execution period of the frame animation, so that the message processing function of the Handler object can successfully receive the second information object every other execution period of the frame animation, and the frame animation progress is updated after the second information object is received, so that the frame animation can be normally executed.
S5, when the message processing function of the Handler object receives a second information object after the information identification initialization, updating the frame animation progress, calling the pictures in the picture set corresponding to the sequence value and the updated frame animation progress, and stopping sending the second information object after the information identification initialization until the updated frame animation progress is equal to the capacity value of the picture set;
when a frame animation change message is received in the frame animation execution process, whether a change condition is met is judged, and if yes, a picture set corresponding to the frame animation is changed according to the frame animation change message.
After the frame animation progress is defined and initialized, the second information object is circularly sent to the message processing function of the Handler object through the empty message delay sending method of the Handler object, so that the message processing function of the Handler object can successfully receive the second information object every other execution period of the frame animation, and the frame animation progress is added with 1 after the second information object is received.
The method comprises the steps of calling a picture corresponding to a sequence value and an updated frame animation progress in a picture set, wherein the picture can be understood as calling the nth picture in the picture set when the updated frame animation progress is n; the sequence value of the picture set is a positive integer starting from 0, so that the sequence value corresponding to the nth picture is n-1, that is, when the frame animation progress is n after updating, the picture with the sequence value of n-1 in the picture set is called.
And stopping sending the second information until the progress of the updated frame animation is equal to the capacity value of the picture set, and executing to finish the Android frame animation. For example, when the volume value of the picture set is 24, that is, the picture set corresponds to 24 pictures, the execution process of the frame animation may be understood as: if the frame animation progress is updated to 1, calling the 1 st picture from the picture set corresponding to the frame animation; if the frame animation progress is updated to be 2, calling the 2 nd picture from the picture set corresponding to the frame animation; and (4) calling the 24 th picture from the picture set corresponding to the frame animation every time the frame animation progress is increased by 1 until the frame animation progress is updated to be 24, thereby finishing the execution of the frame animation.
The volume value of the picture set may be understood as the size of the picture set, and may also be understood as the number of corresponding pictures contained in the picture set. The capacity value of the picture set can be obtained by calling the following method:
int i=listImageIds.Count;
the listImageIds is a name of the picture set, and is used for representing a predefined picture set, and the name of the picture set may be other names, and is not limited to the listImageIds; the method comprises the steps that a volume value of a picture set can be obtained through a Count method, and the volume value is assigned to a defined integer variable i; when the frame animation change message is received and the frame animation is changed according to the frame animation change message, the capacity value combined with the picture needs to be obtained again so as to ensure that the frame animation progress can be updated to the capacity value of the changed frame animation, and therefore the normal execution of the changed frame animation is ensured.
Optionally, the calling of the picture in which the sequence value corresponds to the updated frame animation progress in the picture set includes:
and calling a picture information calling method to call picture information of which the sequence value corresponds to the updated frame animation progress in the picture set, and calling a bitmap obtaining method to obtain a picture corresponding to the picture information.
Wherein, the picture information can be ID information of the picture; and each picture has a unique ID number corresponding to the picture in the Android system, so that the picture can be identified by the ID number of the picture. The picture ID is added to the picture set, so that the picture corresponding to the picture set is conveniently acquired, the memory overhead is greatly reduced, and the picture set can be maintained by maintaining the picture ID, so that the picture in the picture set is more favorably maintained.
The picture information calling method may specifically be:
listImageIds.get(index);
the listImageIds is a name of the picture set, and is used for representing a predefined picture set, and the name of the picture set may be other names, and is not limited to the listImageIds; wherein, index represents index number, and the index number can be specifically the value of frame animation progress minus 1 after updating in the execution process of frame animation; and acquiring the ID information of the pictures with the sequence values equal to the index numbers in the picture set by using a get method. By acquiring the picture ID information in the picture set, a bitmap acquisition method can be called to acquire the bitmap picture corresponding to the picture ID information.
The bitmap acquisition method may specifically be:
Bitmapfactory.DecodeResource(imageId);
the imageId is the name of the picture ID information and is used for representing the ID information of the picture, and the name of the picture ID information can be other names and is not limited to the imageId; acquiring a bitmap picture corresponding to the picture ID information by a DecodeResource method; the Bitmap is a Bitmap class, and after a Bitmap object named mBitmap in the Bitmap class is constructed, the Bitmap object can be understood as a Bitmap picture.
Optionally, after the picture with the sequence value corresponding to the updated frame animation progress in the picture set is called, the method further includes:
and calling a bitmap destroying method to destroy the fetched picture corresponding to the animation schedule of the frame before updating.
Because the called bitmap picture occupies a large memory, if the called picture is not destroyed in time, the situations of memory overflow, abnormal execution of frame animation and the like may occur. Therefore, after the pictures with the sequence values corresponding to the updated frame animation progress in the picture set are called, the previously called pictures can be preferably destroyed to release the memory and ensure the normal execution of the frame animation.
The bitmap destroying method may specifically be:
mBitmap.recycle();
the mBitmap is the name of the bitmap picture and is used for representing the bitmap picture, and the name of the bitmap picture can be other names and is not limited to the mBitmap; the memory occupied by the called bitmap picture can be recycled through the recycle method, so that the destroying operation of the called picture is realized.
Optionally, when a frame animation change message is received in the frame animation execution process, determining whether a change condition is satisfied, and if so, changing a picture set corresponding to the frame animation according to the frame animation change message, including:
when a frame animation change message is received in the frame animation execution process, determining the change position and the change information of a picture set corresponding to the frame animation according to the frame animation change message; acquiring the animation progress of the current frame according to a preset protocol interface, and judging whether the animation progress of the current frame is before the position is changed; and if so, changing the picture set corresponding to the frame animation according to the change message.
Wherein, the change position can be understood as a corresponding sequence value in the picture set which needs to be changed; the change information may include operation instructions such as addition, deletion, and replacement, and bitmap pictures and picture ID information corresponding to the operation instructions.
The protocol interface definition method may specifically be:
Figure BDA0001750027040000161
the method includes the following steps that IAnim is the name of a protocol interface and is used for representing the protocol interface, the name of the protocol interface can be other names, and the method is not limited to IAnim; the starting onStart, executing onsegress and ending onEnd states of the frame animation can be transmitted through the protocol interface; in the frame animation execution process, the progress parameter progressive value of the frame animation can be transmitted to a caller, so that the caller can obtain the progress state of the current frame animation execution, and selectively perform the frame animation updating operation according to the progress state.
The caller can inherit the protocol interface IAnim by means of instance, for example, it can be public class a instance IAnim, where a can refer to the type of the caller; after inheriting the interface IAnim, the protocol methods onStart, onsegress, and onEnd in the protocol may be overwritten, so that each execution state of the frame animation may be obtained.
When the caller initialization operation is performed, the caller registration can be performed in the information sender, and specifically, the caller mIAnim can be registered in the information sender by a register (iam mIAnim) registration method, so that the caller can acquire the execution state of the frame animation through the protocol interface.
If the current frame animation progress is before the change position, namely the frame animation execution flow does not reach the change position, the change operation can be carried out at the change position according to the change information; if the current frame animation progress is after the position is changed, that is, the frame animation execution flow has already executed the change position, the change operation can be performed at the change position according to the change information when the frame animation execution is finished. The changing of the picture set corresponding to the frame animation according to the change message may include operations of adding pictures, deleting pictures, replacing pictures, and the like at a change position.
Optionally, before S1, the method further includes:
calling a Handler object definition method to define a Handler object of the Handler type, and rewriting a message processing function in the Handler object; calling a constant definition method to define the execution period of the frame animation; and calling a set definition method to define a picture set of the frame animation, and calling a picture information adding method to add picture information in the picture set.
The method for calling the Handler object definition specifically may be:
Private Handler mHandler=new Handler(){
handleMessage(Message msg){
}
};
wherein, a Handler object can be defined through a new Handler method; the name of the Handler object is mHandler, and the name of the Handler object can be other names and is not limited to mHandler; the mHandler object duplicates a Handlemessage method in the mHandler object during definition, the parameter of the access to the handlemanessage method is an msg object of a Message type, and information can be transmitted and interacted by transmitting the msg object subsequently.
The method for calling the constant definition specifically may be:
public static final int ANIM_DURATION=42;
the ANIM _ DURATION is a name of an execution period of the frame animation, and is used for representing the execution period of the frame animation, and the name of the execution period of the frame animation may be other names, and is not limited to ANIM _ DURATION; wherein the execution period of the frame animation is of a global static integer type; wherein 42 indicates that the execution period of the frame animation is 42ms, and in general, the frame animation is 24 frames/s, and the execution period of the frame animation is 42ms, and the execution period of the frame animation may also be changed according to actual requirements, for example, if the fluency requirement is low, the execution period of the frame animation may be defined to be greater than 42ms, and if the fluency requirement is high, the execution period of the frame animation may be defined to be less than 42 ms.
The set definition method may specifically be:
List<Integer>listImageIds=new ArrayList<Integer>();
the listImageIds is a name of the picture set, and is used for representing a predefined picture set, and the name of the picture set may be other names, and is not limited to the listImageIds; the picture set type is an ArrayList type, and when the frame animation is changed, the capacity of the picture set of the type can be automatically expanded, so that the operations of adding the frame animation and the like are facilitated. The method for adding the picture information may specifically be a listimageids () method, and the picture information may be sequentially added to a picture set of the defined frame animation by an add method.
In the Android frame animation execution method provided by the embodiment, an Android frame animation is generated by using a Handler mechanism, and specifically, a message processing function for acquiring a first information object, initializing an information identifier of the first information object and sending the initialized information identifier to a Handler object is acquired; when the message processing function of the Handler object judges that the received information identifier of the first information object is in a frame animation opening state, acquiring a second information object, initializing the information identifier of the second information object, and sending the initialized information identifier to the message processing function of the Handler object; when the message processing function of the Handler object judges that the received information identifier of the second information object is in a frame animation execution state, defining the frame animation progress of the Handler object and initializing the progress to 0; circularly sending the second information object after the information identifier initialization to a message processing function of the Handler object every other execution period of the frame animation by using a Handler-like circular timer so as to control pictures to be sequentially called from a picture set corresponding to the frame animation, thereby realizing the execution of the frame animation; and in the frame animation executing process, the picture set corresponding to the frame animation can be changed according to the received frame animation change message. The dynamic change of the frame animation content in the frame animation execution process is realized, the frame animation is executed more smoothly, and the user experience is improved.
Example two
Fig. 4 is a schematic structural diagram of an Android frame animation execution device according to a second embodiment of the present invention, which is applicable to a case where frame animation content is dynamically changed in a frame animation execution process.
Referring to fig. 4, the Android frame animation execution device in this embodiment includes:
the first information object sending module 210 is configured to receive an opening instruction, obtain a first information object according to the opening instruction, initialize an information identifier of the first information object to a frame animation opening state, and send the initialized information identifier of the first information object to a message processing function of a Handler object;
the second information object sending module 220 is configured to, when the message processing function of the Handler object determines that the received information identifier of the first information object is in the frame animation enabled state, obtain the second information object, initialize the information identifier of the second information object to be in the frame animation executing state, and send the initialized information identifier of the second information object to the message processing function of the Handler object;
a frame animation progress initialization module 230, configured to define a frame animation progress of the Handler object and initialize the frame animation progress to 0 when the message processing function of the Handler object determines that the received information identifier of the second information object is a frame animation execution state;
a second information object cyclic sending module 240, configured to send the second information object after the information identifier is initialized to a message processing function of the Handler object cyclically every other execution period of the frame animation;
the frame animation progress updating module 250 is configured to update the frame animation progress when the message processing function of the Handler object receives a second information object after initialization of the information identifier, call a picture in the picture set, where the sequence value corresponds to the updated frame animation progress, and stop sending the second information object after initialization of the information identifier until the updated frame animation progress is equal to the capacity value of the picture set;
and the frame animation changing module 260 is configured to, when a frame animation changing message is received in a frame animation executing process, determine whether a changing condition is met, and if so, change the picture set corresponding to the frame animation according to the frame animation changing message.
Optionally, the first information object sending module 210 includes:
and the first information object acquisition submodule is used for receiving the opening instruction and calling an information acquisition method according to the opening instruction to acquire the first information object.
And the first information object information identifier initialization submodule is used for calling an information identifier initialization method to initialize the information identifier of the first information object to the frame animation starting state value.
And the first information object sending submodule is used for calling an air message sending method of the Handler object and sending the first information object after the information identifier is initialized to a message processing function of the Handler object.
Optionally, the second information object sending module 220 includes:
and the second information object acquisition submodule is used for calling an information acquisition method to acquire the second information object when the message processing function of the Handler object judges that the received information identifier of the first information object is in the frame animation opening state.
And the second information object information identification initialization submodule is used for calling an information identification initialization method to initialize the information identification of the second information object to the frame animation execution state value.
And the second information object sending submodule is used for calling an air message sending method of the Handler object and sending the second information object after the information identifier is initialized to a message processing function of the Handler object.
Optionally, the second information object cyclic sending module 240 is specifically configured to:
and calling an empty message delayed sending method loop of the Handler object to send the second information object after the information identifier initialization to a message processing function of the Handler object every other execution period of the frame animation.
Optionally, the frame animation progress updating module 250 is specifically configured to:
and calling a picture information calling method to call picture information of which the sequence value corresponds to the updated frame animation progress in the picture set, and calling a bitmap obtaining method to obtain a picture corresponding to the picture information.
Optionally, the frame animation progress updating module 250, after the picture corresponding to the updated frame animation progress and the sequence value in the picture set is called, is further specifically configured to:
and calling a bitmap destroying method to destroy the fetched picture corresponding to the animation schedule of the frame before updating.
Optionally, the frame animation change module 260 includes:
the frame animation execution sub-module is used for executing frame animation execution on the basis of the frame animation information, and determining the change position and the change information of the picture set corresponding to the frame animation according to the frame animation information;
the judging submodule is used for acquiring the current frame animation progress according to a preset protocol interface and judging whether the current frame animation progress is before the position is changed;
and the frame animation changing submodule is used for changing the picture set corresponding to the frame animation according to the changing message if the frame animation changing submodule is used for changing the picture set corresponding to the frame animation according to the changing message.
Optionally, the Android frame animation executing apparatus further includes:
the Handler object definition module is used for calling a Handler object definition method to define a Handler object of the Handler type and rewriting a message processing function in the Handler object;
the execution cycle definition module is used for calling a constant definition method to define the execution cycle of the frame animation;
and the picture set definition module is used for calling a set definition method to define the picture set of the frame animation and calling a picture information adding method to add the picture information in the picture set.
The Android frame animation execution device provided in this embodiment is the same as the Android frame animation execution method provided in the first embodiment, and the technical details that are not described in detail in this embodiment may be referred to in the first embodiment.
EXAMPLE III
The embodiment provides a terminal which can be used for the situation that the content of the frame animation is dynamically changed in the execution process of the frame animation. Fig. 5 is a schematic structural diagram of a terminal according to a third embodiment of the present invention. Referring to fig. 5, the terminal includes:
one or more processors 310;
a memory 320 for storing one or more programs;
when the one or more programs are executed by the one or more processors 310, the one or more processors 310 are enabled to implement the Android frame animation execution method as set forth in the first embodiment.
In FIG. 5, a processor 310 is illustrated; the processor 310 and the memory 320 may be connected by a bus or other means, such as the bus connection in fig. 5.
The memory 320 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the Android frame animation execution method in the embodiment of the present invention. The processor 310 executes various functional applications and data processing of the terminal by running software programs, instructions and modules stored in the memory 320, that is, implements the above-described Android frame animation execution method.
The memory 320 may mainly include a program storage area and a data storage area, wherein the program storage 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 memory 320 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 memory 320 may further include memory located remotely from the processor 310, which may be connected to the terminal 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 terminal and the Android frame animation execution method provided by the first embodiment belong to the same inventive concept, and technical details not described in detail in the first embodiment can be referred to in the first embodiment, and the first embodiment have the same beneficial effects.
Example four
The present embodiment provides a readable medium, on which a computer program is stored, and when the computer program is executed by a processor, the method for executing an Android frame animation according to an embodiment of the present invention is implemented.
The readable medium provided by the embodiment and the Android frame animation execution method provided by the first embodiment belong to the same inventive concept, and technical details not described in detail in the embodiment can be referred to the first embodiment, and the first embodiment have the same beneficial effects.
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 can 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 methods according to the embodiments of the present invention.
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. An Android frame animation execution method is characterized by comprising the following steps:
s1, receiving an opening instruction, acquiring a first information object according to the opening instruction, initializing an information identifier of the first information object into a frame animation opening state, and sending the first information object after the information identifier is initialized to a message processing function of a Handler object;
s2, when the message processing function of the Handler object judges that the received information identifier of the first information object is in a frame animation starting state, acquiring a second information object, initializing the information identifier of the second information object into a frame animation executing state, and sending the second information object after the information identifier initialization to the message processing function of the Handler object;
s3, when the message processing function of the Handler object judges that the received information identification of the second information object is the frame animation execution state, defining the frame animation progress of the Handler object, and initializing the frame animation progress to 0;
s4, circularly sending the second information object after the information identifier initialization to the message processing function of the Handler object every other execution period of the frame animation;
the execution period is predefined and comprises an update period of the frame animation progress and/or a period of a timer constructed through a Handler mechanism;
s5, when the message processing function of the Handler object receives a second information object after the information identification initialization, updating the frame animation progress, calling the pictures corresponding to the sequence value and the updated frame animation progress in the picture set corresponding to the frame animation, and stopping sending the second information object after the information identification initialization until the updated frame animation progress is equal to the capacity value of the picture set;
when a frame animation change message is received in the frame animation execution process, whether a change condition is met is judged, and if yes, a picture set corresponding to the frame animation is changed according to the frame animation change message.
2. The method according to claim 1, wherein the S1 includes:
s11, receiving a starting instruction, and calling an information obtaining method according to the starting instruction to obtain a first information object;
s12, calling an information identifier initialization method to initialize the information identifier of the first information object to a frame animation starting state value;
and S13, calling an empty message sending method of the Handler object to send the first information object after the information identifier is initialized to a message processing function of the Handler object.
3. The method according to claim 1, wherein the S2 includes:
s21, when the message processing function of the Handler object judges that the received information mark of the first information object is in a frame animation opening state, calling an information acquiring method to acquire a second information object;
s22, calling an information identifier initialization method to initialize the information identifier of the second information object to a frame animation execution state value;
and S23, calling an empty message sending method of the Handler object to send the second information object after the information identifier is initialized to a message processing function of the Handler object.
4. The method according to claim 1, wherein the calling of the pictures in the picture set, the sequence values of which correspond to the progress of the frame animation after updating, comprises:
and calling a picture information calling method to call picture information of which the sequence value corresponds to the updated frame animation progress in the picture set, and calling a bitmap obtaining method to obtain a picture corresponding to the picture information.
5. The method according to claim 1, wherein after the picture in the picture set is called, the picture with the sequence value corresponding to the progress of the updated frame animation further comprises:
and calling a bitmap destroying method to destroy the fetched picture corresponding to the animation schedule of the frame before updating.
6. The method of claim 1, wherein when a frame animation change message is received during execution of a frame animation, determining whether a change condition is satisfied, and if so, changing a picture set corresponding to the frame animation according to the frame animation change message comprises:
when a frame animation change message is received in the frame animation execution process, determining the change position and change information of a picture set corresponding to the frame animation according to the frame animation change message;
acquiring the animation progress of the current frame according to a preset protocol interface, and judging whether the animation progress of the current frame is in front of the change position;
and if so, changing the picture set corresponding to the frame animation according to the change message.
7. The method according to claim 1, prior to the S1, further comprising:
calling a Handler object definition method to define a Handler object of the Handler type, and rewriting a message processing function in the Handler object;
calling a constant definition method to define the execution period of the frame animation;
and calling a set definition method to define a picture set of the frame animation, and calling a picture information adding method to add picture information in the picture set.
8. An Android frame animation execution device, comprising:
the first information object sending module is used for receiving an opening instruction, acquiring a first information object according to the opening instruction, initializing an information identifier of the first information object into a frame animation opening state, and sending the first information object after the information identifier is initialized to a message processing function of a Handler object;
the second information object sending module is used for acquiring a second information object when the message processing function of the Handler object judges that the received information identifier of the first information object is in a frame animation starting state, initializing the information identifier of the second information object into a frame animation executing state, and sending the second information object after the information identifier initialization to the message processing function of the Handler object;
the frame animation progress initialization module is used for defining the frame animation progress of the Handler object and initializing the frame animation progress to 0 when the message processing function of the Handler object judges that the received information identifier of the second information object is in a frame animation execution state;
the second information object circulating sending module is used for circularly sending the second information object after the information identifier is initialized to a message processing function of the Handler object every other execution period of the frame animation;
the execution period is predefined and comprises an update period of the frame animation progress and/or a period of a timer constructed through a Handler mechanism;
the frame animation progress updating module is used for updating the frame animation progress when a message processing function of the Handler object receives a second information object after information identification initialization, calling pictures corresponding to the sequence value in the picture set corresponding to the frame animation and the updated frame animation progress, and stopping sending the second information object after the information identification initialization until the updated frame animation progress is equal to the capacity value of the picture set;
and the frame animation changing module is used for judging whether a changing condition is met or not when a frame animation changing message is received in the frame animation executing process, and if so, changing the picture set corresponding to the frame animation according to the frame animation changing message.
9. A terminal, characterized in that the terminal comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the Android frame animation execution method of any of claims 1-7.
10. A readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the Android frame animation execution method of any of claims 1-7.
CN201810862413.9A 2018-08-01 2018-08-01 Android frame animation execution method, device, terminal and readable medium Active CN109062620B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810862413.9A CN109062620B (en) 2018-08-01 2018-08-01 Android frame animation execution method, device, terminal and readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810862413.9A CN109062620B (en) 2018-08-01 2018-08-01 Android frame animation execution method, device, terminal and readable medium

Publications (2)

Publication Number Publication Date
CN109062620A CN109062620A (en) 2018-12-21
CN109062620B true CN109062620B (en) 2021-07-23

Family

ID=64832474

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810862413.9A Active CN109062620B (en) 2018-08-01 2018-08-01 Android frame animation execution method, device, terminal and readable medium

Country Status (1)

Country Link
CN (1) CN109062620B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134392B (en) * 2019-04-30 2022-08-09 延锋伟世通电子科技(南京)有限公司 Kanzi-based sequence frame animation playing method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103544729A (en) * 2013-09-24 2014-01-29 Tcl集团股份有限公司 Animation data processing method and system
CN104268916A (en) * 2014-09-10 2015-01-07 北京金山安全软件有限公司 View drawing method and device and mobile terminal
CN107589962A (en) * 2016-07-14 2018-01-16 广州市动景计算机科技有限公司 A kind of method for displaying user interface and device

Also Published As

Publication number Publication date
CN109062620A (en) 2018-12-21

Similar Documents

Publication Publication Date Title
CN108023808B (en) Message distribution method and device in application program
AU2019233201B2 (en) Resource configuration method and apparatus, terminal, and storage medium
CN110493067B (en) Method and device for updating API gateway service
CN107766101B (en) Method, device and equipment for processing App starting event
CN112118459A (en) Method for realizing common live broadcast of multiple apps by sharing camera data and readable medium
US20240111549A1 (en) Method and apparatus for constructing android running environment
CN109213462B (en) Android horizontal and vertical screen data synchronization method and device, terminal and readable medium
CN105955792B (en) Start control method, device and equipment
EP4210053A1 (en) Application program control method and apparatus, electronic device, and storage medium
CN108008950B (en) Method and device for realizing user interface updating
CN105653934B (en) Mobile terminal and application protection method thereof
WO2016045082A1 (en) Policy implementation method, device and system
CN106843977B (en) A kind of processing method, device and the mobile terminal of application program self-starting
CN109086115B (en) Android animation execution method, device, terminal and readable medium
CN109062620B (en) Android frame animation execution method, device, terminal and readable medium
CN107515792B (en) Method and device for processing message by using function class Handler
CN109062650B (en) Bullet screen message distribution method, device, equipment and storage medium
CN108810633B (en) Barrage message transmission method, device, equipment and storage medium
CN110045997B (en) Object initialization method, device, equipment and storage medium of basic function module
CN110324722B (en) Method, device, equipment and storage medium for acquiring data in live broadcast room
CN106874010B (en) Method for rapid page loading of ListView in Android system
CN109274988B (en) Bullet screen message distribution method, device, equipment and storage medium
CN109144638B (en) Android horizontal and vertical screen data synchronization method and device, terminal and readable medium
CN109144520B (en) Information interaction method, device, equipment and storage medium among different objects in Android
CN109064531B (en) Android animation execution method and device, terminal and readable 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