Glide Downloading GIF files

Source: Internet
Author: User

Before doing a similar to the view of a friend circle function, now also add the Save function.

Save the picture there are many ideas, can be extracted from the ImageView bitmap, can be downloaded to the local URL. If ImageView is extracted, the GIF will become a static figure.

My picture is loaded with glide, glide comes with a cache, and if you download the picture again with glide, the cache is read directly, saving time. The principle of this use is to save the glide cache file to the Pictures folder when you click Save Image.

/*** Created by Csonezp on 16-1-12.*/ Public classSaveimagetaskextendsAsynctask<string, Void, file> {    Private    Finalcontext Context;  PublicSaveimagetask (Context context) { This. Context =context; } @OverrideprotectedFile doinbackground (String ... params) {string URL= Params[0];//Should is easy-to- extend to share multiple images at once        Try {            returnGlide. With (context). Load (URL). downloadonly (Target.size_or Iginal, target.size_original). Get ()//needs to being called on background thread                    ; } Catch(Exception ex) {return NULL; }} @Overrideprotected voidOnPostExecute (File result) {if(Result = =NULL) {            return; } String Path=Result.getpath (); Fileutil.copyfile (Path, Fileutil.getpubalbumdir (). GetPath ()+ Uuid.randomuuid (). toString () + ". gif");    Globalutil.shorttoast (Context, context.getstring (r.string.save_success)); }}

Glide Downloading GIF files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.