public override void SetImageDrawable(Drawable drawable) { var gifDrawable = drawable as FFGifDrawable; if (gifDrawable != null) { _tcs?.Cancel(); _tcs = new CancellationTokenSource(); var previous = Drawable; _drawableRef = new WeakReference <Drawable>(drawable); base.SetImageDrawable(drawable); UpdateDrawableDisplayedState(drawable, true); UpdateDrawableDisplayedState(previous, false); PlayGif(gifDrawable, _tcs.Token); return; } GifDecoder currenGifDecoder = null; Drawable currentDrawable = null; if (_drawableRef != null && _drawableRef.TryGetTarget(out currentDrawable) && currentDrawable != null) { var currentGifDrawable = currentDrawable as FFGifDrawable; currenGifDecoder = currentGifDrawable?.GifDecoder; } var bitmapDrawable = drawable as BitmapDrawable; if (bitmapDrawable == null || currenGifDecoder == null || !currenGifDecoder.ContainsBitmap(bitmapDrawable?.Bitmap)) { _tcs?.Cancel(); var previous = Drawable; _drawableRef = new WeakReference <Drawable>(drawable); base.SetImageDrawable(drawable); UpdateDrawableDisplayedState(drawable, true); UpdateDrawableDisplayedState(previous, false); } else { base.SetImageDrawable(drawable); } }