Summary of the invention
The object of the present invention is to provide the method and apparatus that card can not be caused to pause during a kind of can Showing Picture in waterfall stream mode on mobile terminals.
In order to achieve the above object, the invention provides a kind of method Showed Picture in waterfall stream mode, comprising:
Obtain the multiple pictures needing display, initialization current display page;
In the trailing process of display page, successively picture control and corresponding picture are loaded in waterfall stream, and reclaim picture control corresponding to the picture that shifts out screen.
Preferably, before initialization current display page, described method also comprises:
Set up the data pool comprising the picture control of predetermined number;
Described initialization current display page specifically comprises:
Picture control initialization current display interface is taken out from described data pool;
Described picture control being loaded in waterfall stream specifically comprises:
From described data pool, take out picture control is loaded in waterfall stream;
Picture control corresponding to the picture of screen is shifted out in described recovery, specifically comprises:
Picture control corresponding for the picture shifting out screen is put back in data pool.
Preferably, before initialization display page, described method also comprises:
Typesetting is carried out to each picture and obtains the positional information of each picture in waterfall stream;
Described initialization current display page, specifically comprises:
Corresponding picture initialization current page is chosen according to the positional information of each picture described;
Describedly successively picture control and corresponding picture to be loaded in waterfall stream, to comprise:
The picture control of picture to be loaded and correspondence thereof is loaded in waterfall stream by the positional information according to described picture to be loaded.
Preferably, describedly typesetting carried out to each picture obtain the positional information of each picture in waterfall stream, specifically comprise:
According to the picture columns L of the width determination waterfall stream that width and the picture needs of screen show;
Setting up a size is the array of L, and each element in array is initialized as the first preset value;
Successively typesetting is carried out to each picture according to the DISPLAY ORDER of each picture, and preserve positional information corresponding to each picture; Wherein, for the current picture treating typesetting, the positional information of the picture of typesetting in waterfall stream is treated as current in the position of element minimum for value in current array in array and value, and using described current treat the picture of typesetting height value and array in the minimum element of value and as the value of this element.
Preferably, describedly successively picture control and corresponding picture are loaded into waterfall stream and comprise:
Part in waterfall stream screen to be slided into is Loaded Image control; Or, the picture of control and correspondence that the part in waterfall stream screen to be slided into is Loaded Image.
Preferably, described picture control and corresponding picture being loaded in waterfall stream successively also comprises:
Pre-rendered is carried out to picture to be loaded in the picture downloaded.
Preferably, in the described picture to having downloaded, picture to be loaded carries out pre-rendered and specifically comprises:
When judging that the rolling speed of described display interface is less than the second preset value, pre-rendered is carried out to picture to be loaded in the picture downloaded.
Preferably, described method also comprises:
When judging that the rolling speed of described display interface reaches the second preset value, load default picture.
The invention provides a kind of equipment Showed Picture in waterfall stream mode, comprising:
Initialization module, for obtaining the multiple pictures needing display, initialization current display page;
Display module, in the trailing process of display page, is loaded into picture control and corresponding picture in waterfall stream successively, and reclaims picture control corresponding to the picture that shifts out screen.
Preferably, described equipment also comprises: data pool sets up module, for before initialization current display page, sets up the data pool comprising the picture control of predetermined number;
Initialization module, specifically for set up from described data pool module set up data pool in take out picture control initialization current display interface;
Display module, is loaded in waterfall stream specifically for taking out picture control from described data pool, and picture control corresponding for the picture shifting out screen is put back in data pool.
Preferably, described equipment also comprises: type-setting module, for before initialization display page, carries out typesetting obtain the positional information of each picture in waterfall stream to each picture;
Described initialization module, specifically for choosing corresponding picture initialization current page according to the positional information of each picture described;
Described display module, is loaded into the picture control of picture to be loaded and correspondence thereof in waterfall stream specifically for the positional information according to described picture to be loaded.
Preferably, described type-setting module is specifically for performing:
According to the picture columns L of the width determination waterfall stream that width and the picture needs of screen show;
Setting up a size is the array of L, and each element in array is initialized as the first preset value;
Successively typesetting is carried out to each picture according to the DISPLAY ORDER of each picture, and preserve positional information corresponding to each picture; Wherein, for the current picture treating typesetting, the positional information of the picture of typesetting in waterfall stream is treated as current in the position of element minimum for value in current array in array and value, and using described current treat the picture of typesetting height value and array in the minimum element of value and as the value of this element.
Preferably, described display module is also for the control that Loads Image to the part in waterfall stream screen to be slided into; Or, the picture of control and correspondence that the part in waterfall stream screen to be slided into is Loaded Image.
Preferably, described display module is also for carrying out pre-rendered to picture to be loaded in the picture downloaded.
Preferably, described display module also for when described equipment judges that the rolling speed of described display interface is less than the second preset value, carries out pre-rendered to picture to be loaded in the picture downloaded.
Preferably, described display module also for when judging that the rolling speed of described display interface reaches the second preset value, load default picture.
In image display method provided by the invention, obtain the multiple pictures needing display, initialization current display page; In the trailing process of display page, successively picture control and corresponding picture are loaded in waterfall stream, and reclaim picture control corresponding to the picture that shifts out screen.Owing to reclaiming the picture control corresponding to the picture shifting out screen, can avoid, in waterfall stream procedure for displaying, taking too much picture control, thus reduce taking CPU and internal memory, avoid the Caton phenomenon when mobile device carries out the display of waterfall stream.
Embodiment
Below in conjunction with drawings and Examples, the specific embodiment of the present invention is further described.Following examples only for technical scheme of the present invention is clearly described, and can not limit the scope of the invention with this.
The invention provides a kind of image display method, as described in Figure 1, the method comprises following flow process:
Step 101, obtains the multiple pictures needing display.
In detail, in step S1, multiple pictures of acquisition needs display refer to the information from file server requests picture, and server upon receiving a request, returns the picture address of each pictures with json form, the sequencing information of wide and the high and picture of picture.This process is consistent with prior art, no longer describes in detail at this.
Step 102, initialization current page.
Here initialization current page refers to that the picture selecting some from the multiple pictures got is full of screen.This process, with to carry out the initialized process of the page in prior art on other-end consistent, no longer describes in detail at this.
Step 103, in the trailing process of display page, is loaded into picture control and corresponding picture in waterfall stream successively, and reclaims picture control corresponding to the picture that shifts out screen.
In practical application, when showing, needing picture control to be loaded on display page, recording corresponding picture according to picture control afterwards.Here picture control refers to the space being specifically designed to and Loading Image, and its information that may comprise comprises background picture, picture description etc.Here " picture control being loaded in waterfall stream with corresponding picture successively " can be consistent with the mode each picture control and corresponding picture are recorded in waterfall stream when waterfall stream shows in prior art, is no longer further detailed at this.
In image display method provided by the invention, obtain the multiple pictures needing display, initialization current display page; In the trailing process of display page, successively picture control and corresponding picture are loaded in waterfall stream, and reclaim picture control corresponding to the picture that shifts out screen.Owing to reclaiming the picture control corresponding to the picture shifting out screen, can avoid, in waterfall stream procedure for displaying, taking too much picture control, thus reduce taking CPU and internal memory, avoid the Caton phenomenon when equipment carries out the display of waterfall stream.
Further, in order to avoid carrying out in the process of picture display in the mode of waterfall stream, the generation repeatedly of picture control, the waterfall stream display packing of picture provided by the invention also comprised before initialization current display page: set up the data pool comprising the picture control of predetermined number; Now,
Described step 102 specifically comprises: from described data pool, take out picture control initialization current display interface;
Picture control being loaded in waterfall stream in described step 103 specifically comprises: from described data pool, take out picture control be loaded in waterfall stream;
Picture control corresponding to the picture of screen is shifted out in recovery in described step 103, specifically comprises: picture control corresponding for the picture shifting out screen be put back in data pool.
Here predetermined number can according to the picture number setting can held in screen.And, understandablely be, the quantity of the picture control in data pool should be greater than the quantity of the picture that screen can hold, and considers that picture control can reclaim in time, this numerical value can be set to a value slightly larger than the picture number that can hold in screen.
In this way, for display device, without the need to the foundation that repeats and cleaning picture control, further reduce taking CPU and internal memory.
Further, after getting the multiple pictures needing display, before initialization current display page, typesetting can also be carried out to each picture and obtain the positional information of each picture in waterfall stream;
Now described step 102 can be:
Corresponding picture initialization current page is chosen according to the positional information of each picture described;
Picture control and corresponding picture are loaded into waterfall stream can be in step 103:
The picture control of picture to be loaded and correspondence thereof is loaded in waterfall stream by the positional information according to described picture to be loaded.
According to the record of the application, it may occur to persons skilled in the art that and multiplely carry out to each picture the mode that typesetting obtains the positional information of each picture in waterfall stream, one of the present invention preferred embodiment, can comprise as shown in Figure 2:
Step 201, according to the picture columns L of the width determination waterfall stream that width and the picture needs of screen show.
In practical application, the width of each picture adopting waterfall stream mode to show is generally consistent, according to the width of screen and the width of every pictures needs display, can calculate the columns of the picture in waterfall stream.
Step 202, sets up the array colOffsets [L] that a size is L, and each element in array is initialized as the first preset value.
Here the first preset value can set arbitrarily, is such as 0, as long as the initial value of each element is consistent, all can realize technical scheme provided by the present invention.
Step 203, whether typesetting is complete to judge all pictures, if not, then performs step 204, if so, then terminates typesetting flow process;
Step 204, determines the current picture treating typesetting according to the DISPLAY ORDER of each picture, rear steering step 205.
Here DISPLAY ORDER refers to the order needing to be shown, and the relevant information of display information can obtain from server, and corresponding process is consistent with prior art, no longer describes in detail at this.
Step 205, the positional information of the picture of typesetting in waterfall stream is treated as current in the position of element minimum for value in current array in array and value, and using described current treat the picture of typesetting height value and array in the minimum element of value sue for peace as the value of this element, rear steering step 203.
Concrete, in the implementation of step 205 can be:
Create the array framMap [N] that a size is picture number N, (positional information here can be the position of the minimum element of value in array in array and value itself to be used for depositing the more specific location information of all pictures, because the columns at this picture place can be indicated in the position in array, the value of element can show the height of picture in waterfall stream, therefore directly can determine the position of this picture in waterfall stream according to the position of minimum element in array and value, thus record for follow-up picture and picture control foundation is provided).Afterwards, the json information that resolution server returns, being left in a size is in the array Image [N] of N, this array is sorted according to DISPLAY ORDER.Traversal array Image [N], height of each row of waterfall stream after picture has been pasted according to the high computational of picture, each new picture pasted all will be attached to those minimum row of colOffsets [L] array intermediate value, preserves the absolute location information of this pictures in array framMap [N] simultaneously.
In this way, the typesetting of picture can simply be realized.
Further, describedly successively picture control and corresponding picture are loaded into waterfall stream and comprise:
Part in waterfall stream screen to be slided into is Loaded Image control; Or, the picture of control and correspondence that the part in waterfall stream screen to be slided into is Loaded Image.By the mode of this prestrain, the record just carrying out picture after display page slips into screen can be avoided, thus make the display of picture seem more smooth, promote the experience of user.This prestrain can be only the prestrain to picture control, also can for load picture simultaneously.
Further, describedly successively picture control and corresponding picture are loaded in waterfall stream and can also comprise:
Pre-rendered is carried out to picture to be loaded in the picture downloaded.
Mobile device is when showing image, decompress(ion) and resampling can consume a lot of CPU time, in order to avoid just carrying out compressing the loading that brings slower situation during display, after picture is downloaded, pre-rendered is carried out to picture to be loaded in the present invention, here pre-rendered can for draw image in advance in a bitmapcontex, this image of buffer memory again, can directly load image good for buffer memory when the loading of picture like this.
Further, in the described picture to having downloaded, picture to be loaded carries out pre-rendered and specifically comprises:
When judging that the rolling speed of described display interface is less than the second preset value, pre-rendered is carried out to picture to be loaded in the picture downloaded.
When screen slides too fast, the speed that picture loads also is accelerated accordingly, if now still carry out pre-rendered to all pictures, then likely cause the load too high of CPU, cause card, on this basis, in the embodiment of the present invention, only when judging that the rolling speed of described display interface is less than the second preset value, pre-rendered is carried out to picture to be loaded in the picture downloaded.
And when judging that the rolling speed of described display interface reaches the second preset value, can load default picture or delay loading picture.
Based on identical design, present invention also offers a kind of equipment Showed Picture in waterfall stream mode, as shown in Figure 3, comprising:
Initialization module 301, for obtaining the multiple pictures needing display, initialization current display page;
Display module 302, in the trailing process of display page, is loaded into picture control and corresponding picture in waterfall stream successively, and reclaims picture control corresponding to the picture that shifts out screen.
Preferably, described equipment also comprises: data pool sets up module, for before initialization current display page, sets up the data pool comprising the picture control of predetermined number;
Described initialization module 301, specifically for set up from described data pool module set up data pool in take out picture control initialization current display interface;
Described display module 302, is loaded in waterfall stream specifically for taking out picture control from described data pool, and picture control corresponding for the picture shifting out screen is put back in data pool.
Preferably, described equipment also comprises: type-setting module, for before initialization display page, carries out typesetting obtain the positional information of each picture in waterfall stream to each picture;
Described initialization module 301, specifically for choosing corresponding picture initialization current page according to the positional information of each picture described;
Described display module 302, is loaded into the picture control of picture to be loaded and correspondence thereof in waterfall stream specifically for the positional information according to described picture to be loaded.
Preferably, described type-setting module is specifically for performing:
According to the picture columns L of the width determination waterfall stream that width and the picture needs of screen show;
Setting up a size is the array of L, and each element in array is initialized as the first preset value;
Successively typesetting is carried out to each picture according to the DISPLAY ORDER of each picture, and preserve positional information corresponding to each picture; Wherein, for the current picture treating typesetting, the positional information of the picture of typesetting in waterfall stream is treated as current in the position of element minimum for value in current array in array and value, and by described current treat the picture of typesetting height value and array in the minimum element of value sue for peace.
Preferably, described display module 302 is also for the control that Loads Image to the part in waterfall stream screen to be slided into; Or, the picture of control and correspondence that the part in waterfall stream screen to be slided into is Loaded Image.
Preferably, described display module 302 is also for carrying out pre-rendered to picture to be loaded in the picture downloaded.
Preferably, described display module 302 also for when described equipment judges that the rolling speed of described display interface is less than the second preset value, carries out pre-rendered to picture to be loaded in the picture downloaded.
Preferably, described display module 302 also for when judging that the rolling speed of described display interface reaches the second preset value, load default picture.
The above is only the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, under the prerequisite not departing from the technology of the present invention principle; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.