fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Adding an animated drawable as a placeholder?

Open osrl opened this issue 11 years ago • 16 comments

Is there a way to add a prorgressBar or a different view (maybe a custom view like materialish-progress) as a placeholder? No image library is capable of this. Is the progressBarImage animatable?

osrl avatar Mar 28 '15 23:03 osrl

I have changes ready to add a real progress information to Fresco, so expect this very soon.

The way the progressBar works at the moment is: display progress bar image until the final image is ready. This is just a drawable and at the moment we provide the AutoRotateDrawable which can be used for displaying an indefinite spinner until the image is ready. You can specify progressBarImage and progressBarAutoRotateInterval in XML. You can also use your own drawable if you wish.

What I am adding now is real progress, so that as the bytes are downloading, we set the level to the progressbar drawable (0 to 10000). That means that drawable is now aware of the real progress and based on its level can display that progress in whichever way it wants. We'll provide a ProgressBarDrawable that just draws a line based on the percentage, but you can implement your custom drawable to do whatever you want.

plamenko avatar Mar 29 '15 22:03 plamenko

Any way we could play GIF as the placeholder ? May be not a loader but some other GIF itself. The only way I can think of right now is having two Drawee Views on top of each other one playing a local GIF till the network fetch happens and then hide it and show the loaded image from the network.

adnan-SM avatar Mar 30 '15 06:03 adnan-SM

This is possible, but in order to be able to answer on how to do it, I need the information on where do you get the GIF image from?

plamenko avatar Mar 30 '15 15:03 plamenko

Also, you can try using low-res image as explained in the documentation: http://frescolib.org/docs/requesting-multiple-images.html#_

DraweeController controller = Fresco.newDraweeControllerBuilder()
    .setLowResImageRequest(ImageRequest.fromUri(gifPlaceholderUri))
    .setImageRequest(ImageRequest.fromUri(uri))
    .setOldController(mSimpleDraweeView.getController())
    .build();
mSimpleDraweeView.setController(controller);

plamenko avatar Mar 30 '15 15:03 plamenko

The low resolution thing works fine, but what if I wanted to play a GIF bundled locally within the app in assets ? How would I do something like that, apart from having 2 overlapping drawee objects ?

adnan-SM avatar Mar 30 '15 15:03 adnan-SM

http://frescolib.org/docs/supported-uris.html#_

plamenko avatar Mar 30 '15 15:03 plamenko

@plamenko I set GIF to actual image,and RoundingParams don't work.

blackiedm avatar Mar 31 '15 01:03 blackiedm

Default rounding mode, BITMAP_ONLY, doesn't support animations. Please check if OVERLAY_COLOR rounding mode would work for you. For best appearance, you should use the same color that is beneath the DraweeView for overlay color (e.g. the ListView background color if DraweeView sits in the ListView). See http://frescolib.org/docs/rounded-corners-and-circles.html#_

plamenko avatar Mar 31 '15 13:03 plamenko

@plamenko thanks

blackiedm avatar Mar 31 '15 14:03 blackiedm

Hello @plamenko . You say there is no way to use a custom prorgressBar right now am I right? Is there a plan on that? I want to show an indefinite progressBar instead of a real progress. I think the only way to show good looking progressBar is hide/show drawee and progressBar. Could progressBarImage be an AnimationDrawable? That wouldn't be as smooth as a custom view though.

osrl avatar Apr 01 '15 07:04 osrl

Hi. Nope, I said that you can use whatever drawable you wish, but at the time we didn't support real progress. Now we do support real progress too, we just need to do a github push.

progressBarImage can be an AnimationDrawable, it's just that we don't call start/stop on it. I should probably add that logic.

plamenko avatar Apr 01 '15 11:04 plamenko

@plamenko did the push happen? It would be really useful

mhdatie avatar Apr 24 '15 14:04 mhdatie

Progress bars have been supported since v0.2.0. See their documentation.

tyronen avatar Apr 24 '15 15:04 tyronen

@tyronen figured that out 30 mins after my post :)

mhdatie avatar Apr 24 '15 15:04 mhdatie

Well, I have an animated drawable.. and it needs code to start it somewhere, can this be handled now on the current version?

sydneyagcaoili avatar Jan 13 '16 04:01 sydneyagcaoili

When I set the gif in function setLowResImageRequest(),it's showing but don't playing the animation @plamenko

Xwally avatar Jul 07 '17 02:07 Xwally