Image loading method and device, electronic equipment and storage medium
By reloading images that failed due to network disconnection when the network is restored, the problem of degraded user experience is solved, efficient image loading and resource management are achieved, ensuring that users can quickly see the desired content after the network is restored.
Patent Information
- Application Number
- CN202410839046.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-13
AI Technical Summary
The existing technology cannot automatically reload images when recovering after a network disconnection, resulting in a degraded user experience.
When the network status is restored, by determining the loading failure parameters and position parameters of multiple candidate images, select and reload the target images that failed to load due to network disconnection, and only reload the images that have been attached to the window to avoid invalid loading. , and optimize user experience through retry mechanism and load times control.
This ensures that users can view content quickly after network recovery, improves user experience and loading efficiency, avoids invalid loading and waste of resources, and extends device usage time.
Smart Images

Figure CN118642893A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and more specifically, to a method, device, electronic device and storage medium for image loading in the field of image processing. Background Art
[0002] At present, in order to improve people's quality of life and provide people with an intelligent lifestyle, various application software are emerging in an endless stream. When users use various application software, the application software interface may involve the display of images. In order to improve the user experience and ensure that the images on the page can be quickly displayed to users when users click on the application software interface, image loading has become a necessary requirement.
[0003] When implementing image loading in the related technology, if the network is disconnected, the image loading process will not be automatically restored when the network is restored. Summary of the invention
[0004] The present application provides a method, device, electronic device and storage medium for image loading. The method can reload an image that failed to load due to a network disconnection when the network recovers from a disconnection, thereby avoiding the problem of a decreased user experience due to the inability to display the image due to a single failed load.
[0005] In a first aspect, a method for loading an image is provided, the method comprising: in a case where the network status is disconnected, in response to the network status being restored to a connected status, determining a plurality of candidate images and loading failure parameters and position parameters of each of the candidate images, the plurality of candidate images being images that failed to load, the loading failure parameters being used to indicate a reason why the corresponding candidate image failed to load, and the position parameters being used to indicate a storage location of the corresponding candidate image; based on the loading failure parameters of each of the candidate images, determining at least one target image from each of the candidate images, at least one of the target images being an image that failed to load due to network disconnection; based on the at least one target image, determining the position parameters of at least one of the target images from the position parameters of each of the candidate images; and based on the position parameters of at least one of the target images, reloading at least one of the target images.
[0006] In the above technical solution, when image loading is required, the present application proposes a method for image loading, which can select at least one target image that failed to load due to network disconnection from multiple candidate images to be loaded when detecting that the network is restored from disconnection to connection, and reload at least one target image. By reloading the images that failed to load due to network disconnection after the network is restored, it can ensure that users will not be unable to view content due to short-term network problems when browsing content, thereby improving user satisfaction. In addition, the present application chooses to load images that failed to load due to network disconnection, rather than blindly reloading all images that failed to load, which can improve loading efficiency and avoid invalid loading of some images, and the automated retry loading mechanism avoids the problem of users having to manually refresh the page.
[0007] In combination with the first aspect, in some possible implementations, based on the loading failure parameters of each of the candidate images, determining at least one target image from each of the candidate images includes: determining a target loading failure parameter from the loading failure parameters of each of the candidate images, the target loading failure parameter being used to indicate that the corresponding candidate image failed to load due to a network disconnection; and determining at least one target image from each of the candidate images based on the target loading failure parameter.
[0008] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, reloading at least one target image based on the position parameters of at least one target image includes: for any one of the at least one target images, determining the target view corresponding to the target image according to the target loading failure parameter; determining whether the target view is already attached to the window; and if the target view is already attached to the window, reloading the target image based on the position parameters of the target image.
[0009] In the above technical solution, when reloading the target image, it is first determined whether the target view corresponding to the target image has been attached to the window. When the target view is attached to the window, the target image is reloaded through the position parameters of the target image. The above process can ensure that only the images in the view that the user can actually see (i.e., the view that has been attached to the window) will be reloaded, avoiding useless network requests and resource occupation, improving the user's actual experience, and enabling the user to quickly see the expected content after restoring the network connection. In addition, only the images that are currently displayed or about to be displayed are reloaded, avoiding invalid loading of images in the background or inactive views, and improving the processing efficiency of the system.
[0010] In combination with the first aspect and the above implementations, in some possible implementations, the method further includes: when the target view is not attached to the window, deleting the target loading failure parameter.
[0011] In the above technical solution, when the electronic device determines that the target view is not attached to the window, it means that the target view is not a view that needs to be displayed to the user. In this case, deleting the loading failure parameter corresponding to the target view can effectively free up storage space, avoid useless storage of content that is no longer needed or not currently displayed, and ensure that the electronic device currently only focuses on loading tasks directly related to the current user interface.
[0012] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, after reloading at least one of the target images, the method also includes: for any one of the at least one target images, in the process of reloading the target image, monitoring whether the target image is loaded successfully; if the target image is loaded successfully, deleting the target loading failure parameter corresponding to the target image; if the target image fails to load, determining whether the target image has been reloaded before; if the target image has not been reloaded before, initializing the reloading count of the target image and continuing to load the target image; if the target image has been reloaded before, obtaining the reloading count; and determining whether to continue loading the target image based on the reloading count.
[0013] In the above technical solution, in the process of reloading the target image, the loading failure parameters are cleared immediately after the target image is loaded successfully, which helps to reduce unnecessary memory usage and keep the device running efficiently and light. When the target image fails to load, by counting the number of times the target image is reloaded and deciding whether to continue to try to load based on the number of retries, it can effectively avoid the degradation of user experience caused by giving up loading after a single loading failure, and avoid the waste of resources caused by unlimited retries.
[0014] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the determination of whether to continue loading the target image is made based on the number of reloads, including: when the number of reloads is equal to the preset number of loads, determining not to continue loading the target image and determining the preset image as the target image; when the number of reloads is less than the preset number of loads, determining to continue loading the target image and updating the number of reloads.
[0015] In the above technical solution, when the target image fails to load, if the number of retries to load has reached the limit, it will automatically switch to the preset image, avoiding the blank interface or delay caused by long-term loading failure, ensuring the integrity of the user interface, improving the user experience, and reducing the user's waiting anxiety. In addition, this application helps avoid endless retries by reasonably controlling the number of loading attempts, reducing the waste of network and system resources, and helping to extend the use time of the device.
[0016] In combination with the first aspect and the above-mentioned implementation manner, in some possible implementation manners, the method further includes: when the target image fails to be reloaded, obtaining current loading failure parameters of the target image; and updating the target loading failure parameters based on the current loading failure parameters.
[0017] In the above technical solution, each time a target image is loaded, if the target image fails to load, the electronic device promptly obtains the current loading failure parameters of the target image, thereby achieving synchronous updating of the loading failure parameters in each loading process.
[0018] In a second aspect, a device for loading an image is provided, the device comprising: a candidate image determination module, for determining, in response to the network status being restored to a connected state when the network status is disconnected, a plurality of candidate images and a loading failure parameter and a position parameter of each of the candidate images, wherein the plurality of candidate images are images that failed to load, the loading failure parameter is used to indicate a reason why the corresponding candidate image failed to load, and the position parameter is used to indicate a storage location of the corresponding candidate image; a target image determination module, for determining at least one target image from each of the candidate images based on the loading failure parameter of each of the candidate images, wherein at least one of the target images is an image that failed to load due to a network disconnection; a position parameter determination module, for determining, based on at least one of the target images, the position parameters of at least one of the target images from the position parameters of each of the candidate images; and an image loading module, for reloading at least one of the target images based on the position parameters of at least one of the target images.
[0019] In combination with the second aspect, in some possible implementations, the target image determination module is specifically used to: determine a target loading failure parameter from the loading failure parameters of each of the candidate images, and the target loading failure parameter is used to indicate that the corresponding candidate image failed to load due to a network disconnection; and determine at least one of the target images from each of the candidate images based on the target loading failure parameter.
[0020] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the image loading module is specifically used to: for any one of the at least one target images, determine the target view corresponding to the target image according to the target loading failure parameter; determine whether the target view has been attached to the window; and if the target view has been attached to the window, reload the target image based on the position parameters of the target image.
[0021] In combination with the second aspect and the above implementations, in some possible implementations, the image loading module is further used to: when the target view is not attached to the window, delete the target loading failure parameter.
[0022] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, after reloading at least one of the target images, the device also includes: a loading monitoring module, which is used to monitor whether the target image is loaded successfully for any one of the at least one target images during the process of reloading the target image; if the target image is loaded successfully, delete the target loading failure parameter corresponding to the target image; if the target image fails to load, determine whether the target image has been reloaded before; if the target image has not been reloaded before, initialize the reloading number of the target image and continue to load the target image; if the target image has been reloaded before, obtain the reloading number; and determine whether to continue loading the target image based on the reloading number.
[0023] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the loading monitoring module is specifically used to: when the number of reloading times is equal to the preset number of loading times, determine not to continue loading the target image and determine the preset image as the target image; when the number of reloading times is less than the preset number of loading times, determine to continue loading the target image and update the reloading number.
[0024] In combination with the second aspect and the above-mentioned implementation methods, in some possible implementation methods, the device also includes: a parameter updating module, which is used to obtain the current loading failure parameters of the target image when the target image fails to be reloaded; and update the target loading failure parameters based on the current loading failure parameters.
[0025] In a third aspect, an electronic device is provided, comprising a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the electronic device executes the method in the first aspect or any possible implementation of the first aspect.
[0026] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.
[0027] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a schematic diagram of an image loading scenario provided by an embodiment of the present application;
[0029] Figure 2 is a schematic flow chart of an image loading method provided in an embodiment of the present application;
[0030] Figure 3 is a schematic flow chart of another method for loading an image provided in an embodiment of the present application;
[0031] Figure 4 is a schematic flow chart of another method for loading an image provided in an embodiment of the present application;
[0032] Figure 5 is a schematic flow chart of another method for loading an image provided in an embodiment of the present application;
[0033] Figure 6 is a schematic flow chart of another method for loading an image provided in an embodiment of the present application;
[0034] Figure 7 is a structural schematic diagram of an image loading device provided in an embodiment of the present application;
[0035] Figure 8 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0037] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0038] Before introducing the solutions of the embodiments of the present application, the professional terms that may be involved in the embodiments of the present application are first explained.
[0039] Glide: is an efficient and powerful open source image loading and caching library, a picture (or image) loading library designed specifically for Android development.
[0040] HashMap: It is a data structure in the Java programming language and is an implementation class of the Map interface. It provides a key-value pair storage method that allows a unique key to be mapped to a specific value.
[0041] System.identityHashCode(): is a method in Java that receives an object as a parameter and returns the "identity hash code" of the object.
[0042] onLoadFailed(): This is a callback method used in the Glide image loading library. When image loading fails (for example, due to network problems, resource non-existence, decoding errors, etc.), the Glide image loading library will call this method. Developers can implement error handling logic in this method, such as displaying an error placeholder, logging, or trying to reload.
[0043] onResourceReady(): This is another callback method used in the Glide image loading library. When the image is loaded successfully and the resource is ready to be displayed, the Glide image loading library will call this method. Developers can perform operations after the image is successfully loaded here, such as adding animation effects, recording statistics of successful loading, etc.
[0044] The application scenarios of the embodiments of the present application are introduced below.
[0045] Figure 1 This is an image loading scenario provided by an embodiment of the present application.
[0046] For example, Figure 1 As shown, multiple applications are installed on the electronic device 101. For one of the applications (xx application), when the user browses a page in the application by sliding or clicking, the page can display different contents as the user continues to click or slide. When the content displayed on the page includes an image, the above process involves an image loading process.
[0047] When implementing the image loading process, the developer can add the Glide image loading library to the application. When the user slides or clicks the application page, the electronic device 101 generates an image loading request through the application program and requests the corresponding image from the Glide image loading library.
[0048] In a possible implementation, when the current network status of the electronic device 101 is good, the application can successfully load the image from the Glide image loading library and finally display it on the current page, such as Figure 1 As shown in (a) in .
[0049] In another possible implementation, when the current network status of the electronic device 101 is disconnected, the application fails to load the image, and the current page may be as follows: Figure 1 As shown in (b) in the figure, a prompt text "Loading" and an icon "Loading" will be displayed.
[0050] In the related art, when the network status of the electronic device 101 is restored from disconnected to connected, the image that failed to load previously will not be processed, resulting in low efficiency of image loading and poor user experience.
[0051] Based on the above problems, an embodiment of the present application provides a method for image loading, which can reload images that failed to load due to network disconnection when the network recovers from disconnection, thereby avoiding the problem of decreased user experience due to the inability to display the image due to a single failed load.
[0052] After introducing the application scenarios of the embodiments of the present application, the implementation process of an image loading method provided by the embodiments of the present application is described in detail below.
[0053] Figure 2 It is a schematic flow chart of a method for image loading provided in an embodiment of the present application. It should be understood that the method can be applied to an electronic device, and the type of the electronic device can be, for example, any electronic control unit (Electronic Control Unit, ECU, also known as a controller) in a smart phone, a computer device, a tablet, or a vehicle. The embodiment of the present application does not limit the type of electronic device.
[0054] For example, Figure 2 As shown, the method 200 includes:
[0055] 201. When the network status is disconnected, in response to the network status being restored to a connected state, multiple candidate images and loading failure parameters and position parameters of each candidate image are determined, wherein the multiple candidate images are images that failed to load, the loading failure parameters are used to indicate the reason why the corresponding candidate images failed to load, and the position parameters are used to indicate the storage location of the corresponding candidate images.
[0056] It should be understood that when a user browses a page of an application on an electronic device, if the network status of the electronic device is good, during the browsing process, as the user continues to slide or click, the images or video content in the page can be continuously loaded.
[0057] Taking the content of a page as an image as an example, when the network is disconnected during the user's browsing of the page, the image loading process will be interrupted, and the electronic device will eventually display blank content on the current page. When the network status returns to normal, the image can be reloaded through the method of the embodiment of the present application.
[0058] In the embodiment of the present application, in order to facilitate timely monitoring of network status changes, developers can pre-set corresponding network listeners in the application. The network listener is mainly used to monitor changes in network status. For example, switching from Wireless Fidelity (Wi-Fi) to mobile data, or network disconnection, etc.
[0059] For example, when a developer sets a network listener in an application, he or she may register a broadcast receiver (BroadcastReceiver) in the application, and use the BroadcastReceiver to listen to the network status change broadcasts issued by the Android operating system during the use of the application.
[0060] After the network listener is set up, if the electronic device determines through the network listener that the network status has recovered from a disconnected state to a connected state, the electronic device can start the method flow of the embodiment of the present application and reload the image that failed to load last time.
[0061] Specifically, during the reloading process, the electronic device may first determine multiple candidate images and loading failure parameters and location parameters of the multiple candidate images. The loading failure parameter is used to indicate the reason for the failure to load the candidate image, such as network reasons, image non-existence, etc. The location parameter is used to indicate the storage location of the candidate image, which can be understood as the image's Uniform Resource Locator (URL), that is, the unique address of the candidate image's image resource on the network, which is used to quickly locate the image.
[0062] It should be understood that for any image in the Glide image loading library, the image may be loaded repeatedly during the user's use of the application. Each time an image is loaded, a loading result will be obtained. The loading result specifically refers to whether the image loading is successful or failed.
[0063] For any image, there is a unique view corresponding to it during the loading process. The view is used to display the image and is the container of the image. The view is mainly responsible for the layout, display and interaction logic of the image. For example, when a user clicks on an image on a page to zoom in or out, it is all achieved through the packaging and processing of the image by the view.
[0064] If the image is loaded successfully, it means that the image has been read from the Glide image loading library and displayed in the current page through the corresponding view; if the image is loaded unsuccessfully, it means that the image cannot be displayed normally in the browsing page.
[0065] In the embodiment of the present application, in order to facilitate statistics of detailed information on image loading failures, the electronic device may establish a HashMap (referred to as a "first HashMap") to store loading failure parameters and URLs of images corresponding to each view.
[0066] In the first HashMap, the electronic device can generate a unique identity hash code for each view through the System.identityHashCode(view) method, and use the identity hash code of each view as the key of the first HashMap; use the loading failure parameters and URL of the image corresponding to each view as the value of the first HashMap, and obtain multiple key-value pairs.
[0067] Optionally, the loading failure parameter of each image can be the loading failure parameter of the image in the most recent loading process (i.e., the previous loading failure parameter), or can be the loading failure parameter of each image in each loading failure in the historical loading process. The embodiment of the present application takes the loading failure parameter as the most recent loading failure parameter as an example for subsequent introduction.
[0068] Exemplarily, for loading failure parameters, based on the Glide image loading library that the embodiment of the present application relies on for loading, during the image loading process through the Glide image loading library, the developer can obtain the image loading status by setting a loading listener.
[0069] Optionally, the image loading status includes loading success and loading failure. For different image loading status, the Glide image loading library provides different callback methods.
[0070] Specifically, when image loading fails, the Glide image loading library will call the onLoadFailed() error callback method for processing, and the electronic device can obtain the loading failure parameters in this callback method through the Glide image loading library. When the image loading is successful, the electronic device can call the onResourceReady() success callback method for processing through the Glide image loading library.
[0071] In addition, in the first HashMap, in addition to using the loading failure parameters and URL as the value of each key-value pair, the electronic device can also use the rounded corner settings corresponding to each image, default image information, and the identity document (ID) of the view corresponding to the image as the value of the key-value pair.
[0072] It should be noted that the difference between the view ID and the view identity hash code is that the view ID is a unique integer defined for each view on the interface, which is used to quickly find the view later. The view identity hash code does not directly identify the view, but serves as an internal representation of the object identity in the HashMap to facilitate efficient storage of the view.
[0073] Among them, the rounded corner settings are specific instructions on how to display images (such as the rounded corner radius of the image). When displaying images, the application will dynamically process the images according to these settings to make the final image more beautiful when displayed on the interface; the default image information refers to the information about the preset default image that the electronic device can display in order to avoid displaying blank content on the page when the original image cannot be loaded, such as the URL and rounded corner settings of the default image.
[0074] Based on the above-mentioned first HashMap, when the network listener detects that the network status has been restored, the electronic device can determine the corresponding multiple images according to the URLs of the multiple images that failed to load stored in the first HashMap, and use the multiple images as multiple candidate images, i.e., images that failed to load.
[0075] In addition, based on the multiple loading failure parameters and URLs stored in the first HashMap, the electronic device can also obtain the loading failure parameters and corresponding URLs corresponding to each of the multiple candidate images.
[0076] 202 : Determine at least one target image from the candidate images based on the loading failure parameters of the candidate images, where the at least one target image is an image that fails to load due to a network disconnection.
[0077] After the electronic device obtains multiple candidate images and the loading failure parameters and URLs of each candidate image through step 201, it can also filter out a target image that needs to be reloaded from the multiple candidate images based on the multiple loading failure parameters. The target image refers to a candidate image among the multiple candidate images that failed to load due to network disconnection.
[0078] In a possible implementation, determining at least one target image from each candidate image based on the loading failure parameter of each candidate image includes:
[0079] Determining a target loading failure parameter from the loading failure parameters of each candidate image, the target loading failure parameter being used to indicate that the corresponding candidate image fails to load due to a network disconnection;
[0080] At least one target image is determined from each candidate image according to the target loading failure parameter.
[0081] It should be understood that there are various reasons for loading failure during the image loading process. When the electronic device calls the onLoadFailed() method through the Glide image loading library to handle the loading failure process, the method usually receives a GlideException object as a parameter, which contains the specific reason for the loading failure, that is, the loading failure parameter.
[0082] Based on this, after obtaining the loading failure parameters of each candidate image, the electronic device can identify the loading failure parameters fed back by GlideException, which loading failure parameters indicate that the loading failure is caused by network disconnection, and use the loading failure parameters as the target loading failure parameters. Correspondingly, since the loading failure parameters correspond to the image. The electronic device can determine the URL of at least one target image corresponding to the target loading failure parameters based on the target loading failure parameters, and determine at least one target image based on the URL of at least one target image.
[0083] Since the principle of reloading each target image is the same, the loading process of the target image is introduced by taking one of the target images as an example in the embodiment of the present application.
[0084] 203 . Determine, according to at least one target image, position parameters of at least one target image from position parameters of each candidate image.
[0085] After determining at least one target image that fails to load due to network reasons, since the URL of each image is unique, based on the first HashMap, the electronic device can determine the URL of each target image from the URL of each candidate image stored in the first HashMap.
[0086] 204 : Reload at least one target image based on a position parameter of the at least one target image.
[0087] After determining at least one target image to be reloaded through step 202, the electronic device may reload the at least one target image.
[0088] In a possible implementation, reloading at least one target image based on a position parameter of at least one target image includes:
[0089] For any target image of the at least one target image, determining a target view corresponding to the target image according to the target loading failure parameter;
[0090] Determine whether the target view is attached to the window;
[0091] If the target view is already attached to the window, reload the target image based on the target image's position parameters.
[0092] It should be understood that, combined with the above, when the page is displayed, the window is the final interface for the application to interact with the user. The user interacts with the application through the window, and the window is responsible for rendering the content of the view (such as an image) on the screen. The window includes one or more views. During the interaction process, the user generally triggers it by clicking on the view in the window.
[0093] In other words, the premise for the image to be visible to the user is that the window in the page includes the view corresponding to the image, that is, the view corresponding to the image needs to be attached to the window first. Attaching a view to a window specifically means associating a view with a window so that the user can see and interact with it.
[0094] For example, for the Android system, when implementing the view attached to the window, the window usually refers to the window associated with the Activity, and the view is dynamically created and added through the layout file or code. Specifically, the structure and properties of the view are usually defined in the eXtensible Markup Language (XML) layout file, and then setContentView(R.layout.your_layout) is used in the onCreate() method of the Activity to set the layout file as the view content of the window. The view is dynamically created in the code and added to an existing view container (such as a FrameLayout or LinearLayout) through the addView() method. This container is usually the root view of the Activity. Therefore, through the above process, the view can be attached to the window.
[0095] For any target image, since the load failure parameter and the view ID are pre-stored in the value of the first HashMap, after the target image is determined, the target view corresponding to the target image can be determined based on the correspondence between the target load failure parameter and the view ID.
[0096] For example, the electronic device can call the method view.isAttachedToWindow() through the application to check whether the view is attached to the window. When the view is attached to the window, the method will return true; when the view is not attached to the window, the method will return false.
[0097] When the electronic device determines that the target view has been attached to the window, it implements the retry loading process.
[0098] Image loading specifically refers to the process of obtaining image data from different data sources, processing it, and displaying it in the interface.
[0099] Specifically, in the process of loading a target image based on the URL of the target image, the electronic device can use the with() method of the Glide image loading library through an application to start a loading request, and then call the load() method to specify the URL of the target image to be loaded, and specify the target view corresponding to the target image.
[0100] In the above technical solution, when reloading the target image, it is first determined whether the target view corresponding to the target image has been attached to the window. When the target view is attached to the window, the target image is reloaded. The above process can ensure that only the images in the view that the user can actually see (i.e., the view that has been attached to the window) will be reloaded, avoiding useless network requests and resource occupation, improving the user's actual experience, and enabling the user to quickly see the expected content after restoring the network connection. In addition, only the images that are currently displayed or about to be displayed are reloaded, avoiding invalid loading of images in the background or inactive views, and improving the processing efficiency of the system.
[0101] When the target view is not attached to the window, the electronic device may perform the following process:
[0102] In a possible implementation, the method further includes:
[0103] Removed target load failure parameter in case the target view is not attached to the window.
[0104] In another scenario, when the electronic device obtains the result that the target view is not attached to the window through view.isAttachedToWindow(), it may include the following situations:
[0105] First, the target view may not have been added to the layout. Generally in Android applications, views need to be added to a parent view or layout, and this parent view will eventually be attached to a window. If the view has not been correctly added to the layout, it is not associated with any window.
[0106] The second is that the view has been removed. If the view was once part of a window but was removed from the window due to some operation (such as dynamically removing the view, destroying the Activity or Fragment), then it is no longer attached to any window.
[0107] The third is that the page where the view is located is not fully initialized. During the page loading process, the view may still be in the initialization stage and has not yet completed the binding with the window.
[0108] When the electronic device obtains that the target view is not attached to the window, it means that the target image does not need to be displayed temporarily, so the electronic device determines that the target image does not need to be reloaded. In addition, since the target image is an image that does not need to be reloaded, in order to reduce unnecessary storage, the electronic device can also delete the target loading failure parameter corresponding to the target image in the first HashMap.
[0109] In addition to deleting the target loading failure parameters, the electronic device also needs to delete other parameters related to the target image in the first HashMap, including the identity hash code of the target view, the URL of the target image, the rounded corner settings, the basic information of the default image and the ID of the target view, so as to save the storage space of the first HashMap to the greatest extent.
[0110] In the above technical solution, when the electronic device determines that the target view is not attached to the window, it means that the target view is not a view that needs to be displayed to the user. In this case, deleting the loading failure parameter corresponding to the target view can effectively free up storage space, avoid useless storage of content that is no longer needed or not currently displayed, and ensure that the electronic device currently only focuses on loading tasks directly related to the current user interface.
[0111] Based on the different callback methods provided in the embodiments of the present application, when reloading a target image, the electronic device can call different methods for processing through the Glide image loading library based on the loading status of the target image.
[0112] In a possible implementation, after reloading at least one target image, the method further includes:
[0113] For any target image in the at least one target image, during the process of reloading the target image, monitoring whether the target image is loaded successfully;
[0114] When the target image is loaded successfully, the target loading failure parameter corresponding to the target image is deleted;
[0115] In the event that the target image fails to load, determine whether the target image has been reloaded before; if the target image has not been reloaded before, initialize the target image reload count and continue to load the target image; if the target image has been reloaded before, obtain the reload count; and determine whether to continue loading the target image based on the reload count.
[0116] In order to monitor the image loading results, developers can set up a loading listener in the application in advance. Specifically, when setting up a loading listener, the Glide image loading library provides RequestListener<drawable>Interface, based on this interface, developers can set two callback methods, onResourceReady() and onLoadFailed(), so that the Glide image loading library can call the corresponding method for processing when it receives the image loading status passed by the application.
[0117] Exemplarily, for any target image, during the loading process, the Glide image loading library can monitor the loading result of the target image through the loading listener.
[0118] Specifically, when the target image is loaded successfully, the electronic device can call the onResourceReady() method through the Glide image loading library, delete the target loading failure parameters in the first HashMap, and simultaneously delete the identity hash code of the target view in the first HashMap, the URL of the target image, the rounded corner settings, the relevant information of the default image and the target view ID, etc., to clear the relevant storage content of the first HashMap for the target image.
[0119] When the target image fails to load, the electronic device can call the onLoadFailed() method through the Glide image loading library for processing.
[0120] When the target image fails to load, the embodiment of the present application can provide multiple reloading opportunities, which can increase the probability of image loading compared to the loading strategy of reloading only once.
[0121] Based on the multiple reloading opportunities provided by the embodiments of the present application, in order to facilitate counting the number of image loading failures, the electronic device can set up another HashMap (called "second HashMap") to store the number of image loading times during the reloading process.
[0122] When establishing the second HashMap, the identity hash code of the view corresponding to the image can also be used as the key of each key-value pair, and the number of times the image is reloaded can be used as the value of each key-value pair, so as to obtain multiple key-value pairs.
[0123] As a result, when the target image fails to load, the electronic device can call the onLoadFailed() method through the Glide image loading library to count the number of times the target image is reloaded.
[0124] Since the number of retry loading times is limited in the embodiment of the present application, when the loading of the target image fails, the electronic device can determine whether to continue loading the target image based on the number of retry loading times of the target image.
[0125] To implement the above process, the electronic device may first determine whether there is a retry loading record of the target image in the second HashMap to determine whether the target image has been reloaded before.
[0126] Exemplarily, since the identity hash code of each view is unique, the electronic device can determine whether the identity hash code of the target view exists in the second HashMap through the identity hash code of the target view. When the identity hash code of the target view exists in the second HashMap, it means that the target image has been reloaded before; on the contrary, when the identity hash code of the target view does not exist in the second HashMap, it means that the target image has not been reloaded before.
[0127] If the target image has not been reloaded before, the electronic device can use the identity hash code of the target view as the key, store the number of times the target image has been reloaded as the value in the second HashMap, and initialize the number of reloads to 1, indicating that the current target view has been reloaded once.
[0128] In the case that the target image has been loaded before, the electronic device may determine whether to continue loading the target image according to the number of times the target image has been reloaded.
[0129] In the above technical solution, in the process of reloading the target image, the loading failure parameters are cleared immediately after the target image is loaded successfully, which helps to reduce unnecessary memory usage and keep the device running efficiently and light. When the target image fails to load, by counting the number of times the target image is reloaded and deciding whether to continue to try to load based on the number of retries, it can effectively avoid the degradation of user experience caused by giving up loading after a single loading failure, and avoid the waste of resources caused by unlimited retries.
[0130] Specifically, when determining whether to load the target image, the process is as follows.
[0131] In a possible implementation, determining whether to continue loading the target image according to the number of reloads includes:
[0132] When the number of reloads is equal to the preset number of loads, determining not to continue loading the target image and determining the preset image as the target image;
[0133] When the number of reload times is less than the preset number of load times, it is determined to continue loading the target image and update the number of reload times.
[0134] Exemplarily, it is assumed that the preset number of loading times is 3 times.
[0135] It should be noted that each time the target image is reloaded, the target image has a total of 3 loading opportunities. When the 3 loading opportunities are used up and the target image is not loaded successfully, the loading is completed. The electronic device will reset the number of retry loading times to 0 so that it can be counted during the next reloading of the target image.
[0136] In this loading process, the target image has a total of 3 loading opportunities (processes). When any loading process fails, the electronic device can first obtain the current reloading number (that is, the reloading number obtained after the previous accumulation). When the reloading number is equal to 3 times, it means that the current loading has reached the limit, and the electronic device stops loading the target image and determines the preset image as the target image.
[0137] The preset image here is the default image mentioned above. The specific electronic device can determine and display the default image from the Glide image loading library through the URL and rounded corner settings of the default image stored in the first HashMap, as well as the ID of the target view.
[0138] When the number of reloads is less than 3 times, it means that the current loading has not reached the limit. The electronic device can add 1 to the number of retry loadings and continue to load the target image.
[0139] In the above technical solution, when the target image fails to load, if the number of retries to load has reached the limit, it will automatically switch to the preset image, avoiding the blank interface or delay caused by long-term loading failure, ensuring the integrity of the user interface, improving the user experience, and reducing the user's waiting anxiety. In addition, this application helps avoid endless retries by reasonably controlling the number of loading attempts, reducing the waste of network and system resources, and helping to extend the use time of the device.
[0140] When the target image fails to load, in order to ensure synchronization of the loading failure parameters, the electronic device also needs to update the loading failure parameters.
[0141] In a possible implementation, the method further includes:
[0142] When the target image fails to be reloaded, the current loading failure parameters of the target image are obtained;
[0143] Update the target load failure parameters based on the current load failure parameters.
[0144] Exemplarily, when the target image fails to load, the electronic device may call the onLoadFailed() method through the Glide image loading library to obtain the current loading failure parameters and update them into the first HashMap.
[0145] In the above technical solution, each time the target image is loaded, if the target image fails to load, the electronic device promptly updates the loading failure parameters of the target image. On the one hand, it realizes the timely update of the loading failure parameters during each loading process; on the other hand, it can accumulate error information for each loading attempt, helping developers or system administrators to better track and analyze the specific reasons for the loading failure (such as network problems, server problems, non-existent resources, etc.).
[0146] In summary, an image loading method provided by an embodiment of the present application can select at least one target image that failed to load due to network disconnection from multiple candidate images to be loaded, and reload the at least one target image when detecting that the network has recovered from a disconnected state. By reloading images that failed to load due to a network disconnection after the network is restored, it is possible to ensure that users will not be unable to view content due to short-term network problems when browsing content, thereby improving user satisfaction. In addition, the present application selects to load images that failed to load due to a network disconnection, rather than blindly reloading all images that failed to load, which can improve loading efficiency and avoid invalid loading of some images, and the automated retry loading mechanism avoids the problem of users having to manually refresh the page.
[0147] In order to facilitate understanding of the implementation process of the embodiment of the present application, Figure 3-Figure 6 The overall process of the embodiment of the present application is introduced.
[0148] Figure 3 It is a schematic flowchart of another image loading method provided in an embodiment of the present application.
[0149] For example, Figure 3 As shown, the method 300 includes:
[0150] 301. When the network status is disconnected, in response to the network status being restored to a connected status, multiple candidate images and loading failure parameters and position parameters of each candidate image are determined, wherein the multiple candidate images are images that failed to load, the loading failure parameters are used to indicate the reason why the corresponding candidate images failed to load, and the position parameters are used to indicate the storage location of the corresponding candidate images.
[0151] 302 : Determine a target loading failure parameter from the loading failure parameters of each candidate image, where the target loading failure parameter is used to indicate that the corresponding candidate image fails to load due to a network disconnection.
[0152] 303 : Determine at least one target image from each candidate image according to the target loading failure parameter.
[0153] 304. Determine, according to at least one target image, position parameters of at least one target image from position parameters of each candidate image.
[0154] 305 : Reload at least one target image based on a position parameter of the at least one target image.
[0155] The above steps 301 to 305 have the same inventive concept as steps 201 to 204 in method 200 . Please refer to the above introduction for details, which will not be repeated here.
[0156] Figure 4 It is a schematic flowchart of another image loading method provided in an embodiment of the present application.
[0157] For example, Figure 4 As shown, the method 400 includes:
[0158] 401. When the network status is disconnected, in response to the network status being restored to a connected state, multiple candidate images and loading failure parameters and position parameters of each candidate image are determined, wherein the multiple candidate images are images that failed to load, the loading failure parameters are used to indicate the reason why the corresponding candidate images failed to load, and the position parameters are used to indicate the storage location of the corresponding candidate images.
[0159] 402 , determining a target loading failure parameter from the loading failure parameters of each candidate image, where the target loading failure parameter is used to indicate that the corresponding candidate image fails to load due to a network disconnection.
[0160] 403 : Determine at least one target image from each candidate image according to the target loading failure parameter.
[0161] 404 . Determine, according to at least one target image, position parameters of at least one target image from position parameters of each candidate image.
[0162] 405 . For any target image among the at least one target image, determine a target view corresponding to the target image according to the target loading failure parameter.
[0163] 406, determine whether the target view is attached to the window.
[0164] When the target view is already attached to the window, execute step 407;
[0165] When the target view has been attached to the window, step 408 is executed.
[0166] 407: Reload the target image based on the position parameter of the target image.
[0167] 408, delete target load failure parameter.
[0168] The above steps 401 to 408 have the same inventive concept as steps 201 to 204 in method 200 . Please refer to the above introduction for details, which will not be repeated here.
[0169] Figure 5 It is a schematic flowchart of another image loading method provided in an embodiment of the present application.
[0170] For example, Figure 5 As shown, the method 500 includes:
[0171] 501. When the network status is disconnected, in response to the network status being restored to a connected status, multiple candidate images and loading failure parameters and position parameters of each candidate image are determined, wherein the multiple candidate images are images that failed to load, the loading failure parameters are used to indicate the reason why the corresponding candidate images failed to load, and the position parameters are used to indicate the storage location of the corresponding candidate images.
[0172] 502 , determining a target loading failure parameter from the loading failure parameters of each candidate image, where the target loading failure parameter is used to indicate that the corresponding candidate image fails to load due to a network disconnection.
[0173] 503 . According to at least one target image, determine position parameters of at least one target image from position parameters of each candidate image.
[0174] 504 : Reload at least one target image based on a position parameter of the at least one target image.
[0175] 505 . During the reloading process, for any target image in at least one target image, monitoring whether the target image is loaded successfully is performed.
[0176] When the target image is loaded successfully, execute step 506;
[0177] When the target image fails to load, step 507 is executed.
[0178] 506, delete the target loading failure parameter corresponding to the target image.
[0179] 507, determine whether the target image has been reloaded before.
[0180] When the target image has been loaded before, execute step 508;
[0181] When the target image has been loaded before, steps 509 - 510 are executed.
[0182] 508 , initialize the reloading times of the target image and continue to load the target image.
[0183] 509, Get the number of reloads.
[0184] 510 , determining whether to continue loading the target image according to the number of reloads.
[0185] 511. When the target image fails to load, obtain the current loading failure parameters of the target image.
[0186] 512. Update the target loading failure parameter according to the current loading failure parameter.
[0187] The above steps 501 to 512 have the same inventive concept as steps 201 to 204 in method 200 . Please refer to the above introduction for details, which will not be repeated here.
[0188] Figure 6 It is a schematic flowchart of another image loading method provided in an embodiment of the present application.
[0189] For example, Figure 6 As shown, the method 600 includes:
[0190] 601. When the network status is disconnected, in response to the network status being restored to a connected state, multiple candidate images and loading failure parameters and position parameters of each candidate image are determined, and the multiple candidate images are all images that failed to load. The loading failure parameters are used to indicate the reason why the corresponding candidate image failed to load, and the position parameters are used to indicate the storage location of the corresponding candidate image.
[0191] 602 , determining a target loading failure parameter from the loading failure parameters of each candidate image, where the target loading failure parameter is used to indicate that the corresponding candidate image fails to load due to a network disconnection.
[0192] 603 . Determine, according to at least one target image, position parameters of at least one target image from position parameters of each candidate image.
[0193] 604 : Reload at least one target image based on a position parameter of the at least one target image.
[0194] 605 . During the reloading process, for any target image in the at least one target image, monitoring whether the target image is loaded successfully is performed.
[0195] When the target image is loaded successfully, execute step 606;
[0196] When the target image fails to load, step 607 is executed.
[0197] 606, deleting the target loading failure parameter corresponding to the target image.
[0198] 607, determine whether the target image has been reloaded before.
[0199] When the target image has been loaded before, execute step 608;
[0200] When the target image has been loaded before, step 609 is executed.
[0201] 608 , initialize the number of reloads of the target image and continue to load the target image.
[0202] 609, Get the number of reloads.
[0203] 610, determine whether the number of reloads is equal to the preset number.
[0204] When the number of reloads is equal to the preset number, executing step 611;
[0205] When the number of times the rack is re-assembled is less than the preset number, step 612 is executed.
[0206] 611 , determine not to continue loading the target image and determine the preset image as the target image.
[0207] 612, determine to continue loading the target image and update the reload count.
[0208] 613. When the target image fails to load, obtain current loading failure parameters of the target image.
[0209] 614, update the target loading failure parameter according to the current loading failure parameter.
[0210] The above steps 601 to 614 have the same inventive concept as steps 201 to 204 in method 200 . Please refer to the above introduction for details, which will not be repeated here.
[0211] Figure 7 It is a structural schematic diagram of an image loading device provided in an embodiment of the present application.
[0212] For example, Figure 7 As shown, the device 700 includes:
[0213] The candidate image determination module 701 is used to determine a plurality of candidate images and a loading failure parameter and a position parameter of each of the candidate images in response to the network status being restored to a connected state when the network status is disconnected, wherein the plurality of candidate images are images that failed to load, the loading failure parameter is used to indicate a reason why the corresponding candidate image failed to load, and the position parameter is used to indicate a storage location of the corresponding candidate image;
[0214] A target image determining module 702 is used to determine at least one target image from each of the candidate images based on the loading failure parameters of each of the candidate images, wherein at least one of the target images is an image that fails to load due to a network disconnection;
[0215] A position parameter determination module 703, configured to determine, according to at least one of the target images, a position parameter of at least one of the target images from the position parameters of each of the candidate images;
[0216] The image loading module 704 is used to reload at least one target image based on at least one position parameter of the target image.
[0217] In one possible implementation, the target image determination module 702 is specifically used to: determine a target loading failure parameter from the loading failure parameters of each candidate image, and the target loading failure parameter is used to indicate that the corresponding candidate image fails to load due to a network disconnection; and determine at least one target image from each candidate image based on the target loading failure parameter.
[0218] In one possible implementation, the image loading module 704 is specifically used to: for any one of the at least one target images, determine the target view corresponding to the target image according to the target loading failure parameter; determine whether the target view has been attached to the window; and if the target view has been attached to the window, reload the target image based on the position parameters of the target image.
[0219] In a possible implementation, the image loading module 704 is further configured to: delete the target loading failure parameter when the target view is not attached to the window.
[0220] Optionally, after reloading at least one of the target images, the device also includes: a loading monitoring module, used for monitoring whether the target image is loaded successfully for any one of the at least one target images during the process of reloading the target image; if the target image is loaded successfully, deleting the target loading failure parameter corresponding to the target image; if the target image fails to load, determining whether the target image has been reloaded before; if the target image has not been reloaded before, initializing the reloading number of the target image and continuing to load the target image; if the target image has been reloaded before, obtaining the reloading number; and determining whether to continue loading the target image based on the reloading number.
[0221] In one possible implementation, the loading monitoring module is specifically used to: when the number of reloading times is equal to the preset number of loading times, determine not to continue loading the target image and determine the preset image as the target image; when the number of reloading times is less than the preset number of loading times, determine to continue loading the target image and update the reloading number.
[0222] Optionally, the device further includes: a parameter updating module, configured to obtain current loading failure parameters of the target image when the target image fails to be reloaded; and update the target loading failure parameters based on the current loading failure parameters.
[0223] Figure 8 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0224] For example, Figure 8 As shown, the electronic device 101 includes: a memory 801 and a processor 802, wherein the memory 801 stores an executable program code 8011, and the processor 802 is used to call and execute the executable program code 8011 to perform an image loading method.
[0225] In this embodiment, the electronic device can be divided into functional modules according to the above method example. For example, each functional module can be corresponded to, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0226] In the case of dividing each functional module according to each function, the electronic device may include: a candidate image determination module, a target image determination module, a position parameter determination module, an image loading module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, and will not be repeated here.
[0227] The electronic device provided in this embodiment is used to execute the above-mentioned image loading method, and thus can achieve the same effect as the above-mentioned implementation method.
[0228] In the case of an integrated unit, the electronic device may include a processing module and a storage module. The processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device in executing related program codes and data.
[0229] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits shown in conjunction with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.
[0230] This embodiment further provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement an image loading method in the above-mentioned embodiment.
[0231] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement an image loading method in the above-mentioned embodiment.
[0232] In addition, the electronic device provided in the embodiments of the present application may specifically be a chip, a component or a module, and the electronic device may include a connected processor and a memory; wherein the memory is used to store instructions, and when the electronic device is running, the processor may call and execute instructions so that the chip executes an image loading method in the above-mentioned embodiments.
[0233] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.
[0234] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0235] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0236] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.< / drawable>
Claims
1. A method for loading an image, characterized in that: The method comprises: In the case where the network state is disconnected, in response to the network state being restored to a connected state, determining a plurality of candidate images, a loading failure parameter and a position parameter of each of the candidate images, wherein the plurality of candidate images are images that failed to load, the loading failure parameter is used to indicate a reason why the corresponding candidate image failed to load, and the position parameter is used to indicate a storage location of the corresponding candidate image; Based on the loading failure parameters of each of the candidate images, determining at least one target image from each of the candidate images, wherein the at least one target image is an image that fails to load due to a network disconnection; According to at least one of the target images, determining a position parameter of at least one of the target images from position parameters of each of the candidate images; At least one of the target images is reloaded based on a position parameter of at least one of the target images.
2. The method according to claim 1, characterized in that The step of determining at least one target image from each of the candidate images based on the loading failure parameters of each of the candidate images comprises: Determining a target loading failure parameter from the loading failure parameters of each of the candidate images, the target loading failure parameter being used to indicate that the corresponding candidate image fails to load due to a network disconnection; At least one target image is determined from each of the candidate images according to the target loading failure parameter.
3. The method according to claim 2, characterized in that The step of reloading at least one of the target images based on a position parameter of at least one of the target images comprises: For any one of the at least one target image, determining a target view corresponding to the target image according to the target loading failure parameter; Determine whether the target view is already attached to the window; In the case where the target view is already attached to a window, the target image is reloaded based on the position parameter of the target image.
4. The method according to claim 3, characterized in that The method further comprises: In the case that the target view is not attached to a window, the target load failure parameter is deleted.
5. The method according to claim 1, characterized in that After reloading at least one of the target images, the method further includes: For any of the at least one target image, during the process of reloading the target image, monitoring whether the target image is loaded successfully; In the case where the target image is loaded successfully, deleting the target loading failure parameter corresponding to the target image; In the event that the target image fails to load, determine whether the target image has been reloaded before; in the event that the target image has not been reloaded before, initialize the number of reloads of the target image and continue to load the target image; in the event that the target image has been reloaded before, obtain the number of reloads; and determine whether to continue loading the target image based on the number of reloads.
6. The method according to claim 5, characterized in that The step of determining whether to continue loading the target image according to the number of reloads includes: When the number of reloads is equal to the preset number of loads, determining not to continue loading the target image and determining a preset image as the target image; When the reloading number is less than the preset loading number, it is determined to continue loading the target image and update the reloading number.
7. The method according to claim 5, characterized in that The method further comprises: In the case where the target image fails to be reloaded, obtaining current loading failure parameters of the target image; Based on the current loading failure parameter, the target loading failure parameter is updated.
8. An image loading device, characterized in that: The device comprises: a candidate image determination module, for determining, in response to the network state being restored to a connected state, a plurality of candidate images, a loading failure parameter and a position parameter of each of the candidate images when the network state is disconnected, wherein the plurality of candidate images are images that failed to load, the loading failure parameter is used to indicate a reason why the corresponding candidate image failed to load, and the position parameter is used to indicate a storage location of the corresponding candidate image; A target image determination module, configured to determine at least one target image from each of the candidate images based on a loading failure parameter of each of the candidate images, wherein at least one of the target images is an image that fails to load due to a network disconnection; A position parameter determination module, configured to determine, based on at least one of the target images, a position parameter of at least one of the target images from the position parameters of each of the candidate images; The image loading module is used to reload at least one of the target images based on a position parameter of at least one of the target images.
9. An electronic device, characterized in that: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.
