CN114338709A - User head portrait synchronization method and device, storage medium and electronic equipment - Google Patents

User head portrait synchronization method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN114338709A
CN114338709A CN202111489507.4A CN202111489507A CN114338709A CN 114338709 A CN114338709 A CN 114338709A CN 202111489507 A CN202111489507 A CN 202111489507A CN 114338709 A CN114338709 A CN 114338709A
Authority
CN
China
Prior art keywords
user
avatar
head portrait
network address
display page
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.)
Granted
Application number
CN202111489507.4A
Other languages
Chinese (zh)
Other versions
CN114338709B (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.)
Guiyang Yuwan Technology Co ltd
Original Assignee
Guiyang Yuwan 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 Guiyang Yuwan Technology Co ltd filed Critical Guiyang Yuwan Technology Co ltd
Priority to CN202111489507.4A priority Critical patent/CN114338709B/en
Publication of CN114338709A publication Critical patent/CN114338709A/en
Application granted granted Critical
Publication of CN114338709B publication Critical patent/CN114338709B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The application provides a user head portrait synchronization method, a device, a storage medium and an electronic device, wherein an AvatarImageView inherited from the ImageView preset in a client is loaded, and the method is applied to the AvatarImageView and comprises the following steps: acquiring a user identifier and an avatar network address corresponding to the current user avatar in the newly loaded display page; judging whether a target network address of a target user avatar corresponding to the user identifier in a user avatar list is consistent with an avatar network address or not based on a user identifier and an avatar network address corresponding to the current user avatar, wherein the user avatar list is located in an avatar ImageView and comprises a plurality of user identifiers in a loaded display page and the network address of the user avatar corresponding to each user identifier; and if the current user head portrait is inconsistent with the current user head portrait, caching the current user head portrait, and refreshing the user head portrait of the loaded display page based on the current user head portrait.

Description

