Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get GifDecoder from GifDrawable? #2397

Closed
berrytao7 opened this issue Sep 15, 2017 · 8 comments
Closed

how to get GifDecoder from GifDrawable? #2397

berrytao7 opened this issue Sep 15, 2017 · 8 comments
Labels

Comments

@berrytao7
Copy link

hello ,
my glide version now is 4.1.1,
before ,it is 3.8.0.
I want to know how to get GifDecoder for GifDdrawable in 4.1.1?
in 3.8.0 it is like this:
GifDecoder decoder = gifDrawable.getDecoder();
but now cannot find getDecoder method.

@sjudd
Copy link
Collaborator

sjudd commented Sep 15, 2017

In short, you can't.

Out of curiosity, what are you using the GifDecoder for?

@sjudd sjudd added the question label Sep 15, 2017
@berrytao7
Copy link
Author

I want to get the end of playing gif,
and then ,do something。
Is it has any method for this in Glide 4.1.1?

@sjudd
Copy link
Collaborator

sjudd commented Sep 15, 2017

What do you mean by gt the end of playing gif?

GifDrawable does have an API, but beyond that nothing is exposed by default. If you have a use case that is generally useful, please feel free to create a pull request to expand GifDrawable. If not, you could write your own ResourceDecoder that returns an extension of GifDrawable that exposes whatever you need.

@berrytao7
Copy link
Author

got it! Thanks

@ScreamingHawk
Copy link

I realise this issue is closed, but I too have this use case.

I want to set the number of loops of a GIF depending on the length of time the GIF runs for.

e.g. If it's a long GIF play once. If it's short play twice.

@niuyunedu
Copy link

niuyunedu commented Jan 12, 2018

I want to do something like @ScreamingHawk does, and I had the same problem.
Maybe I can write a class that extends GifDrawable to solve my problem, but I don't know how to do it.

public class MyGifDrawable extends GifDrawable {

	private final GifDecoder gifDecoder;

	public MyGifDrawable(Context context,
	                     GifDecoder gifDecoder,
	                     Transformation<Bitmap> frameTransformation,
	                     int targetFrameWidth,
	                     int targetFrameHeight,
	                     Bitmap firstFrame) {
		super(context, gifDecoder, frameTransformation, targetFrameWidth, targetFrameHeight, firstFrame);
		this.gifDecoder = gifDecoder;
	}

	public GifDecoder getGifDecoder() {
		return gifDecoder;
	}
}

Is any way to load a gif file as MyGifDrawable ?

@sjudd
Copy link
Collaborator

sjudd commented Jan 12, 2018

@niuyunedu You'd also need to write a ResourceDecoder and register it. http://bumptech.github.io/glide/doc/configuration.html#registering-components might be helpful.

@niuyunedu
Copy link

@sjudd Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants