CN110333920B - Method and related device for updating icon - Google Patents

Method and related device for updating icon Download PDF

Info

Publication number
CN110333920B
CN110333920B CN201910379077.7A CN201910379077A CN110333920B CN 110333920 B CN110333920 B CN 110333920B CN 201910379077 A CN201910379077 A CN 201910379077A CN 110333920 B CN110333920 B CN 110333920B
Authority
CN
China
Prior art keywords
view
mimageview
icon
layout
function
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
CN201910379077.7A
Other languages
Chinese (zh)
Other versions
CN110333920A (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 CN201910379077.7A priority Critical patent/CN110333920B/en
Publication of CN110333920A publication Critical patent/CN110333920A/en
Application granted granted Critical
Publication of CN110333920B publication Critical patent/CN110333920B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/017Gesture based interaction, e.g. based on a set of recognized hand gestures
    • 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

Abstract

The embodiment of the application discloses a method and a related device for updating an icon, which are used for improving the display effect of updating the icon and increasing the convenience of updating the icon. The method in the embodiment of the application comprises the following steps: defining a view container class MyContainer which inherits a linear layout Linear layout container in an Android system; constructing an object mImageView, wherein the object mImageView completely fills a space of a MyContainer layout of a view container class, and is a container object for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation; receiving a first gesture operation aiming at a target mImageView, wherein the first gesture operation is used for indicating an updating operation on the content in the target mImageView, and the updating operation comprises adding an icon or removing the icon; in response to the first gesture operation, putting an icon view in a view set listView into an object mImageView, wherein the view set listView is used for storing the icon currently displayed; the contents of the updated object mImageView are placed into the view container class MyContainer.

Description

Method and related device for updating icon
Technical Field
The present application relates to the field of live broadcast platform development, and in particular, to a method for updating an icon and a related device.
Background
In the development process of a live broadcast room, display spaces of a plurality of icon pendants exist, the icon pendants can be displayed in the same display area, namely the positions of the icon pendants can be the same or different, and mutually exclusive service logic relations can exist among some icon pendants. In the traditional scheme, a large number of service logic functions are written to solve the mutual exclusion relationship between icon pendants. However, as the number of icon pendants increases, maintenance difficulties and costs increase.
In the prior art, a control recycleView in an Android system is used for bearing a display space of an icon pendant, however, in the prior art, icons are displayed through the control recycleView, when the icon pendant is deleted or added, all the icon pendants can be refreshed, performance is greatly lost, and therefore a flashing screen is caused, and the display effect is poor.
Disclosure of Invention
The embodiment of the application provides a method and a related device for updating an icon, which are used for improving the display effect of updating the icon and increasing the convenience of updating the icon.
A first aspect of the embodiments of the present application provides a method for updating an icon, which is applied to an Android system, and includes: defining a view container class MyContainer that inherits a Linear layout container in the Android system; constructing an object mImageView, wherein the object mImageView completely fills a space of the MyContainer layout of the view container class, and is a container object for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation; receiving a first gesture operation aiming at the object mImageView, wherein the first gesture operation is used for indicating that an updating operation is performed on the content in the object mImageView, and the updating operation comprises an icon addition or an icon removal; in response to the first gesture operation, putting an icon view in a view set listView into the object mImageView, wherein the view set listView is used for storing an icon currently being displayed; and putting the updated content in the object mImageView into the view container class MyContainer.
In one possible embodiment, the defining the view container class MyContainer includes: defining the view container class MyContainer by a statement public class MyContainer extensions LinearLayout; and respectively setting the width and the height of the view label of the view container class MyContainer as a dp and b dp by calling a function android, width and height of which are a dp and b dp.
In a possible embodiment, the building of the object mlageview and the completely filling the space of the view container class MyContainer layout with the object mlageview comprises: constructing the object mImageView by calling a function mImageView ═ new ImageView (); constructing a layout object layout params by calling a function layout. Calling a function layout paramas, width of which is linear layout, layout param, match _ part to set the width of the layout object layout params to fill a PARENT layout, and a function layout paramas, height of which is linear layout, layout param, match _ part to set the height of the layout object layout to fill the PARENT layout, the PARENT layout being a space of the view container class MyContaine layout, respectively; setlayout objects are set into the object mImageView by calling a function mImageView. setLayoutParams (layoutParams) so that the object mImageView completely fills the space of the view container class MyContainer layout.
In a possible embodiment, when the update operation is adding an icon, before the icon view in the view set listView is put into the object mlageview, the method further includes: judging whether the icon to be newly added indicated by the updating operation is an empty null object or not; if the icon to be newly added is not an empty object, judging whether the icon to be newly added exists in the view set listView; if the icon to be newly added does not exist in the view set listView, adding the icon to be newly added into the view set listView by calling a function listView.add (), wherein an input parameter of the function listView.add () is the icon to be newly added.
In a possible embodiment, when the update operation is deleting an icon, before the placing an icon view in the view set listView into the object mlageview, the method further includes: judging whether the icon to be removed indicated by the updating operation is an empty null object or not; if the icon to be removed is not an empty object, judging whether the icon to be newly added exists in the view set listView; if the icon to be removed exists in the view set listView, deleting the icon to be removed in the view set listView by calling a function listView remove (), wherein an input parameter of the function listView remove () is the icon to be removed.
In one possible embodiment, the setting a gesture listener for the subject mlimageview comprises: setontouchlink (this) sets the gesture listener for the subject mImageView by calling the function mImageView.
In a possible embodiment, the placing the updated contents of the object mlimageview into the view container class MyContainer includes: and putting the content of the updated object mImageView into the view container class MyContainer by calling a function addView (mImageView), wherein the function addView () is a public function, the input parameter of the function addView () is a ViewGroup type, and the return value of the addView () is a void type.
A second aspect of an embodiment of the present application provides an update apparatus, including: the system comprises a defining unit, a judging unit and a judging unit, wherein the defining unit is used for defining a view container type MyContainer which inherits a linear layout Linear layout container in the Android system; the object mImageView is used for constructing an object mImageView, completely fills a space of the MyContainer layout of the view container class, and is a container object used for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation; a receiving and sending unit, configured to receive a first gesture operation for the subject mImageView, where the first gesture operation is used to instruct to perform an update operation on content in the subject mImageView, and the update operation includes adding an icon or removing an icon; a placing unit, configured to, in response to the first gesture operation, place an icon view in a view set listView into the object mImageView, where the view set listView is used to store an icon currently being displayed; and putting the updated content in the object mImageView into the view container class MyContainer.
A third aspect of the application provides an electronic device comprising a memory and a processor, wherein the processor is configured to implement the steps of the method according to any one of the above when executing a computer management class program stored in the memory.
A fourth aspect of the present application provides a computer-readable storage medium having a computer management-like program stored thereon, characterized in that: the computer management like program when executed by a processor performs the steps of the method as described in any one of the above.
According to the technical scheme, the embodiment of the application has the following advantages: defining a view container class MyContainer that inherits a Linear layout container in the Android system; constructing an object mImageView, wherein the object mImageView completely fills a space of the MyContainer layout of the view container class, and is a container object for containing and displaying a view; setting a gesture listener for the object mImageView so that the object mImageView recognizes a gesture operation; receiving a first gesture operation aiming at the object mImageView, wherein the first gesture operation is used for indicating that an updating operation is performed on the content in the object mImageView, and the updating operation comprises an icon addition or an icon removal; in response to the first gesture operation, placing an icon view in a view set listView into the object mImageView, wherein the view set listView is used for storing an icon currently displayed; and putting the updated content in the object mImageView into the view container class MyContainer. In the embodiment of the application, the customized view container MyContainer has the characteristic of a linear layout container, the function similar to recycleView is realized, when the icon is replaced in the icon container, the operation of refreshing all views is not needed, a data adapter is not needed, the display effect when the icon is updated is improved, and the convenience of updating the icon is increased.
Drawings
FIG. 1 is a flowchart of a possible method for updating an icon according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a possible updating apparatus according to an embodiment of the present disclosure;
fig. 3 is a schematic diagram of a hardware structure of a possible electronic device according to an embodiment of the present disclosure;
fig. 4 is a schematic hardware structure diagram of a possible computer-readable storage medium according to an embodiment of the present disclosure.
Detailed Description
The embodiment of the application provides a method and a related device for updating an icon, which are used for improving the display effect of updating the icon and increasing the convenience of updating the icon.
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. 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 application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The application provides a method for updating an icon, and in order to better understand the method, another possible method for updating the icon is provided, which specifically comprises the following steps:
step 1, defining a container management class ContainerManager, defining an object mConnitainermager of the ContainerManager type in the container management class ContainerManager, and defining the object mConnitainermager as a static (static) object in order to make the whole application program have one and only one object mConnitainermager.
Step 2, in order to acquire and initialize the object mConnitainerManager, the object mConnitainerManager is instantiated by calling a constructor of a container management class ContainermManager class. It should be noted that, in order to prevent the constructor from being called by other functions, the constructor is set to have a private (private) access right, so that the constructor cannot be called by the outside, and it is ensured that the outside cannot perform instantiation operation on the object mContainerManager. However, we need to provide a method for obtaining the object mContainerManager to the outside world, so a function for obtaining the object mContainerManager needs to be designed, and the specific implementation function is defined as follows:
Public static ContainerManager getContainerManager()
{Return mContainerManager;}
wherein, the function getContainerManager () is used to obtain the object mContainerManager, which is a public (public) function, and public can modify a class to represent a common access authority, so that other functions have the authority to call the function getContainerManager (). Meanwhile, in order to facilitate the call of the function directly through the class and not through the object, the getContainermanager () function is set as a static (static) function. In this way, the outside cannot directly obtain the object of the container management class ContainerManager, and can only call the object by a static function to obtain the object mContainerManager.
And 3, defining a view set listView in a container management class Containermanager, wherein the view set listView is used for storing the information of the view icon currently displayed. The function implementation of the definition method of the view set listView specifically comprises the following steps:
Private List<View>listView=new ArrayList<View>();
the view set listView is of a Private (Private) type, the Private is used for modifying class members and representing access control, and the member modified by the Private represents that the members can only be accessed inside the class. After defining a view set listView, performing initialization operation on the view set listView, wherein the view set listView is mainly used for storing icon content information currently displayed.
Step 4, it should be noted that in the present solution, the display logic of the whole icon is loaded and displayed through a recycleView control of the system, and the container for accommodating the view is implemented by setting the sliding direction of recycleView to be horizontal sliding and setting the window size of the recycleView control to be the size of one icon. Specifically, when recycleView is used, the height is also kept consistent with the height of recycleView by calling the function setOrientation (linear layout manager. horizontal) to set the sliding direction thereof as a lateral sliding, and setting the width of the sub-view in recycleView to width (where the width size and the width of recycleView are consistent).
Step 5, dynamically updating the content information of the view in the icon container through the operation of adding and removing the view into the object mContainermanager, wherein the specific implementation mode of adding and removing the view comprises the following steps:
adding icon information;
defining a function addView () for adding view in a container management class ContainerManager, wherein the specific function definition method comprises the following steps: the method comprises the following steps that Public void addView (View), wherein the function addView () is a Public (Public) type function, the return value of the function addView () is a void type return type, and in order to be compatible with complex views, the input parameter of the function addView () is set to be the view of the View group type. Within the addView () function, first, it needs to determine whether a view is a null object by a view ═ null manner; if the object is empty, the whole adding process is ended by calling a return method; if the view is not a null object, judging whether a view set listView contains the view object or not by calling a function listView. If the view set listView already contains the view object, a function return is called to finish the whole process; add a view to the view set listView by calling the function listView.
Then, a new data adapter object AdapterView needs to be constructed through the view set listView, the data adapter object AdapterView is used for carrying out data filling on recycleView, and the specific construction method is constructed by calling a function AdapterView which is new AdapterView (listView). And then, filling the view object into the recycleView by calling a function, setAddView, method, and informing the logic of the change of the view of the recycleView by calling a function, adaptView, notification (), so that the view in the recycleView can be refreshed.
Moving out the icon information;
firstly, a shift-out function removeView () is defined, and the specific function definition method is as follows: public void removeView (View), wherein the remove function removeView () is a function of a common type, the return value of which is a void type return type, and similarly to the function addView (), the input argument of the remove function removeView () is also a view of a ViewGroup type. And the method similar to the method for adding icon information is adopted to perform empty logic judgment on the view and check whether the data contains, and the detailed description is omitted here. It can be understood that, if the view set listView contains the view object, the view object is removed from the view set listView by calling a function listView. Otherwise a return is made through the function return to terminate execution of the program flow. After the view object is removed, the data content information in recycleView is refreshed by constructing a new AdapterView object and calling an AdapterView notification () method.
However, in the above scheme, the View object of the icon is borne by recycleView in an Android system, and in View of the fact that the performance is greatly lost due to refreshing of content data of recycleView and the possibility of screen flashing is brought, and the recycleView is relatively troublesome to use, and is not convenient and fast, an embodiment of the present application provides a method for updating the icon, please refer to fig. 1, which provides a flowchart of a method for updating the icon according to an embodiment of the present application, and specifically includes:
101. defining a view container class MyContainer;
first, a view container type MyContainer is defined, and the view container type MyContainer is made to integrate a linear layout (LinearLayout) container of the Android system by means of extensions. Specifically, the view container class MyContainer may be defined by a public class statement, wherein public may modify a class to represent public access rights, and specifically defining an implementation function of the view container class MyContainer includes:
public class MyContainer extends LinearLayout;
then, defining a view label of the view container class MyContainer through an XML label in the view layout file XML, setting a width and a height for the view container class MyContainer when defining the view label, and specifically, setting the width and the height of the view label of the view container class MyContainer as a dp and b dp respectively by calling a function android, wherein width is equal to "a dp" and function android, height is equal to "b dp". It should be noted that, in different application scenarios, values of a and b are different, for example, in practical application, a may be set to 100, and b may be set to 50, or a and b are other parameters, and are not limited herein.
102. Constructing an object mImageView;
when a view needs to be added into a view container class MyContainer, an object mImageView of an ImageView type needs to be dynamically constructed, wherein the ImageView is a container object which can contain the view and is provided by an android system, and the main function of the object mImageView is to display pictures. Specifically, the object mImageView is constructed by calling the function ImageView new ImageView ().
In the construction process, the size information of the object mImageView is required to be set, so that the object mImageView completely fills the space of the MyContainer layout of the view container class. The size of the object mImageView is specifically set as follows: first, a layout object layout paramas is constructed, and since the view container type MyContainer is a container of the linear layout type, the type of the layout object is also linear layout. Then, the size of the layout object layout paramas is set, specifically, the width of the layout function is set by calling the function layout paramas. Similarly, the height of the layout function is set by calling the function youtpramas, layout paramas, match _ part to fill the PARENT layout, so that the layout object layout paramas can completely occupy the content space of the PARENT layout.
After the size of the layout object layout paramas is set, the layout object layout paramas is set into the object mImageView by calling a function mImageView, setLayoutParams (layout paramas) in the object mImageView, so that the object mImageView can completely fill the space size of the MyContainer layout. Therefore, the object mImageView constructed by the embodiment of the application realizes the complete filling of the space of MyContainer layout, and the display effect of the icon pendant is improved.
103. Setting a gesture listener for the object mImageView so that the object mImageView recognizes gesture operation;
it should be noted that, after the object mImageView is constructed, a function addView (mImageView) is called to fill the content in the object mImageView into the view container MyContainer, so that the object mImageView occupies the size of the entire view container MyContainer, but since the object mImageView just constructed is not filled with any content information, a transparent area is displayed, that is, no content information is displayed on the interface. Therefore, in the embodiment of the present application, views may be filled in the view set listView through the function addView (), for convenience of description, the filled views are referred to as icon views, and specifically, filling views in the view set listView includes: defining a function addView () of adding view, wherein the specific function defining method comprises the following steps: the method comprises the following steps that Public void addView (View), wherein the function addView () is a Public (Public) type function, the return value of the function addView () is a void type return type, and in order to be compatible with complex views, the input parameter of the function addView () is set to be the view of the View group type. Within the addView () function, first, it needs to determine whether the next icon view is a null object by means of the view ═ null mode; if the object is empty, the whole adding process is ended by calling a return method; if the view is not a null object, judging whether the view set listView contains the icon view by calling a function listView. If the view set listView already contains the icon view, a function return is called to finish the whole process; and if the view set listView does not contain the icon view, adding the icon view into the view set listView by calling a function listView.
Therefore, after the icon view is filled in the view set listView through the function addView (), data exists in the view set listView, and the icon view in the view set listView is filled in the object mImageView by adjusting a function mImageView.
However, since the object imageView is a static icon, when the user slides the icon, the sliding effect does not occur, and therefore a gesture listener needs to be set for the object mImageView, so that the object mImageView recognizes the gesture operation. Specifically, a gesture listener is set for the object mlimageview by calling a function mlimageview.
104. Receiving a first gesture operation for a subject mImageView;
105. in response to the first gesture operation, putting an icon view in the view set listView into an object mImageView;
106. the contents of the updated object mImageView are placed into the view container class MyContainer.
When a user needs to perform an update operation on the content in the object mImageView, performing the update operation by indicating a first gesture operation of the object mImageView, wherein the update operation may be an icon addition or icon removal, and the first gesture operation may be a sliding operation or other operations, which is not limited herein. Specifically, after a first gesture operation for the mImageView is received, a next icon view is taken out from the view set listView in response to the first gesture operation, and the icon view is filled in the mImageView object, so that a method for replacing the content in the mImageView during sliding is achieved, and the purpose of sliding and replacing the icon is achieved.
Specifically, when the updating operation is used for adding the icon, whether the icon to be newly added indicated by the updating operation is an empty null object is judged; if the icon to be newly added is not an empty object, judging whether the icon to be newly added exists in the listView set; if the icon to be newly added does not exist in the view set listView, the icon to be newly added is added into the view set listView by calling a function listView.
When the updating operation is used for removing the icon, judging whether the icon to be removed indicated by the updating operation is an empty null object; if the icon to be removed is not a null object, judging whether an icon to be newly added exists in the view set listView; if the icon to be removed exists in the view set listView, deleting the icon to be removed in the view set listView by calling a function listView remove (), wherein an input parameter of the function listView remove () is the icon to be removed.
Therefore, the icon view in the view set listView with the added or deleted icon is placed in the object mImageView, that is, the function of the recycleView control for bearing the display logic for displaying the whole icon is realized in the self-defined view container MyContainer, and when data content is updated relative to the recycleView control, all views are continuously refreshed to cause the operation of a flash screen. Meanwhile, in the prior art, a data adapter object AdapterView needs to be constructed to fill or remove data of the recycleView control, the data adapter object AdapterView is relatively troublesome to use and is not convenient and fast, and the embodiment of the application has no series of operations such as a data adapter, so that the whole operation convenience is better than that of the recycleView control.
In some practical application scenarios, a long-time display of an individual icon may be required, that is, the display duration of the icon is customized according to requirements, so the embodiment of the present application further provides a method for displaying a view object, so that the display of the view object is more flexible and automated, and the method specifically includes the following steps:
step 1, defining a data structure class;
in order to meet the requirement that some icons need to be displayed preferentially in practical application, priority is defined for each view object, and it can be understood that the higher the priority of a view object is, the higher the priority is, the more preferentially the view object, that is, the icon is displayed. First, a data structure class priority view is required to be designed, where the data structure class priority view includes two field information, one of which is view object view of view group type, and one priority object dyPriority corresponding to each view object view, where the priority object dyPriority is used to indicate display priority of view objects, and there are multiple priority objects dyPriority, and the multiple priority objects dyPriority are included in the priority class dyPriority. It should be noted that, the value of the priority object is inversely related to the display priority, that is, the larger the value of the priority object is, the lower the corresponding display priority is; the smaller the value of the priority object, the higher the corresponding display priority. The function expression of the specific definition manner of the priority class DYPriority may be as follows:
Public enum DYPriority{
LEVEL_ONE=1,
LEVEL_TWO=2,
LEVEL_THREE=3,…};
the priority dyprodiority is a public (public) type class, and public can modify a class to indicate a common access right so that other classes have a right to access the priority dyprodiority. In addition, each priority object in the priority class DYPriority, such as LEVEL _ ONE, LEVEL _ TWO, etc., is unique, and since the enumerated (enum) type class has a feature that each value of enumeration is not repeated, the priority class DYPriority is set to the enum type. It should be noted that each priority object may map a numerical value, such as a priority object LEVEL _ ONE mapping number 1, a priority object LEVEL _ TWO ═ 2 mapping number 2, and the like, where a larger number indicates a lower display priority, and a smaller number indicates a higher display priority. In practical applications, the value of the priority object mapping may be other numbers, which may satisfy the condition that the value of the priority object mapping is negatively related to the display priority, and thus the specific value of the priority object mapping is not limited herein.
Therefore, the data structure class PriorityView stores a plurality of view object views of view group type and a priority object corresponding to each view object.
Step 2, inserting a plurality of view objects into a circular linked list according to the sequence of display priority from high to low;
in the conventional scheme, a set is used to manage a series of data, but the performance overhead of data insertion and deletion is very large if the set is used to manage data, so that the entire data insertion and deletion can be very slow and inefficient. Considering that a linked list has the characteristic of high efficiency of inserting and deleting data, in order to better manage view objects, a data structure of the linked list is defined to process view objects in a data structure class priority view, and a function expression of the linked list is specifically defined as Link ═ new Link (), in the embodiment of the application, the linked list can be called as a circular linked list.
After the circularly linked list link is defined, a plurality of view object views in the data structure class PriorityView are inserted into the circularly linked list link according to the sequence of the display priority from high to low. Specifically, when a first view object, priorityView1, needs to insert a circularly linked list link, the insertion is performed by calling a function link- > head-priorityView 1; next, when a second view object priorityView2 needs to be inserted, a link- > head method is called to obtain a first view object priorityView1, then a function priorityView1 getdypriority () is called to obtain a priority object value of the view object priorityView1 as level1, and a function priorityView2 getdypriority () is called to obtain a priority object value of the view object priorityView2 as level 2. After obtaining the values of the priority objects of the view object priorityView1 and the view object priorityView2, judging the values of the priority objects, namely judging the size information of the level1 and the level2, if the level2 is larger than the level1, the display priority of the view object priorityView2 is lower, further judging the value of the priority object of the next element of the view object priorityView1 and the size of the level2, if the priorityView1- > next is found to be empty, the priority View1 is the last element, and therefore judging that the view object priorityView2 corresponding to the level2 should be inserted into the view object priorityView1.
Similarly, when there is a view object priority view3, first, it assumes that the value of the priority object of the view object priority view3 is level3, then sequentially determines the sizes of level3, level1 and level2, inserts the level3 between the values of the adjacent priority objects, if the priorities are equal, it continues to compare with the subsequent elements until the end of the circular linked list is compared or the value of the priority is greater than the value of level3, and then inserts the view object priority view3 between the values. For easy understanding, if there are 2 elements in the original circular linked list, their relationship is PRIORYView 1- > PRIORYView 2, i.e. level1 is less than level 2. After the comparison of the values of the priority objects is performed, it is determined that level1< level3< level2, and then the view object priorityView3 is inserted between the view object priorityView1 and the view object priorityView2, and specifically, the view object priorityView3 may be inserted between the view object priorityView1 and the view object priorityView2 by calling functions priorityView3- > next ═ priorityView1- > next and priorityView1- > next ═ priorityView 3. And then inserting the view objects in the data structure class PriorityView into the circular linked list link in a similar mode until all the view objects in the data structure class PriorityView are inserted into the circular linked list link.
Therefore, after the management of the elements of the circular linked list link is realized in the above manner, the display priority in the entire circular linked list link is ordered, that is, the display priority is sequentially reduced from the head to the tail.
Step 3, directing the last element of the circular linked list to the first element of the circular linked list;
it should be noted that, after the plurality of view objects are inserted into the circular linked list according to the display priority from high to low,
when view objects need to be sequentially taken out from the circular linked list link for display, when the tail of the circular linked list link is taken out, the pointing direction of the data pointer needs to be manually adjusted, the pointer of the circular linked list link points to the head again, and the head is circularly displayed again, so that the process is troublesome. In view of this, in the embodiment of the present application, the last element of the circular linked list link may be defaulted to point to the first element of the circular linked list link, so that the entire circular linked list is constructed into a ring structure, and no ending situation exists no matter how circular. Specifically, judging whether the next element of the currently displayed view object in the circular linked list link is empty NULL or not; if so, determining that the currently displayed view object is the last element of the circular linked list link, and pointing the currently displayed view object to the first element of the circular linked list by calling a function priorityViewL- > next ═ priorityViewF, wherein priorityViewL is used for representing the currently displayed view object, and priorityViewF is used for representing the first element of the circular linked list.
Optionally, since in the circular linked list link, if the pointing of one element is wrong, serious sequence abnormality may occur in the whole display structure, in order to solve the risk point, the circular linked list link is not the pointing of a simple ring structure when being designed, and a key of a next element and a key of a previous element may be stored in each element of the circular linked list link, wherein the key is used for uniquely representing the element. The specific implementation manner is that a String type of lastkey and beforeKey key information are designed in a data structure class primaryview, where beforeKey represents the key of the previous element, and lastkey represents the key of the next element. For example, in the circularly linked list link, the first view object priority view1 stores key1 and key2, where key1 is the key of the last view object in the circularly linked list link, and key2 is the key of the second view object in the circularly linked list link. Therefore, whether the next view object to be displayed found in the circular linked list link is correct or not can be determined through the method, and the integrity and the correctness of the pointing direction of the elements in the whole circular linked list link are guaranteed.
Step 4, sequentially taking out the first view objects from the circular linked list according to the sequence of the display priority from high to low;
after the circular linked list link is constructed in the above manner, and the elements in the circular linked list link, namely the view objects, are sorted from high to low according to the display priority, when the icon needs to be displayed, the first view object is sequentially taken out from the circular linked list, wherein the first view object is any view object in the circular linked list link.
Step 5, determining the display duration of the first view object according to the value of the priority object corresponding to the first view object and a preset adjustment interval;
it should be noted that, in practical applications, not only the individual icon is required to be preferentially displayed, but also the individual icon is required to be displayed for a long time to achieve a better popularization effect, and therefore, the display duration of the icon needs to be dynamically adjusted to meet the requirement. In conventional schemes, such an implementation is too templated by defining a mapping between a priority and a length of display time. In view of this, the embodiment of the present application further provides a method for dynamically adjusting the display duration of a view object.
Specifically, a mapping relationship between the value of the priority object and the preset scheduling interval is constructed, that is, a mapping function relation is constructed to describe the logical relationship between the value of the priority object and the preset scheduling interval, and the specific function expression is designed as follows:
Y=INT(C/LEVEL)*[min,max];
wherein, Y is used for representing a dynamic target adjustment interval; c is a constant, and the constant is a regulating coefficient, and the size of the constant value can be defined according to requirements mainly aiming at different application scenes; LEVEL is used for representing the value of the priority object corresponding to the view object, and the larger the numerical value is, the smaller the display priority is; the function INT () is a rounding function, and the interval [ min, max ] is a preset adjustment interval.
Therefore, the target adjustment interval Y1 of the first view object can be obtained by the mapping function and is set as [ MIN, MAX ], where MIN is used for representing the minimum value of the target adjustment interval Y1, and MAX is used for representing the maximum value of the target adjustment interval Y1; then, a random value, which is a display duration of the first view object, is output in the target adjustment interval Y1 by calling a function math.
And 6, displaying the first view object according to the display timer.
After the display duration of the first view object is determined, a display timer can be defined for the display of the first view object, the timeout time in the display timer is set to a target, and the value of the target is the display duration of the first view object. The first view object is displayed before the display timer times out until a next view object of the first view object is determined and presented after the time out.
Optionally, when the key of the previous element stored in the view object is set as the first key and the key of the next element is set as the second key, it is further necessary to determine whether the next view object of the first view object is correct. Specifically, whether a second secret key stored in a first view object is the same as a first secret key stored in a next view object of the first view object is judged; if the first view object is the same as the second view object, determining and displaying a next view object of the first view object; otherwise, if the two view objects are different, the next view object of the first view object is determined to be wrong, and the display of the view object is stopped, or the correct next view object is determined again for display.
In addition, in practical applications, some scenes such as advertisement icons are required to be displayed randomly for several times and then are not displayed, that is, the scenes such as the advertisement icons are required to be displayed no longer after one icon is displayed for a random number of times, so that how to provide a more flexible icon display mode meeting more requirements is a topic worthy of study. Therefore, the embodiment of the present application further provides a method for moving out a view object to improve the diversity and stability of the display of the view object, which specifically includes the following steps:
step 1, inserting a plurality of view objects in a data structure class into a circular linked list;
in the conventional scheme, a set is used to manage a series of data, but the performance overhead of data insertion and deletion is very large if the set is used to manage data, so that the entire data insertion and deletion can be very slow and inefficient. Considering that a linked list has the characteristic of high efficiency of inserting and deleting data, in order to better manage view objects, a data structure of the linked list is defined to process view objects in a data structure class priority view, and a function expression of the linked list is specifically defined as Link ═ new Link (), in the embodiment of the application, the linked list can be called as a circular linked list.
Optionally, after the circular linked list link is defined, a plurality of view objects view in the data structure class priority view are inserted into the circular linked list link from high to low according to the display priority. Specifically, when a first view object, priorityView1, needs to insert a circularly linked list link, the insertion is performed by calling a function link- > head-priorityView 1; when a second view object privatityview 2 needs to be inserted, acquiring a first view object privatityview 1 by calling a link- > head method, then acquiring a priority object value of the view object privatityview 1 by calling a function privatityview 1.getdypriority (), and acquiring a priority object value of the view object privatityview 2 by calling a function privatityview 2.getdypriority (), wherein the priority object value is assumed to be level2, it is required to say that the priority object value is used to represent a display priority, and the priority object value is inversely related to the display priority, that is, the larger the priority object value is, the smaller the display priority is; conversely, the smaller the value of the priority object, the greater the display priority. After obtaining the values of the priority objects of the view object priorityView1 and the view object priorityView2, judging the values of the priority objects, namely judging the size information of the level1 and the level2, if the level2 is larger than the level1, the display priority of the view object priorityView2 is lower, further judging the value of the priority object of the next element of the view object priorityView1 and the size of the level2, if the priorityView1- > next is found to be empty, the priority View1 is the last element, and therefore judging that the view object priorityView2 corresponding to the level2 should be inserted into the view object priorityView1.
Similarly, when there is a view object priority view3, first, it assumes that the value of the priority object of the view object priority view3 is level3, then sequentially determines the sizes of level3, level1 and level2, inserts the level3 between the values of the adjacent priority objects, if the priorities are equal, it continues to compare with the subsequent elements until the end of the circular linked list is compared or the value of the priority is greater than the value of level3, and then inserts the view object priority view3 between the values. For the sake of understanding, if there are 2 elements in the original circular linked list, the relationship is priorityView1- > priorityView2, i.e. level1 is smaller than level 2. Upon comparison of the values of the priority objects, it is determined that level1< level3< level2, and then the view object PRIORYView 3 is inserted between the view object PRIORYView 1 and the view object PRIORYView 2, and in particular, the view object PRIORYView 3 may be inserted between the view object PRIORYView 1 and the view object PRIORYView 2 by calling functions PRIORYVIEW 3- > next-PRIORYView 1- > next and PRIORYVIEW 1- > next-PRIORYORYPRIORYVIEW 3. And then inserting the view objects in the data structure class PriorityView into the circular linked list link in a similar mode until all the view objects in the data structure class PriorityView are inserted into the circular linked list link.
Therefore, after the management of the elements of the circular linked list link is realized in the above manner, the display priority in the entire circular linked list link is ordered, that is, the display priority is sequentially reduced from the head to the tail.
Optionally, in this embodiment of the application, the multiple view objects in the data structure class PriorityView may also be randomly inserted into the circular linked list link, so that there are multiple ways for inserting the multiple view objects in the data structure class PriorityView into the circular linked list link, and a specific method is not limited herein.
Step 2, obtaining the hash value of each view object in the circular linked list, and correspondingly storing the hash value of each view object and each view object into a data structure class;
since the view objects are stored in the link of the circular linked list, in order to manage a plurality of view objects, a hash value of each view object in the circular linked list needs to be obtained and stored correspondingly, that is, the hash value is encapsulated into the view object of the data structure class PriorityView, and specifically, a hash tag is added into the view object of the data structure class PriorityView by defining a variable hash of a String type.
It should be noted that the manner of obtaining the hash value of each view object and performing corresponding storage specifically includes: the hash value itemHash of the view object is calculated by calling a function PRIORYView.HashId () method, and the obtained hash value itemHash is packaged into a corresponding view object in a data structure class PRIORYView by calling a function PRIORYView.setHash (itemHash), so that the view object contains a unique description information hash value itemHash of the view object.
In the same way, for all view objects in the circular linked list link, the hash value information of the view objects is acquired and is stored in the data structure class PriorityView corresponding to the view objects.
Step 3, defining a global variable;
next, a global variable currentHashItem needs to be defined, and the global variable is initialized to a null object null by calling the function String currentHashItem, wherein the global variable currentHashItem is mainly used for pointing to the hash value itehashof the currently displayed view object. For example, when the circularly linked list link moves the linked list pointer to point to the next view object, itme2, the hash value of the view object needs to be obtained by calling the function, itme2.gethashid (), and then the reference relation of the obtained hash value is transferred to the global variable currentHashItem by calling the function currentHashItem ═ itme2.gethashid (), so that the global variable currentHashItem points to the hash value of the currently displayed element.
Step 4, acquiring random data m;
and then screening out the view objects which need to be deleted randomly in the circular linked list link by acquiring the random data m. Specifically, a random number selection set is constructed, wherein the value range of the random number selection set is an integer between (0, count), and the count is used for representing the number of the view objects in the circular linked list link, and then a parameter m is output by a calling function Math.
Step 5, traversing the circular linked list from the first view object of the circular linked list until the mth view object is traversed;
after the random data m is determined, the circularly linked list link is traversed from the first view object of the circularly linked list link until the mth view object is traversed, namely, the traversal is stopped. Specifically, a temporary variable tempCount is defined, and the value of the temporary variable tempCount is initialized to 0 by calling a function int tempCount ═ 0; starting from the first view object of the circular linked list, adding 1 to the value of a temporary variable tempCount every time one view object is traversed; judging whether the value of the current temporary variable tempCount is equal to the random data m or not every time a view object is traversed; if so, determining that the traversed view object is the mth view object, and stopping traversing the circular linked list, wherein the mth view object is the view object needing to be deleted from the circular linked list link; otherwise, if not, the next view object is continuously traversed.
Step 6, determining whether the mth view object is the currently displayed view object according to the hash value of the mth view object;
it should be noted that, in the normal flow, if a view object to be deleted, that is, the mth view object, is found, the mth view object is directly deleted, but if the view object found is the view object currently being displayed, it is considered that directly deleting a view object currently being displayed may cause page collapse. In view of this, it is necessary to determine whether the mth view object is the view object currently being displayed according to the hash value of the mth view object. Specifically, the mth view object is marked as itmeM, the hash value of the mth view object itmeM is obtained by calling a function itmeM. gethashid (), then the obtained hash value is marked as hashIdM, the hashIdM is compared with the contents of currentHashItem described above, a specific comparison function is textilitis. equals (currenthashidm), and if the hashIdM is the same, a true is returned; otherwise false is returned. If the function returns true indicating that hashIdM is the same as currentHashItem in content, that is, the mth view object is the view object being displayed, whereas if the function returns false indicating that hashIdM is not the same as currentHashItem in content, that is, the mth view object is not the view object being displayed.
Step 7, if not, deleting the mth view object from the circular linked list;
and if the mth view object is not the view object which is being displayed, directly deleting the mth view object from the circular linked list.
Optionally, if the mth view object is the view object being displayed, the deletion operation cannot be performed, and the above-mentioned random number screening needs to be performed again to screen out another random number for processing. It should be noted that, in an extreme case, after the elements currently being displayed are screened out by continuously deleting the random number, the screening operation of the random number is not performed, and at this time, the previous view object of the currently displayed view object is directly deleted. If the currently displayed view object is the first element of the circularly linked list, the last element of the circularly linked list is deleted directly.
Therefore, the view objects can be randomly deleted from the linked list link in the above manner.
It should be noted that, when the view objects are displayed by the circular linked list link, all the view objects start to sequentially display the next view after being displayed once, that is, when the same view object is displayed, it is necessary to wait for all the view objects in the entire circular linked list link to be displayed for a full circle before the view object is displayed again. However, in some practical scenarios, for example, in order to embed some advertisements for marketing objectives, it is desirable that the exposure rate of the advertisements is higher, that is, it is desirable that the advertisement content is repeatedly displayed for a plurality of times with a higher probability, and in order to meet the requirement, the embodiment of the present application further provides a set of solutions, and the specific implementation method includes the following steps:
step 8, constructing a data set nextArray;
and constructing a data set nextArray, wherein the data set nextArray comprises N elements which are randomly distributed, the N elements are divided into M types of parameters { a1, a2 … aM }, the values of the various types of parameters are different from each other, M is the number of the view objects in the circular linked list link, the various types of parameters are used for representing the view objects in the circular linked list link, the sum of the number of the various types of parameters is N, and the number proportion of the various types of parameters is the display probability proportion of the view objects in the preset circular linked list link.
To facilitate understanding, the following will be described by way of specific examples:
assume that the circular linked list link includes 3 view objects A, B and C, i.e. the value of M is 3, and the display probabilities of the 3 view objects are 10%, 60%, and 30%, i.e. the display probability ratio is 1:6: 3. To achieve this, an array is first constructed by calling a function int [100] array ═ new int [ ], and the array can put 100 elements. Next, in order to make the probability distribution of the three view objects 10%, 60%, and 30%, a different parameter may be defined for A, B, C, and for convenience of description, the parameter is defined as an integer of int type, and the parameter is used to uniquely describe the view object. Alternatively, let int a be 1, int B be 2, and int C be 3, that is, parameter 1 is used to represent view object a, parameter 2 is used to represent view object B, and parameter 3 is used to represent view object C. It should be noted that, the values of the parameters may be various, and only the uniqueness of the parameters needs to be ensured, that is, the value of A, B, C cannot have the same parameter.
Next, the parameter information of the view object A, B, C is fetched once from the circular linked list link in a circular manner and stored in the array, that is, 101 s representing the view object a, 60 2 s representing the view object B, and 30 3 s representing the view object C are sequentially fetched and stored in the array, so that 100 parameters are currently stored in the data array. Random (1,100) is called to randomly select data i1 from the interval [1,100], and then a new array, namely a data set nextaray, is constructed by calling a function nt [100] nextaray [ ]; and storing the parameter corresponding to the i1 th data in the array into the data set nextArray. Then dividing the interval [1-100] into two intervals [1, i1] and (i1,100], wherein [ represents equal; (if the meaning cannot be equal, then obtaining a random number i2 from the interval [1, i1) by using a calling function Math. random (1, i1), splitting [1, i1) into 2 small intervals [1, i2) and (i2, i1) after obtaining, and storing parameters corresponding to the i2 data in the array in a data set nextArray; similarly, random number i3 is also obtained from the interval (i1,100) by calling the function (h, random (i1,100), after obtaining, the (i1,100) is also split into 2 small intervals (i1, i3) and (i3, 100), and the parameter corresponding to the i3 th data in the array is stored in the array nextaray, i.e. after each data acquisition, the obtained data is stored in the nextaray set in the order of acquisition for the parameter corresponding to the array until the parameters in the array are all stored in the data set nextaray, i.e. the data set nextaray includes N values of N elements as 100, at this time, the elements in the data set nextaray are completely scrambled, and the scrambled data set nextaray includes 10 views of 1, 60 views of object a, 60 views of 2 and 30 views of C, so as to correspond to 10 views of objects a, 60 views of object B and 30 views of C.
Step 9, acquiring the current system time;
and step 10, determining the t-th element in the nextArray of the data set according to the current system time, and displaying the target view object.
After the data set nextary is constructed, when a view object in the data set nextary needs to be displayed, a current system time information time may be obtained by calling a function system.
t=time%(M*N);
Wherein, M is used for representing the total number of the view objects in the circular linked list link, N is used for representing the number of the elements in the data set nextArray, and the current system time information is complemented with M × N to obtain the remainder t;
therefore, after the remainder t is determined, the data set nextArray indexes the t-th element, and the parameter corresponding to the t-th element is used for representing the target view object, so that the display processing is performed after the target display object is determined.
It should be noted that, there is no specific execution order between steps 8 to 10 and steps 2 to 7, that is, step 8 to step 10 may be executed first, and then steps 2 to 7 are executed, or step 2 to step 7 may be executed first, and then step 8 to step 10 are executed, or executed simultaneously, and the specific implementation is not limited herein.
The embodiments of the present application are described above from the perspective of a method of updating icons, and are described below from the perspective of an updating apparatus.
Referring to fig. 2, fig. 2 is a schematic diagram of an embodiment of a possible updating apparatus according to an embodiment of the present application, where the updating apparatus specifically includes:
a defining unit 201, configured to define a view container class MyContainer, where the view container class MyContainer inherits a linear layout LinearLayout container in the Android system; the object mImageView is used for constructing an object mImageView, completely fills a space of the MyContainer layout of the view container class, and is a container object used for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation;
a transceiving unit 202, configured to receive a first gesture operation for the subject mImageView, where the first gesture operation is used to instruct an update operation to a content in the subject mImageView, and the update operation includes adding an icon or removing an icon;
a placing unit 203, configured to, in response to the first gesture operation, place an icon view in a view set listView into the object mImageView, where the view set listView is used to store an icon currently being displayed; and putting the updated content in the object mImageView into the view container class MyContainer.
Referring to fig. 3, fig. 3 is a schematic view of an embodiment of an electronic device according to an embodiment of the present disclosure.
As shown in fig. 3, an electronic device according to an embodiment of the present application includes a memory 310, a processor 320, and a computer program 311 stored in the memory 320 and executable on the processor 320, where the processor 320 executes the computer program 311 to implement the following steps: defining a view container class MyContainer that inherits a Linear layout container in the Android system; constructing an object mImageView, wherein the object mImageView completely fills a space of the MyContainer layout of the view container class, and is a container object for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation; receiving a first gesture operation aiming at the object mImageView, wherein the first gesture operation is used for indicating that an updating operation is performed on the content in the object mImageView, and the updating operation comprises an icon addition or an icon removal; in response to the first gesture operation, putting an icon view in a view set listView into the object mImageView, wherein the view set listView is used for storing an icon currently being displayed; and putting the updated content in the object mImageView into the view container class MyContainer.
Optionally, in a possible embodiment, the processor 320 is specifically configured to: defining the view container class MyContainer by a statement public class MyContainer extensions LinearLayout; and respectively setting the width and the height of the view label of the view container class MyContainer as a dp and b dp by calling a function android, width and height of which are a dp and b dp.
Optionally, in a possible embodiment, the processor 320 is specifically configured to: constructing the object mImageView by calling a function ImageView new ImageView (); constructing a layout object layout params by calling a function layout. Calling a function layout paramas, width of which is linear layout, layout param, match _ part to set the width of the layout object layout params to fill a PARENT layout, and a function layout paramas, height of which is linear layout, layout param, match _ part to set the height of the layout object layout to fill the PARENT layout, the PARENT layout being a space of the view container class MyContaine layout, respectively; setlayout objects are set into the object mImageView by calling a function mImageView. setLayoutParams (layoutParams) so that the object mImageView completely fills the space of the view container class MyContainer layout.
Optionally, in a possible embodiment, the processor 320 is further configured to: judging whether the icon to be newly added indicated by the updating operation is an empty null object or not; if the icon to be newly added is not an empty object, judging whether the icon to be newly added exists in the view set listView; if the icon to be newly added does not exist in the view set listView, adding the icon to be newly added into the view set listView by calling a function listView.add (), wherein an input parameter of the function listView.add () is the icon to be newly added.
Optionally, in a possible embodiment, the processor 320 is further configured to: judging whether the icon to be removed indicated by the updating operation is an empty null object or not; if the icon to be removed is not an empty object, judging whether the icon to be newly added exists in the view set listView; if the icon to be removed exists in the view set listView, deleting the icon to be removed in the view set listView by calling a function listView remove (), wherein an input parameter of the function listView remove () is the icon to be removed.
Optionally, in a possible embodiment, the processor 320 is specifically configured to: setontouchlink (this) sets the gesture listener for the subject mImageView by calling the function mImageView.
Optionally, in a possible embodiment, the processor 320 is specifically configured to: and putting the content of the updated object mImageView into the view container class MyContainer by calling a function addView (mImageView), wherein the function addView () is a public function, the input parameter of the function addView () is a ViewGroup type, and the return value of the addView () is a void type.
Since the electronic device described in this embodiment is a device used for implementing an updating apparatus in this embodiment, based on the method described in this embodiment, a person skilled in the art can understand the specific implementation manner of the electronic device of this embodiment and various variations thereof, so that how to implement the method in this embodiment by the electronic device is not described in detail herein, and as long as the person skilled in the art implements the device used for implementing the method in this embodiment, the device is within the scope of the present application.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating an embodiment of a computer-readable storage medium according to the present application.
As shown in fig. 4, the present embodiment provides a computer-readable storage medium 400, on which a computer program 411 is stored, the computer program 411 implementing the following steps when executed by a processor: defining a view container class MyContainer that inherits a Linear layout container in the Android system; constructing an object mImageView, wherein the object mImageView completely fills a space of the MyContainer layout of the view container class, and is a container object for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation; receiving a first gesture operation for the subject mImageView, wherein the first gesture operation is used for indicating that an updating operation is performed on the content in the subject mImageView, and the updating operation comprises adding an icon or removing an icon; in response to the first gesture operation, putting an icon view in a view set listView into the object mImageView, wherein the view set listView is used for storing an icon currently being displayed; and putting the updated content in the object mImageView into the view container class MyContainer.
Optionally, in a possible embodiment, the computer program 411 is specifically adapted to implement the following steps when being executed by a processor: defining the view container class MyContainer by a statement public class MyContainer extensions LinearLayout; and respectively setting the width and the height of the view label of the view container class MyContainer as a dp and b dp by calling a function android, width and height of which are a dp and b dp.
Optionally, in a possible embodiment, the computer program 411 is specifically adapted to implement the following steps when being executed by a processor: constructing the object mImageView by calling a function mImageView ═ new ImageView (); constructing a layout object layout params by calling a function layout. Calling a function layout paramas, width of which is linear layout, layout param, match _ part to set the width of the layout object layout params to fill a PARENT layout, and a function layout paramas, height of which is linear layout, layout param, match _ part to set the height of the layout object layout to fill the PARENT layout, the PARENT layout being a space of the view container class MyContaine layout, respectively; setlayout objects are set into the object mImageView by calling a function mImageView. setLayoutParams (layoutParams) so that the object mImageView completely fills the space of the view container class MyContainer layout.
Optionally, in a possible embodiment, the computer program 411 is further configured to, when executed by the processor, implement the following steps: judging whether the icon to be newly added indicated by the updating operation is an empty null object or not; if the icon to be newly added is not an empty object, judging whether the icon to be newly added exists in the view set listView or not; if the icon to be newly added does not exist in the view set listView, adding the icon to be newly added into the view set listView by calling a function listView.add (), wherein an input parameter of the function listView.add () is the icon to be newly added.
Optionally, in a possible embodiment, the computer program 411 is further configured to, when executed by the processor, implement the following steps: judging whether the icon to be removed indicated by the updating operation is an empty null object or not; if the icon to be removed is not an empty object, judging whether the icon to be newly added exists in the view set listView; if the icon to be removed exists in the view set listView, deleting the icon to be removed in the view set listView by calling a function listView remove (), wherein an input parameter of the function listView remove () is the icon to be removed.
Optionally, in a possible embodiment, the computer program 411 is specifically adapted to implement the following steps when being executed by a processor: setontouchlink (this) sets the gesture listener for the subject mImageView by calling the function mImageView.
Optionally, in a possible embodiment, the computer program 411 is specifically adapted to implement the following steps when being executed by a processor: and putting the content of the updated object mImageView into the view container class MyContainer by calling a function addView (mImageView), wherein the function addView () is a public function, the input parameter of the function addView () is a ViewGroup type, and the return value of the addView () is a void type.
It should be noted that, in the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to relevant descriptions of other embodiments for parts that are not described in detail in a certain embodiment.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include such modifications and variations.

Claims (9)

1. A method for updating icons is applied to an Android system and is characterized by comprising the following steps:
defining a view container class MyContainer that inherits a Linear layout container in the Android system;
constructing an object mImageView, wherein the object mImageView completely fills a space of the MyContainer layout of the view container class, and is a container object for containing and displaying a view;
setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation;
receiving a first gesture operation aiming at the object mImageView, wherein the first gesture operation is used for indicating that an updating operation is performed on the content in the object mImageView, and the updating operation comprises an icon addition or an icon removal;
in response to the first gesture operation, putting an icon view in a view set listView into the object mImageView, wherein the view set listView is used for storing an icon currently being displayed;
and putting the updated content in the object mImageView into the view container class MyContainer.
2. The method of claim 1, wherein defining the view container class MyContainer comprises:
defining the view container class MyContainer by a statement public class MyContainer extensions LinearLayout;
and respectively setting the width and the height of the view label of the view container class MyContainer as a dp and b dp by calling a function android, width and height of which are a dp and b dp.
3. The method of claim 1, wherein constructing the object mImageView and wherein the object mImageView completely fills the space of the view container class MyContainer layout comprises:
constructing the object mImageView by calling a function mImageView ═ new ImageView ();
constructing a layout object layout params by calling a function layout, layout, params, of the type layout;
calling a function layout paramas, width of which is linear layout, layout param, match _ part to set the width of the layout object layout params to fill a PARENT layout, and a function layout paramas, height of which is linear layout, layout param, match _ part to set the height of the layout object layout to fill the PARENT layout, the PARENT layout being a space of the view container class MyContaine layout, respectively;
setlayout objects are set into the object mImageView by calling a function mImageView. setLayoutParams (layoutParams) so that the object mImageView completely fills the space of the view container class MyContainer layout.
4. The method of any of claims 1-3, wherein when the update operation is adding an icon, before placing an icon view of a set of views listView into the subject mImageView, the method further comprises:
judging whether the icon to be newly added indicated by the updating operation is an empty null object or not;
if the icon to be newly added is not an empty object, judging whether the icon to be newly added exists in the view set listView or not;
if the icon to be newly added does not exist in the view set listView, adding the icon to be newly added into the view set listView by calling a function listView.add (), wherein an input parameter of the function listView.add () is the icon to be newly added.
5. The method of any of claims 1 to 3, wherein when the update operation is removing an icon, before the placing an icon view of the view set listView into the subject mImageView, the method further comprises:
judging whether the icon to be removed indicated by the updating operation is an empty null object or not;
if the icon to be removed is not an empty object, judging whether the icon to be removed exists in the view set listView or not;
if the icon to be removed exists in the view set listView, deleting the icon to be removed in the view set listView by calling a function listView remove (), wherein an input parameter of the function listView remove () is the icon to be removed.
6. The method of claim 1, wherein the setting a gesture listener for the subject mImageView comprises:
setontouchlink (this) sets the gesture listener for the subject mImageView by calling the function mImageView.
7. The method according to claim 1, wherein the placing the updated content in the object mImageView into the view container class MyContainer comprises:
and putting the content of the updated object mImageView into the view container class MyContainer by calling a function addView (mImageView), wherein the function addView () is a public function, the input parameter of the function addView () is a ViewGroup type, and the return value of the addView () is a void type.
8. An updating apparatus, comprising:
the device comprises a defining unit and a judging unit, wherein the defining unit is used for defining a view container class MyContainer which inherits a linear layout Linear layout container in an Android system; the object mImageView is used for constructing an object mImageView, completely fills a space of the MyContainer layout of the view container class, and is a container object used for containing and displaying a view; setting a gesture monitor for the object mImageView so that the object mImageView recognizes gesture operation;
a receiving and sending unit, configured to receive a first gesture operation for the subject mImageView, where the first gesture operation is used to instruct to perform an update operation on content in the subject mImageView, and the update operation includes adding an icon or removing an icon;
a placing unit, configured to, in response to the first gesture operation, place an icon view in a view set listView into the object mImageView, where the view set listView is used to store an icon currently being displayed; and putting the updated content in the object mImageView into the view container class MyContainer.
9. A computer-readable storage medium comprising computer-executable instructions that, when executed on a computer, cause the computer to perform the method of any one of claims 1-7.
CN201910379077.7A 2019-05-08 2019-05-08 Method and related device for updating icon Active CN110333920B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910379077.7A CN110333920B (en) 2019-05-08 2019-05-08 Method and related device for updating icon

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910379077.7A CN110333920B (en) 2019-05-08 2019-05-08 Method and related device for updating icon

Publications (2)

Publication Number Publication Date
CN110333920A CN110333920A (en) 2019-10-15
CN110333920B true CN110333920B (en) 2022-06-17

Family

ID=68139995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910379077.7A Active CN110333920B (en) 2019-05-08 2019-05-08 Method and related device for updating icon

Country Status (1)

Country Link
CN (1) CN110333920B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103677883A (en) * 2012-09-20 2014-03-26 腾讯科技(深圳)有限公司 Method and device for displaying dock icon
CN106775233A (en) * 2016-12-13 2017-05-31 青岛海信电器股份有限公司 Icon method for refreshing and terminal in a kind of terminal
CN107301014A (en) * 2017-06-26 2017-10-27 广州优视网络科技有限公司 A kind for the treatment of method and apparatus to gesture command
CN107908336A (en) * 2017-11-13 2018-04-13 平安科技(深圳)有限公司 Method for refreshing, device, storage medium and the terminal of list control
CN109117077A (en) * 2018-09-21 2019-01-01 武汉华中时讯科技有限责任公司 A kind of method and terminal by two touch slide refresh list view elements
CN109492178A (en) * 2018-11-05 2019-03-19 腾讯科技(深圳)有限公司 A kind of method and device of switch view

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9760234B2 (en) * 2008-10-14 2017-09-12 International Business Machines Corporation Desktop icon management and grouping using desktop containers
US20160154543A1 (en) * 2014-12-02 2016-06-02 Facebook, Inc. Generating a List of Content Items
US10736543B2 (en) * 2016-09-22 2020-08-11 Apple Inc. Workout monitor interface

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103677883A (en) * 2012-09-20 2014-03-26 腾讯科技(深圳)有限公司 Method and device for displaying dock icon
CN106775233A (en) * 2016-12-13 2017-05-31 青岛海信电器股份有限公司 Icon method for refreshing and terminal in a kind of terminal
CN107301014A (en) * 2017-06-26 2017-10-27 广州优视网络科技有限公司 A kind for the treatment of method and apparatus to gesture command
CN107908336A (en) * 2017-11-13 2018-04-13 平安科技(深圳)有限公司 Method for refreshing, device, storage medium and the terminal of list control
CN109117077A (en) * 2018-09-21 2019-01-01 武汉华中时讯科技有限责任公司 A kind of method and terminal by two touch slide refresh list view elements
CN109492178A (en) * 2018-11-05 2019-03-19 腾讯科技(深圳)有限公司 A kind of method and device of switch view

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"Android中利用OnTouchListener在中ImageView中动态显示图片";awp258;《https://blog.csdn.net/awp258/article/details/7635258》;20120605;第1-3页 *
"Android布局中动态添加ImageView";赏金术士;《https://blog.csdn.net/xzytl60937234/article/details/87966493》;20190227;第1页 *

Also Published As

Publication number Publication date
CN110333920A (en) 2019-10-15

Similar Documents

Publication Publication Date Title
CN109032691B (en) Applet running method and device and storage medium
US20180101394A1 (en) Method and embedded device for loading driver
EP2761442A1 (en) Methods and apparatus for extensions to directed graphs with minimal and maximal constraints are encoded by arcs in opposite directions
CN107729072B (en) Control attribute reading method and device, terminal and readable storage medium
CN110780897B (en) Code changing method and device
CN100507921C (en) Words display process in embedded system and system thereof
CN110333860B (en) Method and related device for moving out view object
CN111475511A (en) Data storage method, data access method, data storage device, data access device and data access equipment based on tree structure
CN110333920B (en) Method and related device for updating icon
CN109976744B (en) Visual programming method, system and terminal equipment
CN110334230B (en) View object display method and related device
CN103678687B (en) Establishment of item method and device based on configuration system
CN109213534A (en) A kind of method and device of extension live streaming software function
CN109089163B (en) Bullet screen message distribution method, device, equipment and storage medium
CN106874010A (en) A kind of method of the quick paging loadings of ListView in android system
CN116185545A (en) Page rendering method and device
CN116521392A (en) Method, system, device and storage medium for switching among multiple application software
CN115543317A (en) Front-end page development method and device
CN109407922B (en) Icon display control method, device, equipment and medium
CN109343758B (en) Method and apparatus for displaying icons through a mutex manager
CN109284164B (en) Icon display method and device
US9552347B1 (en) Data grid cell styling systems and methods
CN115705212A (en) Data response method and device in system platform and electronic equipment
CN109905759B (en) List display method, device, equipment and medium applied to Android client
CN110673827A (en) Resource calling method and device based on android system and electronic equipment

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