User head portrait synchronization method and device, storage medium and electronic equipment
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and an apparatus for synchronizing a user avatar, a storage medium, and an electronic device.
Background
In a social APP (Application), a user avatar is an important social attribute, and people often show their own features and their personalities through the avatar. The head portrait of the same user may appear in multiple pages in the APP, such as a user list page, a user data page, a private chat page, and the like, and the head portrait is often loaded only once when the page is displayed, and then only after the page data is refreshed, or after the page is re-opened, the refreshing is triggered. In this mechanism, the newly opened page is caused to display a new avatar of the user, and after the page returns to the previous page, the new avatar or the old avatar of the user is displayed, so that the user experiences a tearing feeling.
The realization scheme for keeping the user head portrait in the APP uniform in the industry at present is mostly a scheme for pushing messages to the APP and broadcasting in the APP: after the user changes the head portrait, the server pushes the user ID of the changed head portrait for the APP through the long link, the APP sends out a broadcast in the APP after taking the user ID, the page of the displayed head portrait subscribes the broadcast, and the user head portrait is reloaded, so that the consistency of the user head portrait in the APP is realized.
However, the existing scheme of using server push plus APP intra broadcast has the following disadvantages:
(1) the large number of server pushes consumes server resources, increasing server costs.
(2) The APP user does not care whether the head portraits of all users are changed, if the messages are pushed to all online users, the waste of server resources and the performance of the mobile phone of the user can be caused, and the endurance of the mobile phone of the APP user is shortened.
(3) By adopting the broadcast mode in the APP, the broadcast needs to be subscribed on the page displaying the avatar to trigger refreshing of the avatar, which may increase certain development and maintenance costs.
Therefore, a more efficient solution is needed to maintain the consistency of the user's avatar, reducing the tearing experience of the user.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method, an apparatus, a storage medium, and an electronic device for synchronizing a user avatar, so as to maintain consistency of the user avatar in an APP in a low-cost manner without increasing server pressure and cost.
In order to achieve the above object, embodiments of the present application are implemented as follows:
in a first aspect, an embodiment of the present application provides a method for synchronizing a user avatar, where an avatar auxiliary class avatarageview that inherits an original image display class ImageView and is preset in a client is loaded, and the method is applied to the avatarageview and includes: acquiring a user identifier and an avatar network address corresponding to the current user avatar in the newly loaded display page; judging whether a target network address of a target user avatar corresponding to the user identifier in a user avatar list is consistent with the avatar network address or not based on the user identifier and the avatar network address corresponding to the current user avatar, wherein the user avatar list is located in an avatar ImageView and comprises a plurality of user identifiers in a loaded display page and the network address of the user avatar corresponding to each user identifier; and if the current user head portrait is inconsistent with the current user head portrait, caching the current user head portrait, and refreshing the user head portrait of the loaded display page based on the current user head portrait.
In the embodiment of the application, the avatar auxiliary class avatarImageView is utilized to obtain the user identifier and the avatar network address corresponding to the current user avatar in the newly loaded display page, and whether the target network address of the target user avatar corresponding to the user identifier in the user avatar list is consistent with the avatar network address is judged, so that whether the user avatar is changed or not is determined. And when the target user head portrait is inconsistent with the target user head portrait, determining that the user head portrait is changed, and refreshing the user head portrait of the loaded display page by using the cached current user head portrait, thereby refreshing the target user head portrait corresponding to the target user identification in the loaded display page. Therefore, the consistency of the user head portraits displayed in the APP can be maintained, the use experience of the user is improved, the consistency of the user head portraits in the APP is maintained, the pressure and the cost of the server cannot be increased, and the development and maintenance cost of the APP is extremely low.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the client enters the user list page after being started, and before obtaining the user identifier and the avatar network address corresponding to the avatar of the current user in the newly loaded display page, the method further includes: pulling and caching user information of each user from the user list page to serve as the user avatar list, wherein the user information comprises a user identifier of each user and a network address of a user avatar; and for each loaded display page, pulling user information of each user from the loaded display page and adding the user information to the user avatar list.
In this implementation, the user information (including the user identifier and the network address of the user avatar) of each user is pulled from the user list page and cached as the user avatar list; and for each loaded display page, pulling user information of each user from the loaded display page and adding the user information to the user avatar list. Therefore, refreshing of the user head portrait can be achieved timely for each loaded display page in the APP, the updated user head portrait can be displayed in a new loaded display page, and can be updated to the loaded display page in real time, tearing of the user in experience is avoided, broadcasting in the station is not needed by a server, and server resources and cost are greatly saved.
With reference to the first aspect, in a second possible implementation manner of the first aspect, determining whether a target network address of a target user avatar corresponding to the user identifier in a user avatar list is consistent with the avatar network address based on the user identifier and the avatar network address corresponding to the current user avatar includes: determining a target user identifier consistent with the user identifier corresponding to the current user avatar from the user avatar list; and comparing the target network address of the head portrait of the target user corresponding to the target user identification with the head portrait network address, and judging whether the target network address is consistent with the head portrait network address.
In the implementation mode, a target user identification consistent with a user identification corresponding to the current user avatar is determined from the user avatar list, then a target network address of the target user avatar corresponding to the target user identification is compared with the avatar network address, and whether the target network address is consistent with the avatar network address or not is judged. By the method, whether the user head portrait of the newly loaded display page is changed compared with the user head portrait of the loaded display page can be judged efficiently.
With reference to the first aspect, in a third possible implementation manner of the first aspect, the caching the current user avatar, and refreshing the user avatar of the loaded display page based on the current user avatar includes: adding the current user head portrait into AvataImageView for caching; determining all target user head portraits corresponding to the target user identifications from the cache; and refreshing all target user head portraits based on the current user head portraits, so that the current user head portraits are loaded as the user head portraits in each loaded display page.
In the implementation mode, all target user head portraits corresponding to the target user identification are determined from the cache by using the current user head portraits cached by the avatarImageView, and all the target user head portraits are refreshed according to the current user head portraits, so that the user head portraits in each loaded display page are simply and efficiently updated.
With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, after the current user avatar is loaded as the user avatar in each loaded display page, the method further includes: when the fact that the user head portrait is moved out of the display page is detected, the user head portrait of the display page cached in the AvataImageView is removed from the cache; and when the client exits any display page, the user head portrait of the display page cached in the AvataImageView is cleared from the cache.
In this implementation, since the newly loaded display page may be kept consistent with the updated user avatar (because the newly loaded display page may be refreshed), when the client exits any display page, the user avatar of the display page cached in the AvatarImageView may be removed from the cache. And when the user head portrait is detected to be moved out of the display page, the user head portrait of the display page cached in the AvatarImageView can be also cleared from the cache. Therefore, the memory occupation of the AvatarImageView can be reduced, the data volume of the AvatarImageView for detecting when the user avatar synchronization method is operated every time is reduced, and the operation efficiency is improved.
In a second aspect, an embodiment of the present application provides a method for constructing an avatar auxiliary class for user avatar synchronization, including: creating an avatar auxiliary class Avatar ImageView inherited to an original image display class ImageView, setting a detection function in the Avatar ImageView, wherein the Avatar ImageView is used for caching the avatar View, each avatar View is bound with a corresponding user identifier (userID) and an avatar network address (showUrl), and a callback for refreshing the avatar View is arranged; and performing instrumentation in a key function for loading pictures to the avatar View in the avatar ImageView, wherein the instrumentation is used for triggering the avatar ImageView to cache the avatar View and triggering a detection function to operate, so that the detection function determines a corresponding user by detecting a user ID corresponding to the avatar View, determines all avatar View of the user in the avatar View cached in the avatar View, and executes callback refreshing.
In the implementation mode, an avatar auxiliary class avatarageview (used for caching the avatar views, each avatar View is bound with a corresponding user identifier userID and an avatar network address shourl, and a callback for refreshing the avatar views) which inherits the original image display class ImageView is created, so that data can be provided; setting a detection function in the Avatar ImageView, performing instrumentation in a key function for loading a picture for the avatar View, triggering the Avatar ImageView to cache the avatar View, and triggering the detection function to operate, so that the detection function determines a corresponding user by detecting a user ID corresponding to the avatar View, determines all avatar View of the user in the avatar View cached in the Avatar ImageView, and executes callback refreshing. Therefore, the function of reliably synchronizing the head portrait of the user in the APP by the head portrait auxiliary class for synchronizing the head portrait of the user can be simply and conveniently realized.
With reference to the second aspect, in a first possible implementation manner of the second aspect, a container AvatarViewList is created in the AvatarImageView, and is used for caching the displayed avatar View.
In a third aspect, an embodiment of the present application provides a user avatar synchronization apparatus, where an avatar auxiliary class avatarageview that inherits an original image display class ImageView and is preset in a client is loaded, and the apparatus is applied to the avatarageview, and includes: the acquisition module is used for acquiring a user identifier and an avatar network address corresponding to the head portrait of the current user in the newly loaded display page; the judging module is used for judging whether a target network address of a target user head portrait corresponding to the user identification in a user head portrait list is consistent with the head portrait network address or not based on the user identification and the head portrait network address corresponding to the current user head portrait, wherein the user head portrait list is located in the AvatarImageView and comprises a plurality of user identifications in the loaded display page and the network address of the user head portrait corresponding to each user identification; and the head portrait refreshing module is used for caching the head portrait of the current user when the target network address is inconsistent with the head portrait network address, and refreshing the head portrait of the user with the loaded display page based on the head portrait of the current user.
In a fourth aspect, an embodiment of the present application provides a storage medium, where the storage medium includes a stored program, where, when the program runs, a device in which the storage medium is located is controlled to execute the method for synchronizing the avatar of the user according to any one of the first aspect or possible implementation manners of the first aspect, or execute the method for constructing the auxiliary class of the avatar for synchronizing the avatar of the user according to the second aspect or the first possible implementation manner of the second aspect.
In a fifth aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, where the memory is configured to store information including program instructions, and the processor is configured to control execution of the program instructions, where the program instructions are loaded and executed by the processor to implement the method for synchronizing a user avatar according to the first aspect or any one of the possible implementations of the first aspect, or to implement the method for constructing an avatar auxiliary class for user avatar synchronization according to the second aspect or the first possible implementation of the second aspect.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other relevant drawings from these drawings without inventive effort.
Fig. 1 is a flowchart of a method for constructing an avatar auxiliary class for user avatar synchronization according to an embodiment of the present disclosure.
Fig. 2 is a flowchart of a user avatar synchronization method according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram of a loaded display page and a newly loaded display page in a client according to an embodiment of the present application.
Fig. 4 is a block diagram of a user avatar synchronization apparatus according to an embodiment of the present disclosure.
Fig. 5 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Icon: 10-user head portrait synchronizing means; 11-an acquisition module; 12-a judgment module; 13-head portrait refreshing module; 20-an electronic device; 21-a memory; 22-a communication module; 23-a bus; 24-a processor.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
In order to implement synchronization of the user avatar, the present embodiment provides a user avatar synchronization method to maintain consistency of the user avatar in the APP. Because the user head portrait synchronization method provided by the scheme is realized through the preset head portrait auxiliary class AvatarImageView, in order to facilitate reading and understanding of the scheme, a construction method of the head portrait auxiliary class for user head portrait synchronization provided by the scheme is introduced first.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for constructing an auxiliary class of an avatar for user avatar synchronization according to an embodiment of the present disclosure.
In the present embodiment, the method for constructing the avatar auxiliary class for user avatar synchronization may include steps S11 and S12. It should be noted that, for convenience of description, the steps S11 and S12 are introduced from the perspective of a developer, and it is understood that these descriptions may be replaced by descriptions in the perspective of a computer device, which are all within the scope of the present application.
To construct an avatar auxiliary class for user avatar synchronization, step S11 may be performed.
Step S11: creating an avatar auxiliary class AvatarImageView inherited to an original image display class ImageView, setting a detection function in the AvatarImageView, wherein the AvatarImageView is used for caching the avatar View, each avatar View is bound with a corresponding user identifier (userID) and an avatar network address (showUrl), and a callback for refreshing the avatar View is arranged.
In this embodiment, since the original picture display class ImageView is difficult to meet the requirement of the present solution when the user avatars are synchronized, an avatar auxiliary class avatars ImageView inherited from the ImageView is created for caching the avatar View, for example, a container avatars View list may be created in the avatars ImageView for caching the displayed avatar View.
Illustratively, a detection function may be set within the AvatarImageView to detect if the user avatar has been altered. In order to facilitate detection and refreshing of the user avatar in the subsequent process, the scheme binds a corresponding user identifier userID and an avatar network address showUrl for each avatar View, and is provided with a callback for refreshing the avatar View.
Then, step S12 may be performed.
Step S12: and performing instrumentation in a key function for loading pictures to the avatar View in the avatar ImageView, wherein the instrumentation is used for triggering the avatar ImageView to cache the avatar View and triggering a detection function to operate, so that the detection function determines a corresponding user by detecting a user ID corresponding to the avatar View, determines all avatar View of the user in the avatar View cached in the avatar View, and executes callback refreshing.
In this embodiment, instrumentation may be performed on a key function of loading a picture for the avatar View in the avatar imageview, so as to trigger the avatar imageview to cache the avatar View, and may trigger a detection function to run.
The detection function can determine a corresponding user by detecting the userID corresponding to the avatar View, so as to determine all the avatar Views of the user in the avatar View cached in the AvataImageView and execute callback refreshing the avatar.
Here, the construction and function of AvatarImageView are described by using an example, and the construction of the Android code to implement the key part of AvatarImageView is taken as an example:
Figure BDA0003397847010000091
with this section, creation of an AvatarImageView class that inherits from ImageView can be implemented for providing data.
Further:
Figure BDA0003397847010000092
with this section, AvatarImageView is made available for trigger detection.
Further:
Figure BDA0003397847010000093
through the part, the function of deleting the cached user head portrait by the AvataImageView can be realized.
And for the realization of the auxiliary class for controlling the consistency of the head portrait of the user, the method is mainly used for caching the head portrait View and detecting whether the head portrait View needs to reload the picture or not. The method comprises the following specific steps:
Figure BDA0003397847010000094
Figure BDA0003397847010000101
through the part, the function of judging whether the avatar View is changed or not can be realized, and the reloading of the avatar View can be triggered.
Further, for caching and clearing of the avatar View:
Figure BDA0003397847010000102
through the part, caching and clearing of the avatar View can be realized.
Based on the method, data can be provided by creating an avatar auxiliary class avatarageview (used for caching the avatar View, each avatar View is bound with a corresponding user identifier userID and an avatar network address shourl, and a callback for refreshing the avatar View) which inherits the original image display class ImageView; setting a detection function in the Avatar ImageView, performing instrumentation in a key function for loading a picture for the avatar View, triggering the Avatar ImageView to cache the avatar View, and triggering the detection function to operate, so that the detection function determines a corresponding user by detecting a user ID corresponding to the avatar View, determines all avatar View of the user in the avatar View cached in the Avatar ImageView, and executes callback refreshing. Therefore, the function of reliably synchronizing the head portrait of the user in the APP by the head portrait auxiliary class for synchronizing the head portrait of the user can be simply and conveniently realized.
After the avatarImageView is obtained, the avatarImageView can be preset in a client (APP) so as to realize the synchronization of the user avatar in the APP at the client and keep the consistency of the user avatar in the APP.
Based on this, a user avatar synchronization method provided by the present embodiment may be performed. Referring to fig. 2, fig. 2 is a flowchart of a user avatar synchronization method according to an embodiment of the present disclosure, where the user avatar synchronization method is applied to an avatar assistant class avatarageview (the avatarageview is preset in a client, and the client is installed in an electronic device, so that the present disclosure will describe a scheme by taking the electronic device as an execution subject, but is not limited thereto), and the user avatar synchronization method may include step S21, step S22, and step S23.
In order to realize the synchronization of the user avatar, the user avatar synchronization method can be operated when the APP loads a new display page, so that the real-time synchronization of the user avatar can be realized.
Before step S21 is executed, the list of user avatars to be referred to is introduced:
in this embodiment, after the user starts the client, the client opens a user list page first, and this page usually contains information such as head portraits and IDs of a plurality of different users. Then, the electronic device may use the AvatarImageView to pull the user information for each user from the user list page and cache it into AvatarImageView (created container AvatarViewList for caching the displayed avatar View) as the user avatar list. The user information here includes a user identification (userID) of each user and a network address (shokurl) of a user avatar. In addition, the electronic device may perform this operation for each loaded display page, pulling user information for each user from the display page and adding to the user avatar list.
Therefore, the loading display pages in the APP can be cached, refreshing of the user head portrait can be realized in time when the user head portrait is changed, the updated user head portrait can be displayed in the new loading display pages and can be updated to the loaded display pages in real time, and tearing of the user in experience is avoided.
Then, the electronic device may perform step S21 for the new loading of the display page by the client.
Step S21: and acquiring a user identifier and an avatar network address corresponding to the current user avatar in the newly loaded display page.
When a new display page is loaded at a client, the electronic device may obtain a user identifier (userID) and an avatar network address (shokurl) corresponding to a current user avatar in the newly loaded display page.
After acquiring the user identifier and the avatar network address, the electronic device may perform step S22.
Step S22: and judging whether the target network address of the target user avatar corresponding to the user identifier in the user avatar list is consistent with the avatar network address or not based on the user identifier and the avatar network address corresponding to the current user avatar, wherein the user avatar list is positioned in the Avatar ImageView and comprises a plurality of user identifiers in the loaded display page and the network address of the user avatar corresponding to each user identifier.
In this embodiment, the electronic device may determine, based on the user identifier and the avatar network address corresponding to the current user avatar, whether a target network address of a target user avatar corresponding to the user identifier in the user avatar list is consistent with the avatar network address.
For example, a target user identifier consistent with a user identifier corresponding to the current user avatar may be determined from the user avatar list (which may be performed in a traversal manner), and then a target network address of the target user avatar corresponding to the target user identifier is compared with the avatar network address to determine whether the target network address is consistent with the avatar network address.
By the method, whether the user head portrait of the newly loaded display page is changed compared with the user head portrait of the loaded display page can be judged efficiently.
When it is determined that one of the target network addresses does not coincide with the avatar network address, it indicates that the user avatar has been changed, and therefore step S23 may be executed.
Step S23: and caching the current user head portrait, and refreshing the user head portrait of the loaded display page based on the current user head portrait.
In this embodiment, the electronic device may cache the current user avatar, and then refresh the user avatar of the loaded display page based on the current user avatar, thereby implementing synchronization of the user avatar in the client.
For example, the electronic device may add the current user avatar into the AvatarImageView for caching, determine all target user avatars corresponding to the target user identifiers from the cache, and determine all target user avatars by traversing the user avatar list.
Then, the electronic device may refresh all target user avatars based on the current user avatar (implemented using a callback of the refresh avatar View), thereby loading the current user avatar as the user avatar in each loaded display page. Therefore, the user head portrait in the client can be synchronized in time (when the user opens any display page at the client and returns to the page opened before, the user head portrait in the previous display page is synchronized).
And determining all target user head portraits corresponding to the target user identifications from the cache by using the current user head portraits cached by the AvataImageView, and refreshing all the target user head portraits according to the current user head portraits, thereby simply and efficiently updating the user head portraits in each loaded display page.
When it is determined that one target network address is consistent with the head portrait network address, it is indicated that other target network addresses (network addresses with the same target user identification) are also consistent, because the operation is performed once every time a new page is loaded, and the user heads in all the loaded display pages are consistent, so that when the user head portrait is not changed, synchronization is not needed. Thus, the traversal process may end when traversing to the first target network address and determining to be consistent with the avatar network address.
Then, step S23 executed at this time is to cache the current user avatar and add it to the user avatar list.
After loading the current user avatar as the user avatar in each loaded display page, the electronic device may further remove the user avatar of the display page cached in the AvatarImageView from the cache when detecting that the user avatar is moved out of the display page. And when the client exits any display page, the user head portrait of the display page cached in the AvatarImageView can be cleared from the cache.
Since the newly loaded display page may be kept consistent with the updated user avatar (because the newly loaded display page may be refreshed), the user avatar of the display page cached in the AvatarImageView may be purged from the cache when the client exits any display page. And when the user head portrait is detected to be moved out of the display page, the user head portrait of the display page cached in the AvatarImageView can be also cleared from the cache. Therefore, the memory occupation of the AvatarImageView can be reduced, the data volume of the AvatarImageView for detecting when the user avatar synchronization method is operated every time is reduced, and the operation efficiency is improved.
Here, a specific example is used to describe the application of the user avatar synchronization method:
referring to fig. 3, fig. 3 is a schematic diagram illustrating a loaded display page and a newly loaded display page in a client according to an embodiment of the present application. The user list page and the private chat page are loaded display pages, and the user data page is a newly loaded display page.
The user list page, private chat page and user profile page all contain the user avatar to be displayed (the same user, with the same user identification userID, e.g. number 111). Wherein the loaded display page: the user head portrait of the user list page and the private chat page is head portrait a, and the user identification (number 111) of the user and the network address (for example, Urla) of the corresponding user head portrait (head portrait a) are cached in the avararImageView. And the user profile page is a newly loaded display page, the electronic device can acquire the user identifier (number 111) of the user and the avatar network address (e.g. Urlb) of the avatar B.
The electronic device may trigger the operation of the user avatar synchronization method when the user profile page loads the avatar B, thereby determining that the user avatar has been changed. Therefore, the avatar network address (for example, UrlA) corresponding to the user identifier (number 111) is traversed by caching the avatar B by using the Avatar ImageView, and the updating of the user avatar of the user list page and the private chat page is realized by using the preset callback for refreshing the avatar View, so that the avatar network addresses of the user list page and the private chat page are updated to be UrlB, and thus, the consistency of the user avatar in the client is realized.
Therefore, the avatar auxiliary class avatarImageView is utilized to acquire the user identifier and the avatar network address corresponding to the current user avatar in the newly loaded display page, and whether the target network address of the target user avatar corresponding to the user identifier in the user avatar list is consistent with the avatar network address is judged, so as to determine whether the user avatar is changed. And when the target user head portrait is inconsistent with the target user head portrait, determining that the user head portrait is changed, and refreshing the user head portrait of the loaded display page by using the cached current user head portrait, thereby refreshing the target user head portrait corresponding to the target user identification in the loaded display page. Therefore, the consistency of the user head portraits displayed in the APP can be maintained, the use experience of the user is improved, the consistency of the user head portraits in the APP is maintained, the pressure and the cost of the server cannot be increased, and the development and maintenance cost of the APP is extremely low.
Referring to fig. 4, fig. 4 is a block diagram of a user avatar synchronization apparatus 10 according to an embodiment of the present disclosure.
In this embodiment, loading an avatar auxiliary class AvatarImageView that inherits from an original image display class ImageView preset in the client, and applying the user avatar synchronization apparatus 10 to the AvatarImageView may include:
and the obtaining module 11 is configured to obtain a user identifier and an avatar network address corresponding to the current user avatar in the newly loaded display page.
And a judging module 12, configured to judge, based on the user identifier and the network address of the avatar corresponding to the current user avatar, whether a target network address of a target user avatar corresponding to the user identifier in a user avatar list is consistent with the network address of the avatar, where the user avatar list is located in the AvatarImageView and includes multiple user identifiers in the loaded display page and the network address of the user avatar corresponding to each user identifier.
And the head portrait refreshing module 13 is configured to, when the target network address is inconsistent with the head portrait network address, cache the current user head portrait, and refresh the user head portrait of the loaded display page based on the current user head portrait.
In this embodiment, the client enters a user list page after being started, and the user avatar synchronization apparatus 10 further includes a user avatar list module, configured to pull and cache user information of each user from the user list page as the user avatar list before the obtaining module 11 obtains a user identifier and an avatar network address corresponding to a current user avatar in a newly loaded display page, where the user information includes a user identifier of each user and a network address of a user avatar; and for each loaded display page, pulling user information of each user from the loaded display page and adding the user information to the user avatar list.
In this embodiment, the determining module 12 is specifically configured to determine, from the user avatar list, a target user identifier that is consistent with a user identifier corresponding to the current user avatar; and comparing the target network address of the head portrait of the target user corresponding to the target user identification with the head portrait network address, and judging whether the target network address is consistent with the head portrait network address.
In this embodiment, the avatar refresh module 13 is specifically configured to add the current user avatar into the AvatarImageView for caching; determining all target user head portraits corresponding to the target user identifications from the cache; and refreshing all target user head portraits based on the current user head portraits, so that the current user head portraits are loaded as the user head portraits in each loaded display page.
In this embodiment, the user avatar synchronization apparatus 10 further includes a user avatar clearing module, configured to clear the user avatar of the display page cached in the AvatarImageView from the cache when detecting that the user avatar is moved out of the display page after the avatar refresh module 13 loads the current user avatar as the user avatar in each loaded display page; and when the client exits any display page, the user head portrait of the display page cached in the AvataImageView is cleared from the cache.
Referring to fig. 5, fig. 5 is a block diagram of an electronic device 20 according to an embodiment of the present disclosure.
In this embodiment, the electronic device 20 may be a terminal device such as a personal computer, a tablet computer, a smart phone, and the like, which is not limited herein.
Illustratively, the electronic device 20 may include: a communication module 22 connected to the outside world via a network, one or more processors 24 for executing program instructions, a bus 23, and a different form of memory 21, such as a disk, ROM, or RAM, or any combination thereof. And, the electronic device 20 also has a display screen that can present the loaded display pages. The memory 21, the communication module 22, and the processor 24 may be connected by a bus 23.
Illustratively, the memory 21 has stored therein a program. The processor 24 may call and execute these programs from the memory 21, so that the user avatar synchronization method or the construction method of the avatar auxiliary class for user avatar synchronization may be implemented by executing the programs.
The embodiment of the present application provides a storage medium, where the storage medium includes a stored program, where, when the program runs, a device in which the storage medium is located is controlled to execute a user avatar synchronization method in the embodiment, or execute a method for constructing an avatar auxiliary class for user avatar synchronization in the embodiment.
To sum up, the embodiment of the present application provides a method, an apparatus, a storage medium, and an electronic device for synchronizing a user avatar, where a user identifier and an avatar network address corresponding to a current user avatar in a newly loaded display page are obtained by using an avatar auxiliary class avatai imageview, and it is determined whether a target network address of a target user avatar corresponding to the user identifier in a user avatar list is consistent with the avatar network address, so as to determine whether the user avatar is changed. And when the target user head portrait is inconsistent with the target user head portrait, determining that the user head portrait is changed, and refreshing the user head portrait of the loaded display page by using the cached current user head portrait, thereby refreshing the target user head portrait corresponding to the target user identification in the loaded display page. Therefore, the consistency of the user head portraits displayed in the APP can be maintained, the use experience of the user is improved, the consistency of the user head portraits in the APP is maintained, the pressure and the cost of the server cannot be increased, and the development and maintenance cost of the APP is extremely low.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments are merely illustrative, and for example, the division of the units is only one logical functional division, and there may be other divisions in actual implementation, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. A user head portrait synchronization method is characterized in that a head portrait auxiliary class AvatarImageView inherited to an original image display class ImageView preset in a client is loaded, and the method is applied to the AvatarImageView and comprises the following steps:
acquiring a user identifier and an avatar network address corresponding to the current user avatar in the newly loaded display page;
judging whether a target network address of a target user avatar corresponding to the user identifier in a user avatar list is consistent with the avatar network address or not based on the user identifier and the avatar network address corresponding to the current user avatar, wherein the user avatar list is located in an avatar ImageView and comprises a plurality of user identifiers in a loaded display page and the network address of the user avatar corresponding to each user identifier;
and if the current user head portrait is inconsistent with the current user head portrait, caching the current user head portrait, and refreshing the user head portrait of the loaded display page based on the current user head portrait.
2. The method for synchronizing the user avatars according to claim 1, wherein the client enters the user list page after being started, and before acquiring the user identifier and the avatar network address corresponding to the current user avatar in the newly loaded display page, the method further comprises:
pulling and caching user information of each user from the user list page to serve as the user avatar list, wherein the user information comprises a user identifier of each user and a network address of a user avatar; and the number of the first and second groups,
and for each loaded display page, pulling user information of each user from the loaded display page and adding the user information to the user head portrait list.
3. The method of claim 1, wherein determining whether the target network address of the target user avatar corresponding to the user identifier in the user avatar list is consistent with the avatar network address based on the user identifier and the avatar network address corresponding to the current user avatar comprises:
determining a target user identifier consistent with the user identifier corresponding to the current user avatar from the user avatar list;
and comparing the target network address of the head portrait of the target user corresponding to the target user identification with the head portrait network address, and judging whether the target network address is consistent with the head portrait network address.
4. The method of claim 1, wherein caching the current user avatar and refreshing the user avatar of the loaded display page based on the current user avatar comprises:
adding the current user head portrait into AvataImageView for caching;
determining all target user head portraits corresponding to the target user identifications from the cache;
and refreshing all target user head portraits based on the current user head portraits, so that the current user head portraits are loaded as the user head portraits in each loaded display page.
5. The user avatar synchronization method of claim 4, after loading said current user avatar as a user avatar in each loaded display page, said method further comprising:
when the fact that the user head portrait is moved out of the display page is detected, the user head portrait of the display page cached in the AvataImageView is removed from the cache;
and when the client exits any display page, the user head portrait of the display page cached in the AvataImageView is cleared from the cache.
6. A method for constructing an auxiliary class of an avatar for user avatar synchronization, comprising:
creating an avatar auxiliary class Avatar ImageView inherited to an original image display class ImageView, setting a detection function in the Avatar ImageView, wherein the Avatar ImageView is used for caching the avatar View, each avatar View is bound with a corresponding user identifier (userID) and an avatar network address (showUrl), and a callback for refreshing the avatar View is arranged;
and performing instrumentation in a key function for loading pictures to the avatar View in the avatar ImageView, wherein the instrumentation is used for triggering the avatar ImageView to cache the avatar View and triggering a detection function to operate, so that the detection function determines a corresponding user by detecting a user ID corresponding to the avatar View, determines all avatar View of the user in the avatar View cached in the avatar View, and executes callback refreshing.
7. The method for constructing the auxiliary class of the avatar for user avatar synchronization of claim 6, wherein an AvatarViewList container is created in the AvatarImageView for caching the displayed avatar View.
8. A user head portrait synchronizing device is characterized in that an auxiliary head portrait type AvatarImageView inherited to an original image display type ImageView preset in a client is loaded, and the device is applied to the AvatarImageView and comprises the following components:
the acquisition module is used for acquiring a user identifier and an avatar network address corresponding to the head portrait of the current user in the newly loaded display page;
the judging module is used for judging whether a target network address of a target user head portrait corresponding to the user identification in a user head portrait list is consistent with the head portrait network address or not based on the user identification and the head portrait network address corresponding to the current user head portrait, wherein the user head portrait list is located in the AvatarImageView and comprises a plurality of user identifications in the loaded display page and the network address of the user head portrait corresponding to each user identification;
and the head portrait refreshing module is used for caching the head portrait of the current user when the target network address is inconsistent with the head portrait network address, and refreshing the head portrait of the user with the loaded display page based on the head portrait of the current user.
9. A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program runs, a device on which the storage medium is located is controlled to execute the user avatar synchronization method according to any one of claims 1 to 5, or execute the method for constructing an avatar auxiliary class for user avatar synchronization according to any one of claims 6 to 7.
10. An electronic device comprising a memory for storing information comprising program instructions and a processor for controlling the execution of the program instructions, the program instructions being loaded and executed by the processor to implement the method for user avatar synchronization of any of claims 1-5 or to implement the method for building an avatar auxiliary class for user avatar synchronization of any of claims 6-7.
CN202111489507.4A 2021-12-07 2021-12-07 User head portrait synchronization method and device, storage medium and electronic equipment Active CN114338709B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111489507.4A CN114338709B (en) 2021-12-07 2021-12-07 User head portrait synchronization method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111489507.4A CN114338709B (en) 2021-12-07 2021-12-07 User head portrait synchronization method and device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN114338709A true CN114338709A (en) 2022-04-12
CN114338709B CN114338709B (en) 2023-08-29

