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