From my point of view,what you want is to start another activity when the GIF Animation finished rather than the gif is just load into your ImageView.
In such case, you'd better measure how long it will take to finish the gif animation and make it a local variable.In order to make sure the gif animation is complete,it's better to make the time a bit longer than the animation costs.
Then do it like this.
long gifAnimationTime = 1000;// A bit more than the gif animation,you can ajust this to your situation.
Glide.with(this)
.load(R.drawable.image1)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// start your activity here.
}
}, gifAnimationTime);
return false;
}
})
.into(imageViewTarget);
I got something new.Try this:
Movie movie = Movie.decodeByteArray(gifdata,offset,length);
long period = movie.duration();