Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for browsing pictures, which can greatly reduce memory consumption caused by creating a picture view, save memory resources, and make a picture browsing process smoother.
To achieve the above object, according to an aspect of an embodiment of the present invention, a method for browsing pictures is provided.
A method of browsing pictures, comprising: when a current view page of a picture browsing page is entered, obtaining a picture view from a multiplexing pool, and loading picture data of a picture corresponding to the current view page into the picture view for display; and when the current view page is completely displayed, removing and adding the picture view of the previous view page displayed before the current view page into the multiplexing pool.
Optionally, the method further comprises: and if the picture view cannot be acquired from the multiplexing pool, creating the picture view, and loading the picture data of the picture corresponding to the current view page into the created picture view for displaying.
Optionally, the number of the picture views is 2.
Optionally, the method further comprises: when entering a current view page of a picture browsing page, obtaining and caching picture data of a picture corresponding to the current view page and a picture adjacent to the picture corresponding to the current view page.
According to another aspect of the embodiments of the present invention, an apparatus for browsing pictures is provided.
An apparatus for browsing pictures, comprising: the picture display module is used for acquiring a picture view from a multiplexing pool when a current picture page of a picture browsing page is entered, and loading picture data of a picture corresponding to the current picture page into the picture view for display; and the view removing module is used for removing and adding the picture view of the previous view page displayed before the current view page into the multiplexing pool after the current view page is completely displayed.
Optionally, the system further comprises a view creation module, configured to: and if the picture view cannot be acquired from the multiplexing pool, creating the picture view, and loading the picture data of the picture corresponding to the current view page into the created picture view for displaying.
Optionally, the number of the picture views is 2.
Optionally, the system further comprises a data caching module, configured to: when entering a current view page of a picture browsing page, obtaining and caching picture data of a picture corresponding to the current view page and a picture adjacent to the picture corresponding to the current view page.
According to another aspect of the embodiment of the invention, an electronic device for browsing pictures is provided.
An electronic device for browsing pictures, comprising: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for browsing pictures provided by the embodiment of the invention.
According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.
A computer readable medium, on which a computer program is stored, which when executed by a processor implements the method for browsing pictures provided by embodiments of the present invention.
One embodiment of the above invention has the following advantages or benefits: when a current view page of a picture browsing page is entered, obtaining a picture view from a multiplexing pool, and loading picture data of a picture corresponding to the current view page into the picture view for display; when the current view page is completely displayed, the picture view of the previous view page displayed before the current view page is removed and added into the multiplexing pool, so that the picture view is multiplexed and displayed by a multiplexing recovery mechanism, the memory consumption caused by the creation of the picture view can be greatly reduced, the memory resource is saved, and the picture browsing process is smoother. In addition, the method for browsing the pictures can load the pictures adjacent to the current picture in advance by means of a tool for loading the network picture when the current picture is displayed, and the pictures can be browsed more smoothly by preloading the pictures, so that user experience is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In order to solve the problems in the prior art, the invention provides a method and a device for browsing pictures, wherein in the process of browsing pictures by a user, a picture view is multiplexed and displayed by a multiplexing recovery mechanism, so that the memory consumption caused by creating the picture view can be greatly reduced, the memory resource is saved, and the picture browsing process is smoother. In addition, when the current picture is displayed, the picture adjacent to the current picture is loaded in advance by means of the SDWebImage which is a tool for loading the network picture, for example, the picture comprises a previous (preprage) picture and/or a next (nextpage) picture, and the picture can be browsed more smoothly by preloading the picture, so that the user experience is improved.
Fig. 1 is a schematic diagram illustrating main steps of a method for browsing pictures according to an embodiment of the present invention. As shown in fig. 1, the method for browsing pictures according to the embodiment of the present invention mainly includes the following steps S101 and S102.
Step S101: when entering a current view page of the picture browsing page, acquiring a picture view from the multiplexing pool, and loading picture data of a picture corresponding to the current view page into the picture view for display;
step S102: and when the current view page is completely displayed, removing and adding the picture view of the previous view page displayed before the current view page into the multiplexing pool.
According to the embodiment of the invention, the picture view ImageView is stored through the multiplexing pool, and when a certain picture page needs to be displayed each time, the available picture view is firstly obtained from the multiplexing pool, so that the picture view is repeatedly utilized, and a picture view is created without displaying every picture, thereby greatly saving the time and memory resources for creating the picture view.
According to one embodiment of the invention, if the picture view cannot be acquired from the multiplexing pool, the picture view is created, and the picture data of the picture corresponding to the current view page is loaded into the created picture view for display.
If the picture view cannot be acquired from the multiplexing pool, possibly because the current view page is the first view page to be displayed after entering the picture browsing page, and at this time, any picture view ImageView has not been created, then a picture view is created, and the picture data of the picture corresponding to the current view page is loaded into the created picture view for display.
According to another embodiment of the present invention, the number of picture views is 2. Since a large picture of only one picture is generally displayed each time when browsing pictures, and at most two pictures are simultaneously displayed during the process of view sliding, only 2 picture views need to be created in order to save unnecessary memory consumption.
According to another embodiment of the invention, when a current view page of the picture browsing page is entered, picture data of a picture corresponding to the current view page and pictures adjacent to the picture corresponding to the current view page are acquired and cached. The picture data of the picture corresponding to the current view page and the picture data of the picture adjacent to the current view page are downloaded in advance and cached locally, so that the picture data of the pictures can be directly read from the local cache without downloading, the time for generating the view page is greatly shortened, the phenomenon that the pictures are jammed due to the fact that the pictures occupy a network due to downloading is avoided, and the pictures are browsed more smoothly.
The following describes an implementation process of the method for browsing pictures according to the present invention with reference to an embodiment.
When a user enters a picture browsing page by clicking a small picture, firstly, two picture views ImageView (a picture view 1 and a picture view 2) are created, and then picture data of a current picture and a picture adjacent to the current picture are acquired when the user enters the picture browsing page according to a storage address path URL of the picture. In order to determine the adjacent relation between the pictures, the pictures to be displayed on the picture browsing page can be numbered, so that each picture has a serial number, and the sequence of the pictures can be judged according to the serial numbers. For example: assuming that when a user enters a picture browsing page, the sequence number of a current picture is M, and the sequence numbers of two adjacent pictures are (M-1) and (M +1), respectively, when picture data of the picture with the sequence number M is downloaded, the picture data of the two pictures with the sequence numbers (M-1) and (M +1) can be pre-downloaded to the local and cached. When the user slides the page to enter the previous view page or the next view page, the picture data can be directly obtained from the cache according to the URL of the corresponding picture, so that the picture display is smoother.
After the picture data of the current picture is acquired, the picture data of the current picture can be loaded to any one of the created picture views so as to display the current view page. If the picture data of the current picture is loaded into the created picture view 1 to display the current view page, the picture view 2 is taken as a preloaded picture view at this time, and when the user slides the page to enter the previous view page or the next view page, the picture data of the picture corresponding to the previous view page or the next view page can be directly loaded into the picture view 2 to display the view page, so that the display speed is high.
In the embodiment of the invention, the created picture view ImageView is a slidable picture view, and when the slidable picture view ImageView slides or scrolls, the image can slide or scroll from one view page to another view page. Taking the sliding or scrolling from the view page 1 to the view page 2 as an example, when the view page 1 is slid or scrolled, the system determines the sliding or scrolling direction according to the user operation, so as to determine which picture is displayed on the view page 2 to be entered. It is assumed that the view page 1 displays the picture 1 through the picture view 1, and the view page 2 displays the picture 2 through the picture view 2, where the picture 2 may be a previous picture prep of the picture 1 or a next picture nextpage of the picture 1, and particularly, when the picture 1 is a first picture to be displayed by the picture browse page, the previous picture prep is empty, and when the picture 1 is a last picture to be displayed by the picture browse page, the next picture nextpage is empty.
When the view page 1 is slid or scrolled to just enter the view page 2, the previously created picture view 2 is taken out of the multiplexing pool, and the picture 2 is loaded into the picture view 2 to display the view page 2, at this time, the current page of the APP or the web page may simultaneously display a part of the view page 1 and a part of the view page 2, so that smooth switching in the process of sliding or scrolling the view page is realized. Until the view page 2 is completely displayed, the picture view 1 of the previously displayed view page 1 is removed and added to the multiplexing pool.
When the view page 2 is slid or scrolled again to the view page to be displayed, at this time, whether an available picture view exists is firstly searched from the multiplexing pool, at this time, a picture view 1 exists and is available in the multiplexing pool, the picture view 1 is obtained, and the data display of the picture view 1 is refreshed. When refreshing and displaying the data of the picture view 1, specifically, judging whether the view page to be displayed is the same as the view page 1 (namely, whether a user slides to the previous display view page again or not), and if so, directly taking out the picture view 1 for displaying; otherwise, taking out the picture view 1, removing the loaded picture 1, and then loading and displaying the picture corresponding to the view page to be displayed into the picture view 1. Therefore, the display of the view page can be realized by only using two picture views without creating the picture views for many times, and the memory consumption is saved. And when the user slides or rolls the view page, the next large picture displayed is one of the previous picture and the next picture of the current picture, so that when the user enters one view page, the adjacent pictures of the pictures displayed on the entered view page are pre-downloaded and cached in advance, and the pictures are preferentially obtained from the cache for displaying during displaying, so that the pictures are more smoothly browsed.
Fig. 2 is a schematic block diagram of an apparatus for browsing pictures according to an embodiment of the present invention. As shown in fig. 2, the apparatus 200 for browsing pictures according to the embodiment of the present invention mainly includes a picture displaying module 201 and a view removing module 202.
The image display module 201 is configured to, when a current image page of an image browsing page is entered, obtain an image view from a multiplexing pool, and load image data of an image corresponding to the current image page into the image view for display;
a view removing module 202, configured to remove and add, to the multiplexing pool, a picture view of a previous view page displayed before the current view page after the current view page is completely displayed.
According to an embodiment of the present invention, the apparatus 200 for browsing pictures may further include a view creation module (not shown in the figure) for:
and if the picture view cannot be acquired from the multiplexing pool, creating the picture view, and loading the picture data of the picture corresponding to the current view page into the created picture view for displaying.
According to another embodiment of the present invention, the number of the picture views is 2.
According to another embodiment of the present invention, the apparatus 200 for browsing pictures may further include a data caching module (not shown in the figure) for:
when entering a current view page of a picture browsing page, obtaining and caching picture data of a picture corresponding to the current view page and a picture adjacent to the picture corresponding to the current view page.
According to the technical scheme of the embodiment of the invention, when a current view page of the picture browsing page is entered, a picture view is obtained from a multiplexing pool, and picture data of a picture corresponding to the current view page is loaded into the picture view for displaying; when the current view page is completely displayed, the picture view of the previous view page displayed before the current view page is removed and added into the multiplexing pool, so that the picture view is multiplexed and displayed by a multiplexing recovery mechanism, the memory consumption caused by the creation of the picture view can be greatly reduced, the memory resource is saved, and the picture browsing process is smoother. In addition, the method for browsing the pictures can load the pictures adjacent to the current picture in advance by means of a tool for loading the network picture when the current picture is displayed, and the pictures can be browsed more smoothly by preloading the pictures, so that user experience is improved.
Fig. 3 illustrates an exemplary system architecture 300 of a method for browsing pictures or an apparatus for browsing pictures to which an embodiment of the present invention may be applied.
As shown in fig. 3, the system architecture 300 may include terminal devices 301, 302, 303, a network 304, and a server 305. The network 304 serves as a medium for providing communication links between the terminal devices 301, 302, 303 and the server 305. Network 304 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal device 301, 302, 303 to interact with the server 305 via the network 304 to receive or send messages or the like. The terminal devices 301, 302, 303 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 301, 302, 303 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 305 may be a server providing various services, such as a background management server (for example only) providing support for shopping-like websites browsed by users using the terminal devices 301, 302, 303. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for browsing pictures provided by the embodiment of the present invention is generally executed by the server 305, and accordingly, the apparatus for browsing pictures is generally disposed in the server 305.
It should be understood that the number of terminal devices, networks, and servers in fig. 3 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 4, a block diagram of a computer system 400 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 4, the computer system 400 includes a Central Processing Unit (CPU)401 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output section 407 including a display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 409, and/or installed from the removable medium 411. The computer program performs the above-described functions defined in the system of the present invention when executed by a Central Processing Unit (CPU) 401.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware. The described units or modules may also be provided in a processor, and may be described as: a processor includes a picture presentation module and a view removal module. The names of these units or modules do not in some cases constitute a limitation on the units or modules themselves, for example, the picture display module may also be described as "a module for acquiring a picture view from a multiplexing pool when entering a current picture page of a picture browsing page, and loading picture data of a picture corresponding to the current view page into the picture view for display".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: when a current view page of a picture browsing page is entered, obtaining a picture view from a multiplexing pool, and loading picture data of a picture corresponding to the current view page into the picture view for display; and when the current view page is completely displayed, removing and adding the picture view of the previous view page displayed before the current view page into the multiplexing pool.
According to the technical scheme of the embodiment of the invention, when a current view page of the picture browsing page is entered, a picture view is obtained from a multiplexing pool, and picture data of a picture corresponding to the current view page is loaded into the picture view for displaying; when the current view page is completely displayed, the picture view of the previous view page displayed before the current view page is removed and added into the multiplexing pool, so that the picture view is multiplexed and displayed by a multiplexing recovery mechanism, the memory consumption caused by the creation of the picture view can be greatly reduced, the memory resource is saved, and the picture browsing process is smoother. In addition, the method for browsing the pictures can load the pictures adjacent to the current picture in advance by means of a tool for loading the network picture when the current picture is displayed, and the pictures can be browsed more smoothly by preloading the pictures, so that user experience is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.