Family

ID=81050312

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111489507.4A Active CN114338709B (en) 2021-12-07 2021-12-07 User head portrait synchronization method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114338709B (en)

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004166279A (en) * 2003-11-11 2004-06-10 Bandai Co Ltd Image distribution system and method thereof
CN103118355A (en) * 2013-01-17 2013-05-22 北京奇虎科技有限公司 Display method of mobile terminal user information, mobile terminals and service system
WO2015043463A1 (en) * 2013-09-27 2015-04-02 Tencent Technology (Shenzhen) Company Limited Synchronizing customized user information
CN105554064A (en) * 2015-12-03 2016-05-04 小米科技有限责任公司 Method and device for setting head portrait
CN107247796A (en) * 2017-06-23 2017-10-13 泰康保险集团股份有限公司 Client's head portrait loading method, device and terminal device
CN107545006A (en) * 2016-06-28 2018-01-05 百度在线网络技术(北京)有限公司 A kind of method, equipment and system for being used to establishing or updating image positional data storehouse
CN109562298A (en) * 2016-06-30 2019-04-02 索尼互动娱乐股份有限公司 Automaticmanual intelligence (AI) personal assistant method
US20190304081A1 (en) * 2018-03-29 2019-10-03 Ownsurround Oy Arrangement for generating head related transfer function filters
WO2020226785A1 (en) * 2019-05-06 2020-11-12 Apple Inc. Avatar integration with multiple applications
CN111930473A (en) * 2020-09-25 2020-11-13 亮风台(上海)信息科技有限公司 Method and apparatus for deploying image recognition service on container cloud
CN112422407A (en) * 2020-10-27 2021-02-26 广州趣丸网络科技有限公司 Voice room following method, device, equipment and storage medium
CN112965690A (en) * 2020-12-17 2021-06-15 贵阳语玩科技有限公司 UI resource dynamic updating method and device, storage medium and electronic equipment

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004166279A (en) * 2003-11-11 2004-06-10 Bandai Co Ltd Image distribution system and method thereof
CN103118355A (en) * 2013-01-17 2013-05-22 北京奇虎科技有限公司 Display method of mobile terminal user information, mobile terminals and service system
WO2015043463A1 (en) * 2013-09-27 2015-04-02 Tencent Technology (Shenzhen) Company Limited Synchronizing customized user information
CN105554064A (en) * 2015-12-03 2016-05-04 小米科技有限责任公司 Method and device for setting head portrait
CN107545006A (en) * 2016-06-28 2018-01-05 百度在线网络技术(北京)有限公司 A kind of method, equipment and system for being used to establishing or updating image positional data storehouse
CN109562298A (en) * 2016-06-30 2019-04-02 索尼互动娱乐股份有限公司 Automaticmanual intelligence (AI) personal assistant method
CN107247796A (en) * 2017-06-23 2017-10-13 泰康保险集团股份有限公司 Client's head portrait loading method, device and terminal device
US20190304081A1 (en) * 2018-03-29 2019-10-03 Ownsurround Oy Arrangement for generating head related transfer function filters
WO2020226785A1 (en) * 2019-05-06 2020-11-12 Apple Inc. Avatar integration with multiple applications
CN111930473A (en) * 2020-09-25 2020-11-13 亮风台(上海)信息科技有限公司 Method and apparatus for deploying image recognition service on container cloud
CN112422407A (en) * 2020-10-27 2021-02-26 广州趣丸网络科技有限公司 Voice room following method, device, equipment and storage medium
CN112965690A (en) * 2020-12-17 2021-06-15 贵阳语玩科技有限公司 UI resource dynamic updating method and device, storage medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王结;魏振钢;: "Android平台下快速加载图文信息的研究与实现", 计算机系统应用, no. 12 *

