CN111931095A - Picture loading method of Android system - Google Patents

Picture loading method of Android system Download PDF

Info

Publication number
CN111931095A
CN111931095A CN202010872337.7A CN202010872337A CN111931095A CN 111931095 A CN111931095 A CN 111931095A CN 202010872337 A CN202010872337 A CN 202010872337A CN 111931095 A CN111931095 A CN 111931095A
Authority
CN
China
Prior art keywords
picture
memory
loading
cache
cached
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010872337.7A
Other languages
Chinese (zh)
Inventor
李广
黄杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Bangqi Technology Group Co ltd
Original Assignee
Chongqing Bangqi Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Bangqi Technology Group Co ltd filed Critical Chongqing Bangqi Technology Group Co ltd
Priority to CN202010872337.7A priority Critical patent/CN111931095A/en
Publication of CN111931095A publication Critical patent/CN111931095A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a picture loading method of an Android system, which loads pictures in a three-level cache mode and comprises the following steps of: s1: judging whether the picture is cached or not, and if so, directly reading and loading from the cache; s2: creating a thread pool; s3: storing the data into a memory and a local area; s4: firstly, searching whether the current picture is cached in a memory, and if so, directly loading and displaying; if the cache does not exist, the next step is carried out; s5: searching whether the current picture is cached locally, if so, storing the picture in a memory cache, and loading and displaying the picture; if the cache does not exist, the next step is carried out; s6: downloading in a network, storing the data locally in a memory cache, and loading and displaying the data. By means of three-level caching, the picture loading efficiency is improved, the server pressure is reduced, and the downloading flow is reduced.

Description