Also Published As

Publication number Publication date
CN114338709B (en) 2023-08-29

Similar Documents

Publication Publication Date Title
CN110515572B (en) Screen projection method and device, storage medium and computer equipment
US10877826B2 (en) Message processing method and apparatus, storage medium, and computer device
CN108419089B (en) Component data processing method, device, equipment and storage medium
US20190266034A1 (en) Screen capture method, terminal, and storage medium
CN112817494B (en) Data processing method and device, electronic equipment and storage medium
CN109033466B (en) Page sharing method calculates equipment and computer storage medium
CN113014934A (en) Product display method, product display device, computer equipment and storage medium
CN112035198A (en) Home page loading method, television and storage medium
CN108933947B (en) Bullet screen display method and device
CN109685595A (en) Method for pushing, device, mobile terminal and storage medium based on data analysis
CN112235632A (en) Video processing method and device and server
CN112148395A (en) Page display method, device, equipment and storage medium
CN114338709A (en) User head portrait synchronization method and device, storage medium and electronic equipment
CN108959393B (en) Dynamic picture processing method, device and storage medium
CN111258434A (en) Method, device, equipment and storage medium for inserting pictures into chat interface
US9942287B2 (en) Information processing system, terminal device, and method
CN114428899A (en) Multimedia resource pushing method and device, electronic equipment and storage medium
CN114157881A (en) Multimedia processing method, device, electronic equipment and storage medium
CN112416455A (en) Data processing method, device, terminal and storage medium
CN112861041B (en) Media content display method and device, electronic equipment and storage medium
CN110930496B (en) View drawing method and device, electronic equipment and storage medium
CN114675898A (en) Page jump method, computer device and computer readable storage medium
CN116366907A (en) Interface interaction method, device, equipment and storage medium
CN114385360A (en) Virtual resource distribution method, device, equipment, medium and product
CN115391327A (en) Data processing method, device and system

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