Picture loading method of Android system
Technical Field
The invention relates to the technical field of communication, in particular to a picture loading method of an Android system.
Background
In current mobile devices, such as smartphones based on the Android system, the utilization rate of an APP for loading pictures is very high, sometimes tens of pictures need to be loaded on one page, and the reuse rate of the pictures is also very high, for example: the user's avatar, the merchandise's picture, etc. In a list page, the reuse rate of pictures is high, the number of pictures is increased continuously when a user slides the screen, and the pictures with the screen removed are usually processed. At this time, the garbage collector also considers that you no longer hold references to these pictures, and performs a GC (garbage collection) operation on these pictures. If pictures are loaded on the interface quickly in order to make the program run quickly, we need to consider that some pictures are recovered and then the user slides the pictures into the screen again, and we need to load the pictures again once.
Therefore, in the prior art, a cache manner is usually used to cache and load a part of the picture, and the current picture cache manner mainly includes a memory cache and a local storage. The memory caching is limited, each mobile phone can be divided into a certain memory according to the size of the memory, and the specific memory of different mobile phones is different, so that the memory caching has no way of caching a large number of pictures. Local storage may cache a large number of pictures, but the loading speed is slower than the memory cache.
Disclosure of Invention
In view of the defects of the prior art, the technical problem to be solved by the application of the present invention is how to provide a picture loading method of an Android system, which improves the picture loading speed and loading efficiency, enhances the user experience, enhances the user fluency, and reduces the server pressure and the download flow.
In order to solve the technical problems, the invention adopts the following technical scheme:
a picture loading method of an Android system loads pictures in a three-level cache mode, and comprises the following steps:
s1: judging whether the picture is cached or not, and if so, directly reading and loading from the cache;
s2: creating a thread pool;
s3: storing the data into a memory and a local area;
s4: firstly, searching whether the current picture is cached in a memory, and if so, directly loading and displaying; if the cache does not exist, the next step is carried out;
s5: searching whether the current picture is cached locally, if so, storing the picture in a memory cache, and loading and displaying the picture; if the cache does not exist, the next step is carried out;
s6: downloading in a network, storing the data locally in a memory cache, and loading and displaying the data.
In step S1, determining whether the picture is cached includes the following steps:
a1: reading from the memory by the Tag, judging whether the returned Bitmap is null or not, if not, indicating that the picture exists in the memory, directly loading, and if so, carrying out the next step;
a2: and obtaining from a local storage through Tag, and judging whether the returned Bitmap is null or not.
In step S2, the step of creating a thread pool includes:
Executors.newCachedThreadPool();。
in step S3, the step of storing in the memory and the local storage includes the following steps:
p1: instantiating an LruCache;
p2: defining a set of storage tags;
p3: storing the url address as a mark in the set;
p4: managing picture network downloading by using a thread pool;
p5: converting the acquired streaming file into a Bitmap;
p6: and respectively storing the stream files into a local memory and a memory.
In step S4, searching whether the current picture is cached in the memory includes the following steps:
c1: get (url) method to get Bitmap;
C2:iv.setImageBitmap(bitmap)。
in step S5, it is locally found whether the current picture is cached, and the packet block includes the following steps:
n1: acquiring a local picture cache path;
n2: converting the picture cache path into a Bitmap;
N3:iv.setImageBitmap(bitmap);。
in summary, the picture loading method of the Android system mainly loads through the memory cache, but the memory cache space value is limited and small, so that cache data is easily lost through the memory cache only, and therefore, the picture is loaded through the three-level cache manner, the picture loading speed is increased, and the user use fluency is enhanced.
The method comprises the steps of storing the picture in an internal memory and the local memory in a three-level cache mode, firstly searching whether the picture exists in the internal memory cache when the picture needs to be loaded each time, searching in the local memory if the picture does not exist, then caching the local picture in the internal memory again after the picture is found, and improving the picture loading efficiency, reducing the pressure of a server and reducing the downloading flow by the picture loading method.
Drawings
Fig. 1 is a flowchart of a picture loading method for an Android system according to the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings. In the description of the present invention, it is to be understood that the orientation or positional relationship indicated by the orientation words such as "upper, lower" and "top, bottom" etc. are usually based on the orientation or positional relationship shown in the drawings, and are only for convenience of description and simplicity of description, and in the case of not making a reverse description, these orientation words do not indicate and imply that the device or element referred to must have a specific orientation or be constructed and operated in a specific orientation, and therefore, should not be interpreted as limiting the scope of the present invention; the terms "inner and outer" refer to the inner and outer relative to the profile of the respective component itself.
As shown in fig. 1, a method for loading a picture in an Android system loads a picture in a three-level cache manner, and includes the following steps:
s1: judging whether the picture is cached or not, and if so, directly reading and loading from the cache;
s2: creating a thread pool;
s3: storing the data into a memory and a local area;
s4: firstly, searching whether the current picture is cached in a memory, and if so, directly loading and displaying; if the cache does not exist, the next step is carried out;
s5: searching whether the current picture is cached locally, if so, storing the picture in a memory cache, and loading and displaying the picture; if the cache does not exist, the next step is carried out;
s6: downloading in a network, storing the data locally in a memory cache, and loading and displaying the data.
In step S1, determining whether the picture is cached includes the following steps:
a1: reading from the memory by the Tag, judging whether the returned Bitmap is null or not, if not, indicating that the picture exists in the memory, directly loading, and if so, carrying out the next step;
a2: and obtaining from a local storage through Tag, and judging whether the returned Bitmap is null or not.
In step S2, the step of creating a thread pool includes:
Executors.newCachedThreadPool();。
in step S3, the step of storing in the memory and the local storage includes the following steps:
p1: instantiating an LruCache;
p2: defining a set of storage tags;
p3: storing the url address as a mark in the set;
p4: managing picture network downloading by using a thread pool;
p5: converting the acquired streaming file into a Bitmap;
p6: and respectively storing the stream files into a local memory and a memory.
In step S4, searching whether the current picture is cached in the memory includes the following steps:
c1: get (url) method to get Bitmap;
C2:iv.setImageBitmap(bitmap)。
in step S5, it is locally found whether the current picture is cached, and the packet block includes the following steps:
n1: acquiring a local picture cache path;
n2: converting the picture cache path into a Bitmap;
N3:iv.setImageBitmap(bitmap);。
in summary, the picture loading method of the Android system mainly loads through the memory cache, but the memory cache space value is limited and small, so that cache data is easily lost through the memory cache only, and therefore, the picture is loaded through the three-level cache manner, the picture loading speed is increased, and the user use fluency is enhanced.
The method comprises the steps of storing the picture in an internal memory and the local memory in a three-level cache mode, firstly searching whether the picture exists in the internal memory cache when the picture needs to be loaded each time, searching in the local memory if the picture does not exist, then caching the local picture in the internal memory again after the picture is found, and improving the picture loading efficiency, reducing the pressure of a server and reducing the downloading flow by the picture loading method.
Finally, it should be noted that: various modifications and alterations of this invention may be made by those skilled in the art without departing from the spirit and scope of this invention. Thus, it is intended that the present invention cover the modifications and variations of this invention provided they come within the scope of the appended claims and their equivalents.

Claims (6)

1. A picture loading method of an Android system is characterized in that a picture is loaded in a three-level cache mode, and the method comprises the following steps:
s1: judging whether the picture is cached or not, and if so, directly reading and loading from the cache;
s2: creating a thread pool;
s3: storing the data into a memory and a local area;
s4: firstly, searching whether the current picture is cached in a memory, and if so, directly loading and displaying; if the cache does not exist, the next step is carried out;
s5: searching whether the current picture is cached locally, if so, storing the picture in a memory cache, and loading and displaying the picture; if the cache does not exist, the next step is carried out;
s6: downloading in a network, storing the data locally in a memory cache, and loading and displaying the data.
2. The method for loading the picture in the Android system according to claim 1, wherein in step S1, determining whether the picture is cached comprises the following steps:
a1: reading from the memory by the Tag, judging whether the returned Bitmap is null or not, if not, indicating that the picture exists in the memory, directly loading, and if so, carrying out the next step;
a2: and obtaining from a local storage through Tag, and judging whether the returned Bitmap is null or not.
3. The picture loading method for the Android system as recited in claim 1, wherein in step S2, the step of creating a thread pool includes: new cachedthreadpool (); .
4. The picture loading method for the Android system as claimed in claim 1, wherein in step S3, the storing to the memory and the local storage includes the following steps:
p1: instantiating an LruCache;
p2: defining a set of storage tags;
p3: storing the url address as a mark in the set;
p4: managing picture network downloading by using a thread pool;
p5: converting the acquired streaming file into a Bitmap;
p6: and respectively storing the stream files into a local memory and a memory.
5. The picture loading method for the Android system as recited in claim 1, wherein in step S4, whether the current picture is cached is searched in a memory, and the method comprises the following steps:
c1: get (url) method to get Bitmap;
C2:iv.setImageBitmap(bitmap)。
6. the picture loading method for the Android system as recited in claim 1, wherein in step S5, whether the current picture is cached is locally searched, and the packet block is packaged by the following steps:
n1: acquiring a local picture cache path;
n2: converting the picture cache path into a Bitmap;
N3:iv.setImageBitmap(bitmap);。
CN202010872337.7A 2020-08-26 2020-08-26 Picture loading method of Android system Pending CN111931095A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010872337.7A CN111931095A (en) 2020-08-26 2020-08-26 Picture loading method of Android system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010872337.7A CN111931095A (en) 2020-08-26 2020-08-26 Picture loading method of Android system

Publications (1)

Publication Number Publication Date
CN111931095A true CN111931095A (en) 2020-11-13

Family

ID=73305841

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010872337.7A Pending CN111931095A (en) 2020-08-26 2020-08-26 Picture loading method of Android system

Country Status (1)

Country Link
CN (1) CN111931095A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112631782A (en) * 2020-12-30 2021-04-09 中科星通(廊坊)信息技术有限公司 Method for rapidly loading remote sensing image on Android system
CN113033173A (en) * 2021-04-26 2021-06-25 广州文石信息科技有限公司 Streaming document picture loading method and device, electronic equipment and storage medium
CN114420263A (en) * 2022-03-29 2022-04-29 太极计算机股份有限公司 Medical image data loading method, device and system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106095835A (en) * 2016-05-31 2016-11-09 广东能龙教育股份有限公司 Client side picture four-layer caching method
CN107463627A (en) * 2017-07-11 2017-12-12 深圳市云领天下科技有限公司 A kind of picture loading method and terminal
CN108197160A (en) * 2017-12-12 2018-06-22 腾讯科技(深圳)有限公司 A kind of picture loading method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106095835A (en) * 2016-05-31 2016-11-09 广东能龙教育股份有限公司 Client side picture four-layer caching method
CN107463627A (en) * 2017-07-11 2017-12-12 深圳市云领天下科技有限公司 A kind of picture loading method and terminal
CN108197160A (en) * 2017-12-12 2018-06-22 腾讯科技(深圳)有限公司 A kind of picture loading method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112631782A (en) * 2020-12-30 2021-04-09 中科星通(廊坊)信息技术有限公司 Method for rapidly loading remote sensing image on Android system
CN113033173A (en) * 2021-04-26 2021-06-25 广州文石信息科技有限公司 Streaming document picture loading method and device, electronic equipment and storage medium
CN114420263A (en) * 2022-03-29 2022-04-29 太极计算机股份有限公司 Medical image data loading method, device and system

Similar Documents

Publication Publication Date Title
CN111931095A (en) Picture loading method of Android system
US9229622B2 (en) Visual treatment for a tile-based user interface in a content integration framework
CN101741986B (en) Page cache method for mobile communication equipment terminal
CN104699626B (en) Terminal internal memory processing method, device and terminal
US9235874B2 (en) Image processor for and method of upscaling and denoising using contextual video information
CN104820589B (en) A kind of method and its device of dynamic adaptation webpage
CN103345493B (en) Method that content of text on mobile terminal shows, Apparatus and system
US20160364373A1 (en) Method and apparatus for extracting webpage information
CN103473732B (en) Based on the mobile GIS slice map exhibiting method of con current control and dual-cache mechanism
US9483507B2 (en) Method for managing data and an electronic device thereof
CN108108089B (en) Picture loading method and device
CN104808952A (en) Data caching method and device
US20220035655A1 (en) Method and Device for Anonymous Page Management, Terminal Device, and Readable Storage Medium
CN104902327A (en) Method for updating and issuing page content, smart television and system
US20190114989A1 (en) Systems and methods for image optimization
CN104216902A (en) Paging data loading method, device and system based on server paging
CN105808221A (en) Card type desktop realization method and apparatus
US9754391B2 (en) Webpage display method and apparatus
CN105808307B (en) Page display method and device
CN115731313A (en) SVG format picture processing method, device, equipment, medium and product
US20190245827A1 (en) Method and apparatus for synchronizing contact information and medium
CN109558145A (en) Installation package volume optimization method and device for android application
CN102779181A (en) Browser off-line storage data processing method based on hypertext markup language (HTML) 5 and browser
WO2017092455A1 (en) Method for web browsing in mobile terminal, and mobile terminal
CN111858612A (en) Data accelerated access method and device based on graph database and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20201113